Skip to content

Commit da64e0e

Browse files
authored
Merge pull request #1030 from murrayrm/diemilio-main
Update `timeplot.py` to fix error in `combine_time_responses`.
2 parents bb82883 + 937783a commit da64e0e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

control/tests/timeplot_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_combine_time_responses():
258258
sys_mimo = ct.rss(4, 2, 2)
259259
timepts = np.linspace(0, 10, 100)
260260

261-
# Combine two response with ntrace = 0
261+
# Combine two responses with ntrace = 0
262262
U = np.vstack([np.sin(timepts), np.cos(2*timepts)])
263263
resp1 = ct.input_output_response(sys_mimo, timepts, U)
264264

@@ -293,6 +293,7 @@ def test_combine_time_responses():
293293
combresp4 = ct.combine_time_responses(
294294
[resp1, resp2, resp3], trace_labels=labels)
295295
assert combresp4.trace_labels == labels
296+
assert combresp4.trace_types == [None, None, 'step', 'step']
296297

297298
# Automatically generated trace label names and types
298299
resp5 = ct.step_response(sys_mimo, timepts)
@@ -302,7 +303,13 @@ def test_combine_time_responses():
302303
combresp5 = ct.combine_time_responses([resp1, resp5])
303304
assert combresp5.trace_labels == [resp1.title] + \
304305
["test, trace 0", "test, trace 1"]
305-
assert combresp4.trace_types == [None, None, 'step', 'step']
306+
assert combresp5.trace_types == [None, None, None]
307+
308+
# ntraces = 0 with trace_types != None
309+
# https://github.com/python-control/python-control/issues/1025
310+
resp6 = ct.forced_response(sys_mimo, timepts, U)
311+
combresp6 = ct.combine_time_responses([resp1, resp6])
312+
assert combresp6.trace_types == [None, 'forced']
306313

307314
with pytest.raises(ValueError, match="must have the same number"):
308315
resp = ct.step_response(ct.rss(4, 2, 3), timepts)

control/timeplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ def combine_time_responses(response_list, trace_labels=None, title=None):
738738
if generate_trace_labels:
739739
trace_labels.append(response.title)
740740
trace_types.append(
741-
None if response.trace_types is None else response.types[0])
741+
None if response.trace_types is None
742+
else response.trace_types[0])
742743

743744
else:
744745
# Save the data

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy