René's URL Explorer Experiment


Title: Update I/O system repr() and str() by murrayrm · Pull Request #1091 · python-control/python-control · GitHub

Open Graph Title: Update I/O system repr() and str() by murrayrm · Pull Request #1091 · python-control/python-control

X Title: Update I/O system repr() and str() by murrayrm · Pull Request #1091 · python-control/python-control

Description: This PR provides updates to the string representations of I/O systems, including both the __repr__ and __str__ functions (used for repr(), str(), and print()) as well as LaTeX output (via _repr_html_): Created a set of standard _repr_* formats for InputOutputSystem's that can be overridden in subclasses to get the most useful representations based on the system type, using method names similar to _repr_latex_ used by Jupyter notebooks: _repr_info_: generates a minimal description of the I/O system in the form [output list][, dt=timebase]>. This is the default format that exists for all I/O systems. The inclusion of the timebase is new. _repr_eval_: generates an "evaluatable" description of the I/O system, if possible (otherwise return _repr_info_()). This is used in LTI systems to show the state space matrices, numerator/denominator, or freuquency response data. This format is similar to what was done before this PR for LTI classes, but now includes the signal names (if non-generic) or the signal counts (if generic). The inclusion of the string names make sure that you can recreate the system with the proper labels. The inclusion of the string counts lets you see the number of inputs and outputs. _repr_html_: generates an HTML/LaTeX description of the I/O system, if possible (otherwise return _repr_info_()). This method is picked up by Jupyter notebooks to display the value of a variable and replaces _repr_latex_ used in prior versions. This is similar to what was present before, except that now there is a "header" that shows the system name and signal names before showing a LaTeX representation of the state space matrices and/or transfer functions (this required changing _repr_latex_ to _repr_html_). Note that since the timebase information is included in the header, it is no longer included in the LaTeX formatted code. Created a new function iosys_repr (similar to np.array_repr) that allows different representations of I/O systems via a format parameter ('info', 'eval', or 'latex'). The transfer function display_format parameter is now handled in a dynamic fashion. If it is set to None (default) on system creation, the display style will follow config.defaults['xferfcn.display_format']. If set to poly or zpk on system creation, that overrides the default. Updated the str() (print) representation of InputOutputSystems to include dt after the state/input/output names (suppressed if it matches the default dt). Updated the str() (print) representation for NonlinearIOSystems to include list of parameter labels. Updated the str() (print) representation for InterconnectedSystems to include the list of subsystems (in 'info' form) as well summaries of the connections and outputs matrix (might be an eventual replacement for connection_table). All representations now apply np.printoptions to system arrays before generating strings, so you get consistent formatting across representations (including latex) and you can use things like suppress to display near-zero numbers as '0'. Fixed up various line spacings in str() (print) to make things consistent across the various I/O system classes, including adding some indentation for transfer functions and MIMO systems (see screen shots below). Added examples/repr_gallery.ipynb and exampes/repr_gallery.py files to show all of the various output formats and options (with dashed lines at the start and end so you can see any extraneous blank lines). Added config.defaults options 'iosys.repr_format' and 'iosys.repr_show_count' to control representation formats. The combine_tf function now accepts system and signal name keywords. (This is not strictly related to the main subject of this PR, but I needed since I had to set the name of the system in order for doctests to work.) Added the ability of config.defaults to be called as a context manager, so that you can temporarily change default parameters (this is used in examples/repr_gallery.py). (This is more general than this PR, but I used it extensively in repr_gallery). Updated docstrings and unit tests. A detailed set of before and after views are attached as PDFs, generated by the new examples/repr_gallery.ipynb and exampes/repr_gallery.py files: Before: repr_gallery-10.1-29Dec2024.pdf After: repr_gallery-10.1-04Jan2025.pdf Some highlights (pulled from repr_gallery): State space system, repr(), 'eval' format: StateSpace: sys_ss, dt=0: ------------------------- StateSpace( array([[ 0., 1.], [-4., -5.]]), array([[0.], [1.]]), array([[-1., 1.]]), array([[0.]]), name='sys_ss', states=2, outputs=1, inputs=1) ---- Discrete time, state space system, repr(), 'eval' format: StateSpace: sys_dss, dt=0.1: ---------------------------- StateSpace( array([[ 0.98300988, 0.07817246], [-0.31268983, 0.59214759]]), array([[0.00424753], [0.07817246]]), array([[-1., 1.]]), array([[0.]]), dt=0.1, name='sys_dss', states=2, outputs=1, inputs=1) ---- MIMO transfer function, repr(), 'eval' format: TransferFunction: sys_mtf_zpk, dt=0: ------------------------------------ TransferFunction( [[array([ 1., -1.]), array([0.])], [array([1, 0]), array([1, 0])]], [[array([1., 5., 4.]), array([1.])], [array([1]), array([1, 2, 1])]], name='sys_mtf_zpk', outputs=2, inputs=2) ---- Discrete time, state space system, repr(), ,'info' format: TransferFunction: sys_dss_poly, dt=0.1: --------------------------------------- ['y[0]'], dt=0.1> ---- Discrete time, state space systems, str(): : sys_dss Inputs (1): ['u[0]'] Outputs (1): ['y[0]'] States (2): ['x[0]', 'x[1]'] dt = 0.1 A = [[ 0.98300988 0.07817246] [-0.31268983 0.59214759]] B = [[0.00424753] [0.07817246]] C = [[-1. 1.]] D = [[0.]] ---- Nonlinear I/O system, str(): NonlinearIOSystem: sys_nl, dt=0: -------------------------------- : sys_nl Inputs (1): ['u[0]'] Outputs (1): ['y[0]'] States (2): ['x[0]', 'x[1]'] Parameters: ['a', 'b'] Update: Output: Linear interconnected system, str(): LinearICSystem: sys_ic, dt=0: ----------------------------- : sys_ic Inputs (2): ['r[0]', 'r[1]'] Outputs (2): ['y[0]', 'y[1]'] States (2): ['proc_x[0]', 'proc_x[1]'] Subsystems (2): * ['y[0]', 'y[1]']> * ['y[0]', 'y[1]'], dt=None> Connections: * proc.u[0] <- ctrl.y[0] * proc.u[1] <- ctrl.y[1] * ctrl.u[0] <- -proc.y[0] + r[0] * ctrl.u[1] <- -proc.y[1] + r[1] Outputs: * y[0] <- proc.y[0] * y[1] <- proc.y[1] A = [[-2. 3.] [-1. -5.]] B = [[-2. 0.] [ 0. -3.]] C = [[-1. 1.] [ 1. 0.]] D = [[0. 0.] [0. 0.]] ----

Open Graph Description: This PR provides updates to the string representations of I/O systems, including both the __repr__ and __str__ functions (used for repr(), str(), and print()) as well as LaTeX output (via _repr_htm...

X Description: This PR provides updates to the string representations of I/O systems, including both the __repr__ and __str__ functions (used for repr(), str(), and print()) as well as LaTeX output (via _repr_htm...

Opengraph URL: https://github.com/python-control/python-control/pull/1091

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:5e76b0ae-7e5c-8735-ff96-89ffeae62faa
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idA088:1C9C23:C960F0:11A2993:697B562F
html-safe-nonced8280319f69038bb16b0315f26c185e71bb67253655e34a904d9172d06e22872
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDg4OjFDOUMyMzpDOTYwRjA6MTFBMjk5Mzo2OTdCNTYyRiIsInZpc2l0b3JfaWQiOiIyMzY1OTQxMTk1NTcxMTU2NTI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac0918cb65d3dce42682fc9aff15fcdfacec52511fbca90367fd56fad384d1f571
hovercard-subject-tagpull_request:2260532387
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/1091/checks
twitter:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
og:image:altThis PR provides updates to the string representations of I/O systems, including both the __repr__ and __str__ functions (used for repr(), str(), and print()) as well as LaTeX output (via _repr_htm...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7eed3e20c41f6c464df945b1f353a52c450ca1653f4697d4ebcc58c2adc5868a
turbo-cache-controlno-cache
go-importgithub.com/python-control/python-control git https://github.com/python-control/python-control.git
octolytics-dimension-user_id2285872
octolytics-dimension-user_loginpython-control
octolytics-dimension-repository_id22791752
octolytics-dimension-repository_nwopython-control/python-control
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id22791752
octolytics-dimension-repository_network_root_nwopython-control/python-control
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb059c4725f1b62cc8534bdab4092fd840e833907
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-control/python-control/pull/1091/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F1091%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F1091%2Fchecks
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=python-control%2Fpython-control
Reloadhttps://github.com/python-control/python-control/pull/1091/checks
Reloadhttps://github.com/python-control/python-control/pull/1091/checks
Reloadhttps://github.com/python-control/python-control/pull/1091/checks
python-control https://github.com/python-control
python-controlhttps://github.com/python-control/python-control
Notifications https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Fork 447 https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Star 2k https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Code https://github.com/python-control/python-control
Issues 87 https://github.com/python-control/python-control/issues
Pull requests 8 https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects 0 https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security 0 https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Code https://github.com/python-control/python-control
Issues https://github.com/python-control/python-control/issues
Pull requests https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
murrayrmhttps://github.com/murrayrm
python-control:mainhttps://github.com/python-control/python-control/tree/main
murrayrm:iosys_repr-07Dec2024https://github.com/murrayrm/python-control/tree/iosys_repr-07Dec2024
Conversation 23 https://github.com/python-control/python-control/pull/1091
Commits 21 https://github.com/python-control/python-control/pull/1091/commits
Checks 13 https://github.com/python-control/python-control/pull/1091/checks
Files changed https://github.com/python-control/python-control/pull/1091/files
Please reload this pagehttps://github.com/python-control/python-control/pull/1091/checks
Please reload this pagehttps://github.com/python-control/python-control/pull/1091/checks
Sign in for the full log viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F1091%2Fchecks
Update I/O system repr() and str() https://github.com/python-control/python-control/pull/1091/checks#top
Please reload this pagehttps://github.com/python-control/python-control/pull/1091/checks
Doctest on: pull_request https://github.com/python-control/python-control/actions/runs/12739021177
doctest-linux https://github.com/python-control/python-control/actions/runs/12739021177/job/35502301358?pr=1091
Conda-based pytest on: pull_request https://github.com/python-control/python-control/actions/runs/12739021179
Py3.10; no Slycot; no Pandas; no CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126233?pr=1091
Py3.10; no Slycot; no Pandas; conda CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126447?pr=1091
Py3.10; conda Slycot; no Pandas; no CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126570?pr=1091
Py3.10; conda Slycot; no Pandas; conda CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126689?pr=1091
Py3.12; no Slycot; no Pandas; no CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126817?pr=1091
Py3.12; no Slycot; no Pandas; conda CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502126931?pr=1091
Py3.12; conda Slycot; no Pandas; no CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502127043?pr=1091
Py3.12; conda Slycot; no Pandas; conda CVXOPT https://github.com/python-control/python-control/actions/runs/12739021179/job/35502127169?pr=1091
Py3.12; conda Slycot; conda Pandas; conda CVXOPT ; QtAgg https://github.com/python-control/python-control/actions/runs/12739021179/job/35502127318?pr=1091
Finalize parallel coveralls https://github.com/python-control/python-control/actions/runs/12739021179/job/35502452464?pr=1091
Setup, Examples, Notebooks on: pull_request https://github.com/python-control/python-control/actions/runs/12739021181
install-examples https://github.com/python-control/python-control/actions/runs/12739021181/job/35502126244?pr=1091
Slycot from source on: pull_request https://github.com/python-control/python-control/actions/runs/12739021183
build-linux https://github.com/python-control/python-control/actions/runs/12739021183/job/35502126203?pr=1091
https://github.com/python-control/python-control/actions/runs/12739021177/job/35502301358
https://github.com/actions/runner-images/issues/10636https://github.com/actions/runner-images/issues/10636
https://github.com/python-control/python-control/pull/1091/checks#annotation:3:340
https://github.com/python-control/python-control/pull/1091/checks#annotation:3:359
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.