Skip to content

Commit 4cedb6c

Browse files
committed
update FRD repr() + copy signal/system names on sampling
1 parent 6f7cbfa commit 4cedb6c

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

control/frdata.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ def __init__(self, *args, **kwargs):
285285
if self.squeeze not in (None, True, False):
286286
raise ValueError("unknown squeeze value")
287287

288-
# Process iosys keywords
289288
defaults = {
290289
'inputs': self.fresp.shape[1] if not getattr(
291290
self, 'input_index', None) else self.input_labels,
@@ -421,10 +420,20 @@ def __repr__(self):
421420
422421
limited for number of data points.
423422
"""
424-
return "FrequencyResponseData({d}, {w}{smooth})".format(
423+
out = "FrequencyResponseData(\n{d},\n{w}{smooth}".format(
425424
d=repr(self.fresp), w=repr(self.omega),
426425
smooth=(self._ifunc and ", smooth=True") or "")
427426

427+
if config.defaults['control.default_dt'] != self.dt:
428+
out += ",\ndt={dt}".format(
429+
dt='None' if self.dt is None else self.dt)
430+
431+
if len(labels := self._label_repr()) > 0:
432+
out += ",\n" + labels
433+
434+
out += ")"
435+
return out
436+
428437
def __neg__(self):
429438
"""Negate a transfer function."""
430439

control/tests/frd_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,12 @@ def test_repr_str(self):
465465
[0.1, 1.0, 10.0, 100.0], name='sys0')
466466
sys1 = ct.frd(
467467
sys0.fresp, sys0.omega, smooth=True, name='sys1')
468-
ref0 = "FrequencyResponseData(" \
469-
"array([[[1. +0.j , 0.9 +0.1j, 0.1 +2.j , 0.05+3.j ]]])," \
470-
" array([ 0.1, 1. , 10. , 100. ]))"
471-
ref1 = ref0[:-1] + ", smooth=True)"
468+
ref_common = "FrequencyResponseData(\n" \
469+
"array([[[1. +0.j , 0.9 +0.1j, 0.1 +2.j , 0.05+3.j ]]]),\n" \
470+
"array([ 0.1, 1. , 10. , 100. ]),"
471+
ref0 = ref_common + "\nname='sys0', outputs=1, inputs=1)"
472+
ref1 = ref_common + " smooth=True," + \
473+
"\nname='sys1', outputs=1, inputs=1)"
472474
sysm = ct.frd(
473475
np.matmul(array([[1], [2]]), sys0.fresp), sys0.omega, name='sysm')
474476

0 commit comments

Comments
 (0)