GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix TimeResponseData.to_pandas() for multi-trace responses by murrayrm · Pull Request #1088 · python-control/python-control

Conversation

@murrayrm

@murrayrm murrayrm commented Dec 31, 2024

Copy link
Copy Markdown
Member

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
murrayrm added 2 commits December 30, 2024 14:15
@murrayrm
add unit test showing failure in python-control#1087
448fb62
@murrayrm
fix TimeResponseData.to_pandas() for multi-trace responses
96d3228
@murrayrm murrayrm linked an issue Dec 31, 2024 that may be closed by this pull request
control.timeresp.TimeResponseData.to_pandas() failing #1087
Closed
@coveralls

coveralls commented Dec 31, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

coverage: 94.731% (+0.001%) from 94.73%
when pulling 7707ea8 on murrayrm:fix_topandas-30Dec2024
into 859ece6 on python-control:main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slivingston
slivingston self-requested a review December 31, 2024 18:20
slivingston
slivingston approved these changes Jan 1, 2025
View reviewed changes
Comment thread control/tests/timeresp_test.py
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])

@slivingston slivingston Jan 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 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])

@slivingston slivingston Jan 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
joaoantoniocardoso
joaoantoniocardoso approved these changes Jan 1, 2025
View reviewed changes

@joaoantoniocardoso joaoantoniocardoso left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@murrayrm
update unit test per @slivinsgston review
7707ea8
@murrayrm
murrayrm merged commit 21c8f31 into python-control:main Jan 2, 2025
@murrayrm murrayrm added this to the 0.10.2 milestone Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slivingston slivingston slivingston approved these changes
+1 more reviewer
@joaoantoniocardoso joaoantoniocardoso joaoantoniocardoso approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

0.10.2

Development

Successfully merging this pull request may close these issues.

control.timeresp.TimeResponseData.to_pandas() failing

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@murrayrm @coveralls @slivingston @joaoantoniocardoso
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.