Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
672f229
Made sure interconnectedsystems keeps names of parts.
samlaf May 14, 2020
15a442a
Update control/iosys.py
samlaf May 18, 2020
77f9441
Update control/iosys.py
samlaf May 18, 2020
d45a6c0
Fixed signal names for InterconnectedSystems.
samlaf May 20, 2020
b688729
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
samlaf May 20, 2020
c8fba97
Update control/iosys.py
samlaf Jul 15, 2020
bd38dea
Update control/iosys.py
samlaf Jul 15, 2020
35676f2
Fixed some naming convention problems and added unit tests for naming…
samlaf Jul 16, 2020
90705d4
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
samlaf Jul 16, 2020
0113f99
set default dt to be 0 instead of None. Now need to fix resulting uni…
sawyerbfuller Jul 17, 2020
9aed7cc
changes so that a default dt=0 passes unit tests. fixed code everywhe…
sawyerbfuller Jul 17, 2020
7a9bcd4
small bugfix to xferfcn._evalfr to correctly give it dt value
sawyerbfuller Jul 18, 2020
d59e57a
removed a brittle unit test dependency that is already tested elsewhere
sawyerbfuller Jul 18, 2020
69cc8c5
Removed for loops from tests to get better error messages
samlaf Jul 19, 2020
e76a4f8
Update control/iosys.py
samlaf Jul 19, 2020
abb1f19
Changed a lot of naming convention code/unit test following pull-requ…
samlaf Jul 19, 2020
f955b3a
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
samlaf Jul 19, 2020
3ec2f02
Fixed system naming conventions and unit tests. Still need to do sign…
samlaf Jul 19, 2020
8c957b2
Merge branch 'master' into interconnectedsystems
murrayrm Jul 20, 2020
c96465d
improved unit test suggestd by ben greiner
sawyerbfuller Jul 20, 2020
2ec1653
re-incorporated lti.timebaseEqual, with a pendingDeprecationWarning
sawyerbfuller Jul 20, 2020
1e001ee
changes to enable package-wide default, 'control.default_dt')
sawyerbfuller Jul 20, 2020
b2c8d44
Finished test_signals_naming_convention unit test
samlaf Jul 20, 2020
f5c3fac
fixes to docstrings and conventions.rst to match convention of dt=0 a…
sawyerbfuller Jul 20, 2020
c6787cc
remove extraneous file
sawyerbfuller Jul 21, 2020
606975d
new method is_static_gain() for state space and transfer function sys…
sawyerbfuller Jul 22, 2020
2bd912d
added keyword arguments to xferfcn.tf and statesp.ss to set dt
sawyerbfuller Jul 22, 2020
dc53eb9
unit tests for is_static_gain system method and dt keyword in system …
sawyerbfuller Jul 23, 2020
9da5295
Merge branch 'pr431' into mergetest-prs-400-431-433
bnavigator Jul 23, 2020
d1ac4bb
common_timebase will already raise
bnavigator Jul 23, 2020
e3ff725
Merge branch 'pr433' into mergetest-prs-400-431-433
bnavigator Jul 23, 2020
35f6202
Merge branch 'pr433' into merge-400-431-433-before438
bnavigator Jul 26, 2020
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
Prev Previous commit
Next Next commit
Merge branch 'pr433' into mergetest-prs-400-431-433
and clean up codestyle a tiny bit
  • Loading branch information
bnavigator committed Jul 23, 2020
commit e3ff72530da07f57838f4b34e5844dabdd380459
52 changes: 28 additions & 24 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@

# Define module default parameter values
_statesp_defaults = {
'statesp.use_numpy_matrix': True,
'statesp.remove_useless_states': True,
'statesp.use_numpy_matrix': False,
'statesp.default_dt': None,
'statesp.remove_useless_states': True,
}


Expand Down Expand Up @@ -147,21 +148,21 @@ class StateSpace(LTI):
`numpy.ndarray` objects. The :func:`~control.use_numpy_matrix` function
can be used to set the storage type.

A discrete time system is created by specifying a nonzero 'timebase', dt
A discrete time system is created by specifying a nonzero 'timebase', dt
when the system is constructed:

* dt = 0: continuous time system (default)
* dt > 0: discrete time system with sampling period 'dt'
* dt = True: discrete time with unspecified sampling period
* dt = None: no timebase specified

Systems must have compatible timebases in order to be combined. A discrete
time system with unspecified sampling time (`dt = True`) can be combined
with a system having a specified sampling time; the result will be a
discrete time system with the sample time of the latter system. Similarly,
a system with timebase `None` can be combined with a system having any
timebase; the result will have the timebase of the latter system.
The default value of dt can be changed by changing the value of
* dt = None: no timebase specified

Systems must have compatible timebases in order to be combined. A discrete
time system with unspecified sampling time (`dt = True`) can be combined
with a system having a specified sampling time; the result will be a
discrete time system with the sample time of the latter system. Similarly,
a system with timebase `None` can be combined with a system having any
timebase; the result will have the timebase of the latter system.
The default value of dt can be changed by changing the value of
``control.config.defaults['control.default_dt']``.
"""

Expand Down Expand Up @@ -192,17 +193,20 @@ def __init__(self, *args, **kwargs):
elif len(args) == 1:
# Use the copy constructor.
if not isinstance(args[0], StateSpace):
raise TypeError("The one-argument constructor can only take in a StateSpace "
"object. Received %s." % type(args[0]))
raise TypeError("The one-argument constructor can only take in"
" a StateSpace object."
" Received %s." % type(args[0]))
A = args[0].A
B = args[0].B
C = args[0].C
D = args[0].D
else:
raise ValueError("Expected 1, 4, or 5 arguments; received %i." % len(args))
raise ValueError(
"Expected 1, 4, or 5 arguments; received %i." % len(args))

# Process keyword arguments
remove_useless = kwargs.get('remove_useless', config.defaults['statesp.remove_useless_states'])
remove_useless = kwargs.get(
'remove_useless', config.defaults['statesp.remove_useless_states'])

# Convert all matrices to standard form
A = _ssmatrix(A)
Expand All @@ -228,10 +232,10 @@ def __init__(self, *args, **kwargs):
self.D = D

# now set dt
if len(args) == 4:
if len(args) == 4:
if 'dt' in kwargs:
dt = kwargs['dt']
elif self.is_static_gain():
elif self.is_static_gain():
dt = None
else:
dt = config.defaults['control.default_dt']
Expand All @@ -243,7 +247,7 @@ def __init__(self, *args, **kwargs):
try:
dt = args[0].dt
except NameError:
if self.is_static_gain():
if self.is_static_gain():
dt = None
else:
dt = config.defaults['control.default_dt']
Expand Down Expand Up @@ -873,8 +877,8 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None):

prewarp_frequency : float within [0, infinity)
The frequency [rad/s] at which to match with the input continuous-
time system's magnitude and phase (the gain=1 crossover frequency,
for example). Should only be specified with method='bilinear' or
time system's magnitude and phase (the gain=1 crossover frequency,
for example). Should only be specified with method='bilinear' or
'gbt' with alpha=0.5 and ignored otherwise.

Returns
Expand All @@ -899,7 +903,7 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None):
if (method=='bilinear' or (method=='gbt' and alpha==0.5)) and \
prewarp_frequency is not None:
Twarp = 2*np.tan(prewarp_frequency*Ts/2)/prewarp_frequency
else:
else:
Twarp = Ts
Ad, Bd, C, D, _ = cont2discrete(sys, Twarp, method, alpha)
return StateSpace(Ad, Bd, C, D, Ts)
Expand Down Expand Up @@ -932,9 +936,9 @@ def dcgain(self):
# eigenvalue at DC
gain = np.tile(np.nan, (self.outputs, self.inputs))
return np.squeeze(gain)

def is_static_gain(self):
"""True if and only if the system has no dynamics, that is,
"""True if and only if the system has no dynamics, that is,
if A and B are zero. """
return not np.any(self.A) and not np.any(self.B)

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.