Skip to content

Commit 96d813c

Browse files
committed
remove _NamedIOStateSystem class
1 parent c2e3993 commit 96d813c

3 files changed

Lines changed: 29 additions & 50 deletions

File tree

control/iosys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import copy
3232
from warnings import warn
3333

34-
from .namedio import _NamedIOStateSystem, _process_signal_list
34+
from .namedio import _NamedIOSystem, _process_signal_list
3535
from .statesp import StateSpace, tf2ss, _convert_to_statespace
3636
from .statesp import _ss, _rss_generate
3737
from .xferfcn import TransferFunction
@@ -55,7 +55,7 @@
5555
}
5656

5757

58-
class InputOutputSystem(_NamedIOStateSystem):
58+
class InputOutputSystem(_NamedIOSystem):
5959
"""A class for representing input/output systems.
6060
6161
The InputOutputSystem class allows (possibly nonlinear) input/output
@@ -139,7 +139,7 @@ def __init__(self, inputs=None, outputs=None, states=None, params={},
139139
140140
"""
141141
# Store the system name, inputs, outputs, and states
142-
_NamedIOStateSystem.__init__(
142+
_NamedIOSystem.__init__(
143143
self, inputs=inputs, outputs=outputs, states=states, name=name)
144144

145145
# default parameters

control/namedio.py

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# namedio.py - internal named I/O object class
22
# RMM, 13 Mar 2022
33
#
4-
# This file implements the _NamedIOSystem and _NamedIOStateSystem classes,
5-
# which are used as a parent classes for FrequencyResponseData,
6-
# InputOutputSystem, LTI, TimeResponseData, and other similar classes to
7-
# allow naming of signals.
4+
# This file implements the _NamedIOSystem class, which is used as a parent
5+
# class for FrequencyResponseData, InputOutputSystem, LTI, TimeResponseData,
6+
# and other similar classes to allow naming of signals.
87

98
import numpy as np
109

@@ -19,14 +18,15 @@ def _name_or_default(self, name=None):
1918
return name
2019

2120
def __init__(
22-
self, inputs=None, outputs=None, name=None):
21+
self, name=None, inputs=None, outputs=None, states=None):
2322

2423
# system name
2524
self.name = self._name_or_default(name)
2625

2726
# Parse and store the number of inputs and outputs
2827
self.set_inputs(inputs)
2928
self.set_outputs(outputs)
29+
self.set_states(states)
3030

3131
#
3232
# Class attributes
@@ -38,12 +38,17 @@ def __init__(
3838
#: Number of system inputs.
3939
#:
4040
#: :meta hide-value:
41-
ninputs = 0
41+
ninputs = None
4242

4343
#: Number of system outputs.
4444
#:
4545
#: :meta hide-value:
46-
noutputs = 0
46+
noutputs = None
47+
48+
#: Number of system states.
49+
#:
50+
#: :meta hide-value:
51+
nstates = None
4752

4853
def __repr__(self):
4954
return str(type(self)) + ": " + self.name if self.name is not None \
@@ -58,6 +63,10 @@ def __str__(self):
5863
str += "\nOutputs (%s): " % self.noutputs
5964
for key in self.output_index:
6065
str += key + ", "
66+
if self.nstates is not None:
67+
str += "\nStates (%s): " % self.nstates
68+
for key in self.state_index:
69+
str += key + ", "
6170
return str
6271

6372
# Find a signal by name
@@ -122,44 +131,6 @@ def find_output(self, name):
122131
lambda self: list(self.output_index.keys()), # getter
123132
set_outputs) # setter
124133

125-
def issiso(self):
126-
"""Check to see if a system is single input, single output"""
127-
return self.ninputs == 1 and self.noutputs == 1
128-
129-
130-
class _NamedIOStateSystem(_NamedIOSystem):
131-
def __init__(
132-
self, inputs=None, outputs=None, states=None, name=None):
133-
# Parse and store the system name, inputs, and outputs
134-
super().__init__(inputs=inputs, outputs=outputs, name=name)
135-
136-
# Parse and store the number of states
137-
self.set_states(states)
138-
139-
#
140-
# Class attributes
141-
#
142-
# These attributes are defined as class attributes so that they are
143-
# documented properly. They are "overwritten" in __init__.
144-
#
145-
146-
#: Number of system states.
147-
#:
148-
#: :meta hide-value:
149-
nstates = 0
150-
151-
def __str__(self):
152-
"""String representation of an input/output system"""
153-
str = _NamedIOSystem.__str__(self)
154-
str += "\nStates (%s): " % self.nstates
155-
for key in self.state_index:
156-
str += key + ", "
157-
return str
158-
159-
def _isstatic(self):
160-
"""Check to see if a system is a static system (no states)"""
161-
return self.nstates == 0
162-
163134
def set_states(self, states, prefix='x'):
164135
"""Set the number/names of the system states.
165136
@@ -189,6 +160,14 @@ def find_state(self, name):
189160
lambda self: list(self.state_index.keys()), # getter
190161
set_states) # setter
191162

163+
def issiso(self):
164+
"""Check to see if a system is single input, single output"""
165+
return self.ninputs == 1 and self.noutputs == 1
166+
167+
def _isstatic(self):
168+
"""Check to see if a system is a static system (no states)"""
169+
return self.nstates == 0
170+
192171

193172
# Utility function to parse a list of signals
194173
def _process_signal_list(signals, prefix='s'):

control/statesp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
from scipy.signal import StateSpace as signalStateSpace
6060
from warnings import warn
6161
from .lti import LTI, common_timebase, isdtime, _process_frequency_response
62-
from .namedio import _NamedIOStateSystem, _process_signal_list
62+
from .namedio import _NamedIOSystem, _process_signal_list
6363
from . import config
6464
from copy import deepcopy
6565

@@ -153,7 +153,7 @@ def _f2s(f):
153153
return s
154154

155155

156-
class StateSpace(LTI, _NamedIOStateSystem):
156+
class StateSpace(LTI, _NamedIOSystem):
157157
"""StateSpace(A, B, C, D[, dt])
158158
159159
A class for representing state-space models.

0 commit comments

Comments
 (0)