| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a775479 commit 2ec64a6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -321,6 +321,34 @@ def test_combine_time_responses(): | |||
| 321 | 321 | ct.combine_time_responses([resp1, resp]) | |
| 322 | 322 | ||
| 323 | 323 | ||
| 324 | + @pytest.mark.usefixtures('mplcleanup') | ||
| 325 | + def test_time_response_plot_response_list(): | ||
| 326 | + sys = ct.ss(ct.tf([1, 2], [3, 4, 5])) | ||
| 327 | + timepts = np.linspace(0, 10) | ||
| 328 | + resp1 = ct.input_output_response(sys, timepts, np.sin(timepts)) | ||
| 329 | + resp2 = ct.input_output_response(sys, timepts, np.cos(timepts)) | ||
| 330 | + | ||
| 331 | + cplt = ct.time_response_plot( | ||
| 332 | + [resp1, resp2], trace_labels=["sine input", "cosine input"]) | ||
| 333 | + assert cplt.lines.shape == (2, 2) | ||
| 334 | + assert cplt.axes[0, 0].get_title() == "sine input" | ||
| 335 | + assert cplt.axes[0, 1].get_title() == "cosine input" | ||
| 336 | + assert all(len(lines.item()) == 1 for lines in np.nditer( | ||
| 337 | + cplt.lines, flags=["refs_ok"])) | ||
| 338 | + plt.close() | ||
| 339 | + | ||
| 340 | + cplt = ct.time_response_plot([resp1, resp2], plot_inputs=True) | ||
| 341 | + assert cplt.lines.shape == (2, 2) | ||
| 342 | + assert all(len(lines.item()) == 1 for lines in np.nditer( | ||
| 343 | + cplt.lines, flags=["refs_ok"])) | ||
| 344 | + plt.close() | ||
| 345 | + | ||
| 346 | + cplt = ct.time_response_plot([resp1, resp2], plot_inputs='overlay') | ||
| 347 | + assert cplt.lines.shape == (1, 2) | ||
| 348 | + assert all(len(lines.item()) == 2 for lines in np.nditer( | ||
| 349 | + cplt.lines, flags=["refs_ok"])) | ||
| 350 | + | ||
| 351 | + | ||
| 324 | 352 | @pytest.mark.parametrize("resp_fcn", [ | |
| 325 | 353 | ct.step_response, ct.initial_response, ct.impulse_response, | |
| 326 | 354 | ct.forced_response, ct.input_output_response]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,8 +52,9 @@ def time_response_plot( | |||
| 52 | 52 | ||
| 53 | 53 | Parameters | |
| 54 | 54 | ---------- | |
| 55 | - data : `TimeResponseData` | ||
| 56 | - Data to be plotted. | ||
| 55 | + data : `TimeResponseData` or list of `TimeResponseData` | ||
| 56 | + Data to be plotted. Lists of responses are combined into a | ||
| 57 | + multi-trace response before plotting. | ||
| 57 | 58 | plot_inputs : bool or str, optional | |
| 58 | 59 | Sets how and where to plot the inputs: | |
| 59 | 60 | * False: don't plot the inputs | |
@@ -179,6 +180,9 @@ def time_response_plot( | |||
| 179 | 180 | # | |
| 180 | 181 | # Process keywords and set defaults | |
| 181 | 182 | # | |
| 183 | + if isinstance(data, (list, tuple)): | ||
| 184 | + data = combine_time_responses(data, trace_labels=trace_labels) | ||
| 185 | + | ||
| 182 | 186 | # Set up defaults | |
| 183 | 187 | ax_user = ax | |
| 184 | 188 | sharex = config._get_param('timeplot', 'sharex', kwargs, pop=True) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments