-
Notifications
You must be signed in to change notification settings - Fork 438
Add missing labels when returning TimeResponseData #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a75a962
to
0a87017
Compare
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.
Thanks for this nice contribution. I suggest using *_labels
instead of *_index
, which I think makes the code a bit more readable.
control/timeresp.py
Outdated
output_labels=sys.output_index, input_labels=sys.input_index, | ||
state_labels=sys.state_index, |
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.
This is OK, but it might be more clear to use sys.output_labels
, etc.
control/timeresp.py
Outdated
# Select only the given input and output, if any | ||
input_index = sys.input_index if input is None else {k: 0 for k, v in sys.input_index.items() if v == input} | ||
output_index = sys.output_index if output is None else {k: 0 for k, v in sys.output_index.items() if v == output} | ||
|
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.
Consider changing this to
input_labels = sys.input_labels if input is None \
else sys.input_labels[input]
output_labels = sys.output_labels if output is None else \
sys.output_labels[output]
which seems cleaner.
control/timeresp.py
Outdated
output_labels=output_index, input_labels=input_index, | ||
state_labels=sys.state_index, |
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.
output_labels=output_labels, input_labels=input_labels,
state_labels=sys.state_labels,
control/timeresp.py
Outdated
# Select only the given output, if any | ||
output_index = sys.output_index if output is None else {k: 0 for k, v in sys.output_index.items() if v == output} | ||
|
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.
As above.
control/timeresp.py
Outdated
output_labels=output_index, input_labels=None, | ||
state_labels=sys.state_index, |
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.
As above.
control/timeresp.py
Outdated
# Select only the given input and output, if any | ||
input_index = sys.input_index if input is None else {k: 0 for k, v in sys.input_index.items() if v == input} | ||
output_index = sys.output_index if output is None else {k: 0 for k, v in sys.output_index.items() if v == output} | ||
|
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.
As above.
control/timeresp.py
Outdated
output_labels=output_index, input_labels=input_index, | ||
state_labels=sys.state_index, |
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.
As above.
Thanks, it surely makes it more readable, but I was unsure of using |
7b8db61
to
4ed8491
Compare
Hi @murrayrm, I did the changes regarding using |
4ed8491
to
7daed4b
Compare
control/timeresp.py
Outdated
# Get labels for the inputs/outputs (prior to mimo -> simo conversion) | ||
input_labels = sys.input_labels if input is None \ | ||
else [sys.input_labels[input]] | ||
output_labels = sys.output_labels if output is None \ | ||
else [sys.output_labels[output]] | ||
|
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.
I was thinking about it. Should we move it to here, or should we make the mimo/siso/simo conversions to also propagate the labels (and name)?
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.
Either way works, but because _get_ss_simo
is an internal function, it is fine for it to ignore labels.
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.
take a look at this commit
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.
It's your PR, so feel free to revert the code moves that I made and put in your proposed commit. I was just trying to get something that passed the unit tests, since they were failing.
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.
Also: I think it should work to do sys.output_labels[output]
instead of [sys.output_labels[output]]
(eg, remove the outer list). The code underneath is smart enough to deal with getting passed a string for a single input/output.
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.
Also: I think it should work to do
sys.output_labels[output]
instead of[sys.output_labels[output]]
(eg, remove the outer list). The code underneath is smart enough to deal with getting passed a string for a single input/output.
The _process_labels had a small bug, now it works with plain str instead of [str]
8d0fb10
to
bd83e8c
Compare
@murrayrm I'm good with the patch, let me know if you need any changes, otherwise feel free to merge it |
Fixes #891