Fix TimeResponseData.to_pandas() for multi-trace responses#1088
Merged
murrayrm merged 3 commits intopython-control:mainfrom Jan 2, 2025
Merged
Fix TimeResponseData.to_pandas() for multi-trace responses#1088murrayrm merged 3 commits intopython-control:mainfrom
murrayrm merged 3 commits intopython-control:mainfrom
Conversation
slivingston
approved these changes
Jan 1, 2025
Comment on lines
1279
to
1282
| np.testing.assert_equal( | ||
| df[df['trace'] == 'From u0']['time'], res.time) | ||
| np.testing.assert_equal( | ||
| df[df['trace'] == 'From u0']['y1'], res.outputs['y1', 0]) |
Member
There was a problem hiding this comment.
Suggested change
| np.testing.assert_equal( | |
| df[df['trace'] == 'From u0']['time'], res.time) | |
| np.testing.assert_equal( | |
| df[df['trace'] == 'From u0']['y1'], res.outputs['y1', 0]) | |
| np.testing.assert_equal( | |
| df[df['trace'] == 'From u0']['time'], res.time) | |
| np.testing.assert_equal( | |
| df[df['trace'] == 'From u0']['u0'], res.inputs['u0', 0]) | |
| np.testing.assert_equal( | |
| df[df['trace'] == 'From u0']['y1'], res.outputs['y1', 0]) |
Include comparison of inputs here to be symmetric with comparisons in the for-loop below.
control/tests/timeresp_test.py
Outdated
Comment on lines
1287
to
1290
| np.testing.assert_equal( | ||
| df[df['trace'] == label]['time'], res.time) | ||
| np.testing.assert_equal( | ||
| df[df['trace'] == label]['u0'], res.inputs['u0', i]) |
Member
There was a problem hiding this comment.
Suggested change
| np.testing.assert_equal( | |
| df[df['trace'] == label]['time'], res.time) | |
| np.testing.assert_equal( | |
| df[df['trace'] == label]['u0'], res.inputs['u0', i]) | |
| np.testing.assert_equal( | |
| df[df['trace'] == label]['time'], res.time) | |
| np.testing.assert_equal( | |
| df[df['trace'] == label]['u0'], res.inputs['u0', i]) | |
| np.testing.assert_equal( | |
| df[df['trace'] == label]['y1'], res.outputs['y1', i]) |
Include comparison of outputs here to be symmetric with comparisons for the case of single-trace above.
joaoantoniocardoso
approved these changes
Jan 1, 2025
Contributor
joaoantoniocardoso
left a comment
There was a problem hiding this comment.
Woah, that one was quick!
I've just tested it here, and it worked as a charm!
Thank you so much for keeping this lib, awesome work! And happy New Year! =D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #1087. Multi-trace data (e.g., the output from a MIMO step response) was not being processed correctly. This PR creates a new column 'trace' for multi-trace responses and reshapes the data appropriately. Unit tests and updated documentation are included.
Thanks to @joaoantoniocardoso for finding this bug and providing a fix (modified only slightly here).
@joaoantoniocardoso: if you have time to try this out and confirm that it works for your use case, that would be great. I think the only difference is that I used 'trace' for the column label instead of 'trace_label'. I also had to do things a bit differently for the case where there were multiple traces (your example was "multi-trace" but with sys.ntrace=1 since you selected an input).