Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
from .robust import *
from .config import *
from .sisotool import *
from .iosys import *

# Exceptions
from .exception import *
Expand Down
5 changes: 5 additions & 0 deletions control/bdalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ def feedback(sys1, sys2=1, sign=-1):
scalars, then TransferFunction.feedback is used.

"""
# Allow anything with a feedback function to call that function
try:
return sys1.feedback(sys2, sign)
except AttributeError:
pass

# Check for correct input types.
if not isinstance(sys1, (int, float, complex, np.number,
Expand Down
1,795 changes: 1,795 additions & 0 deletions control/iosys.py

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions control/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,28 @@ def timebaseEqual(sys1, sys2):
else:
return sys1.dt == sys2.dt

# Find a common timebase between two or more systems
def _find_timebase(sys1, *sysn):
"""Find the common timebase between systems, otherwise return False"""

# Create a list of systems to check
syslist = [sys1]
syslist.append(*sysn)

# Look for a common timebase
dt = None

for sys in syslist:
# Make sure time bases are consistent
if (dt is None and sys.dt is not None) or \
(dt is True and isdiscrete(sys)):
# Timebase was not specified; set to match this system
dt = sys.dt
elif dt != sys.dt:
return False
return dt


# Check to see if a system is a discrete time system
def isdtime(sys, strict=False):
"""
Expand All @@ -200,6 +222,15 @@ def isdtime(sys, strict=False):
if isinstance(sys, LTI):
return sys.isdtime(strict)

# Check to see if object has a dt object
if hasattr(sys, 'dt'):
# If no timebase is given, answer depends on strict flag
if sys.dt == None:
return True if not strict else False

# Look for dt > 0 (also works if dt = True)
return sys.dt > 0

# Got passed something we don't recognize
return False

Expand All @@ -225,6 +256,13 @@ def isctime(sys, strict=False):
if isinstance(sys, LTI):
return sys.isctime(strict)

# Check to see if object has a dt object
if hasattr(sys, 'dt'):
# If no timebase is given, answer depends on strict flag
if sys.dt is None:
return True if not strict else False
return sys.dt == 0

# Got passed something we don't recognize
return False

Expand Down
7 changes: 5 additions & 2 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class StateSpace(LTI):
sampling time.
"""

def __init__(self, *args):
def __init__(self, *args, **kw):
"""
StateSpace(A, B, C, D[, dt])

Expand Down Expand Up @@ -152,6 +152,9 @@ def __init__(self, *args):
else:
raise ValueError("Needs 1 or 4 arguments; received %i." % len(args))

# Process keyword arguments
remove_useless = kw.get('remove_useless', True)

A, B, C, D = [_matrix(M) for M in (A, B, C, D)]

# TODO: use super here?
Expand Down Expand Up @@ -183,7 +186,7 @@ def __init__(self, *args):
raise ValueError("C and D must have the same number of rows.")

# Check for states that don't do anything, and remove them.
self._remove_useless_states()
if remove_useless: self._remove_useless_states()

def _remove_useless_states(self):
"""Check for states that don't do anything, and remove them.
Expand Down
Loading