Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change InputOutputSystem repr to show type, name, inputs, and outputs#699

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

roryyorke
Copy link
Contributor

@roryyorkeroryyorke commentedJan 29, 2022
edited
Loading

I didn't know aboutInputOutputSystem 's__str__ implementation, and I find the__repr__ a bit bare-bones. With this change:

In [8]: import control as ct   ...: P1 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='u1', outputs='y1')   ...: P2 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='y1', outputs='y2')   ...: In [9]: display(P1)   ...: <LinearIOSystem:sys[6]:['u1']->['y1']>In [10]: ct.interconnect([P1, P2], inputs=['u1'], outputs=['y2'])    ...: Out[10]: <LinearICSystem:y2:['u1']->['y2']>In [11]: display(ct.InputOutputSystem())    ...: <InputOutputSystem:sys[9]:[]->[]>

This is a draft for comment - if it looks OK, I'll (eventually) improve it and add tests. One improvement I can see already: make the input and output lists a little prettier by removing the quotes.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.591% when pullingf06ef73 on roryyorke:rory/iosys-repr intoe8db508 on python-control:master.

@murrayrm
Copy link
Member

I agree that a change would be useful here. More generally, it would be nice to think through what we want to have displayed in various situations:

  • __repr__: this is the default display for objects in iPython/Jupyter and is supposed to be something that could, in principle, be used to recreate the object. ForStateSpace systems, for example, this currently gives
StateSpace(array([[ 0.,  1.],       [-1., -2.]]), array([[0.],       [1.]]), array([[1., 0.]]), array([[0.]]))
  • __str__: this is what you get when you typeprint(sys) and it gives a more verbose output. The current output for a state space systems is:
A = [[ 0.  1.]     [-1. -2.]]B = [[0.]     [1.]]C = [[1. 0.]]D = [[0.]]
  • After PRI/O system enhancements #710 gets merged, creating a system withss will produce aLinearIOSystem, which has a different__str___ representation:
Object: sys[0]Inputs (1): u[0], Outputs (1): y[0], States (2): x[0], x[1], A = [[ 0.  1.]     [-1. -2.]]B = [[0.]     [1.]]C = [[1. 0.]]D = [[0.]]
  • We also have a_repr_latex_ method, which gets used in Jupyter notebooks. This produces the following output:

Screen Shot 2022-03-18 at 1 11 05 PM

Finally, PR#710 has a conflicting change since I reset therepr format there to include the type and system name. So anInputOutputSystem object has output:

<class 'control.iosys.LinearIOSystem'>: sys[0]

I like the version in this draft PR better, but note that if you get something with lots of inputs and outputs, it could be a bit odd looking.

@murrayrmmurrayrm added this to the0.9.2 milestoneMar 19, 2022
@murrayrm
Copy link
Member

PR#721 has a portion of this (__repr__) implemented, but leaves the other issues touched on above unchanged. It would be nice to sort out a consistent set of representations that make sense in different environments (eg, Jupyter vs command line).

@murrayrmmurrayrm removed this from the0.9.2 milestoneApr 9, 2022
@henklaak
Copy link
Contributor

henklaak commentedFeb 20, 2023
edited
Loading

FYI, Spyder (a nifty little IDE) also uses the_repr_latex_() output
It sure is handy to get your SS in a compact matrix in such editors.

image

@murrayrm
Copy link
Member

This has been implemented since v0.10.0.

@murrayrmmurrayrm added this to the0.10.2 milestoneFeb 19, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.10.2
Development

Successfully merging this pull request may close these issues.

4 participants
@roryyorke@coveralls@murrayrm@henklaak

[8]ページ先頭

©2009-2025 Movatter.jp