From 70d976110f8c687de2ea3206dbd4e00d6d6ed1de Mon Sep 17 00:00:00 2001 From: Diego Emilio Serrano <65074936+diemilio@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:40:20 -0400 Subject: [PATCH 1/3] Update timeplot.py fix name of TimeResponseData object from types to trace_types --- control/timeplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/timeplot.py b/control/timeplot.py index 2eb7aec9b..646d2c1be 100644 --- a/control/timeplot.py +++ b/control/timeplot.py @@ -738,7 +738,7 @@ def combine_time_responses(response_list, trace_labels=None, title=None): if generate_trace_labels: trace_labels.append(response.title) trace_types.append( - None if response.trace_types is None else response.types[0]) + None if response.trace_types is None else response.trace_types[0]) else: # Save the data From d15e21fdedfa92a2af6909d63ea2e84aab4a8c63 Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 13 Jul 2024 09:05:51 -0700 Subject: [PATCH 2/3] add regression test --- control/tests/timeplot_test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/control/tests/timeplot_test.py b/control/tests/timeplot_test.py index 0fcc159be..58ef062a5 100644 --- a/control/tests/timeplot_test.py +++ b/control/tests/timeplot_test.py @@ -258,7 +258,7 @@ def test_combine_time_responses(): sys_mimo = ct.rss(4, 2, 2) timepts = np.linspace(0, 10, 100) - # Combine two response with ntrace = 0 + # Combine two responses with ntrace = 0 U = np.vstack([np.sin(timepts), np.cos(2*timepts)]) resp1 = ct.input_output_response(sys_mimo, timepts, U) @@ -293,6 +293,7 @@ def test_combine_time_responses(): combresp4 = ct.combine_time_responses( [resp1, resp2, resp3], trace_labels=labels) assert combresp4.trace_labels == labels + assert combresp4.trace_types == [None, None, 'step', 'step'] # Automatically generated trace label names and types resp5 = ct.step_response(sys_mimo, timepts) @@ -302,7 +303,13 @@ def test_combine_time_responses(): combresp5 = ct.combine_time_responses([resp1, resp5]) assert combresp5.trace_labels == [resp1.title] + \ ["test, trace 0", "test, trace 1"] - assert combresp4.trace_types == [None, None, 'step', 'step'] + assert combresp5.trace_types == [None, None, None] + + # ntraces = 0 with trace_types != None + # https://github.com/python-control/python-control/issues/1025 + resp6 = ct.forced_response(sys_mimo, timepts, U) + combresp6 = ct.combine_time_responses([resp1, resp6]) + assert combresp6.trace_types == [None, 'forced'] with pytest.raises(ValueError, match="must have the same number"): resp = ct.step_response(ct.rss(4, 2, 3), timepts) From 937783a427c55e7f18b5b32035f7583a932b6aea Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 13 Jul 2024 09:06:05 -0700 Subject: [PATCH 3/3] fix line length overflow --- control/timeplot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control/timeplot.py b/control/timeplot.py index 646d2c1be..f257d2b3a 100644 --- a/control/timeplot.py +++ b/control/timeplot.py @@ -738,7 +738,8 @@ def combine_time_responses(response_list, trace_labels=None, title=None): if generate_trace_labels: trace_labels.append(response.title) trace_types.append( - None if response.trace_types is None else response.trace_types[0]) + None if response.trace_types is None + else response.trace_types[0]) else: # Save the data