Skip to content

Enable scalar division of state-space objects #811

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

Merged
merged 3 commits into from
Dec 16, 2022

Conversation

roryyorke
Copy link
Contributor

I think this is a reasonable if minor improvement; it lets one write gscaled = g / 2 instead of gscaled = g * (1/2). I'm less sure about division by arrays, but I see multiplication by arrays is allowed, and it seems natural to have symmetry between these operations.

I added a simple test for StateSpace / scalar and StateSpace / array, but not for InputOutputSystem / scalar. etc.

I also modified the type-conversion tests as required.

Attempt division by any non-LTI and non-NameIOSystem by translating G
/ k to G * (1/k).

Division of StateSpace by TransferFunction, etc., unchanged.
These aren't used in Python 3.
@coveralls
Copy link

coveralls commented Dec 10, 2022

Coverage Status

Coverage increased (+0.05%) to 94.855% when pulling cc3fb2f on roryyorke:rory/ss-div-scalar into 9d65bf8 on python-control:main.

Copy link
Member

@murrayrm murrayrm left a comment

Choose a reason for hiding this comment

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

LGTM.

control/iosys.py Outdated
@@ -346,6 +346,17 @@ def __neg__(sys):
# Return the newly created system
return newsys

def __truediv__(sys2, sys1):
"""Multiply two input/output systems (series interconnection)"""
Copy link
Contributor

Choose a reason for hiding this comment

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

should this docstring say "divide"?

Copy link
Contributor

@sawyerbfuller sawyerbfuller left a comment

Choose a reason for hiding this comment

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

looks good to me - with one possible update in a docstrong

@roryyorke
Copy link
Contributor Author

roryyorke commented Dec 13, 2022 via email

@murrayrm murrayrm merged commit 4b712a4 into python-control:main Dec 16, 2022
@murrayrm murrayrm added this to the 0.9.3 milestone Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants