René's URL Explorer Experiment


Title: Change to code for ctrb and obsv by billtubbs · Pull Request #300 · python-control/python-control · GitHub

Open Graph Title: Change to code for ctrb and obsv by billtubbs · Pull Request #300 · python-control/python-control

X Title: Change to code for ctrb and obsv by billtubbs · Pull Request #300 · python-control/python-control

Description: This is not a bug fix. It's a minor speed improvement to statefbk.ctrb and statefbk.obsv. [It's the first time I have contributed to someone else's project so welcome feedback and advice if I'm not doing this correctly] Summary I noticed that you can avoid multiple hstack operations by creating a list first. I've done some testing and I think the behaviour of these methods is unchanged. See my test outputs below. I realise this is a very minor improvement so feel free to ignore. 1. Testing ctrb() Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 15:43:19) Type 'copyright', 'credits' or 'license' for more information IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: import numpy as np In [2]: import control In [3]: np.random.seed(1) In [4]: cum = 0 In [5]: for i in range(10): ...: A = np.random.randn(i, i) ...: B = np.random.randn(i, 1) ...: cum += control.ctrb(A, B).sum() ...: In [6]: cum Out[6]: -10066.24518631401 In [7]: control.__file__ Out[7]: '/Users/billtubbs/python-control/python-control/control/__init__.py' Results with official control package for comparison Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 02:16:08) Type 'copyright', 'credits' or 'license' for more information IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: import numpy as np In [2]: import control In [3]: np.random.seed(1) In [4]: cum = 0. In [5]: for i in range(10): ...: A = np.random.randn(i, i) ...: B = np.random.randn(i, 1) ...: cum += control.ctrb(A, B).sum() ...: In [6]: cum Out[6]: -10066.245186314005 In [7]: control.__file__ Out[7]: '/Users/billtubbs/anaconda3/envs/torch/lib/python3.6/site-packages/control/__init__.py' 2. Testing obsv() In [1]: import numpy as np In [2]: import control In [3]: control.__file__ Out[3]: '/Users/billtubbs/python-control/python-control/control/__init__.py' In [4]: np.random.seed(1) In [5]: cum = 0. In [6]: for i in range(10): ...: A = np.random.randn(i, i) ...: C = np.random.randn(1, i) ...: cum += control.obsv(A, C).sum() ...: In [7]: cum Out[7]: -7589.3515984634905 Results with official control package for comparison In [12]: np.random.seed(1) In [13]: cum = 0. In [14]: for i in range(10): ...: A = np.random.randn(i, i) ...: C = np.random.randn(1, i) ...: cum += control.obsv(A, C).sum() ...: In [15]: cum Out[15]: -7589.351598463492 In [16]: control.__file__ Out[16]: '/Users/billtubbs/anaconda3/envs/torch/lib/python3.6/site-packages/control/__init__.py' 3. Speed Tests (In Python 3.7 on a 2013 MacBook Pro) In [8]: def ctrb1(A, B): ...: amat = np.mat(A) ...: bmat = np.mat(B) ...: n = np.shape(amat)[0] ...: ctrb = bmat ...: for i in range(1, n): ...: ctrb = np.hstack((ctrb, amat**i*bmat)) ...: return ctrb ...: In [9]: def ctrb2(A, B): ...: amat = np.mat(A) ...: bmat = np.mat(B) ...: n = np.shape(amat)[0] ...: ctrb = np.hstack([bmat] + [amat**i*bmat for i in range(1, n)]) ...: return ctrb ...: In [11]: np.random.seed(1) In [12]: A = np.random.randn(8, 8) In [13]: B = np.random.randn(8, 1) In [14]: %timeit ctrb1(A, B) 456 µs ± 18 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) In [15]: %timeit ctrb2(A, B) 378 µs ± 13.2 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) In [16]: 1-378/456 Out[16]: 0.17105263157894735

Open Graph Description: This is not a bug fix. It's a minor speed improvement to statefbk.ctrb and statefbk.obsv. [It's the first time I have contributed to someone else's project so welcome feedback and advi...

X Description: This is not a bug fix. It's a minor speed improvement to statefbk.ctrb and statefbk.obsv. [It's the first time I have contributed to someone else's project so welcome feedb...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:f7230427-6e5d-8c43-b719-3b511ce365ff
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC966:2EB10D:51C2A5:6E10BD:697BE982
html-safe-nonce1a47a77263945739012bfe110a42622d39a31e6c63b19c5e58a2c0f77e4c3bf6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTY2OjJFQjEwRDo1MUMyQTU6NkUxMEJEOjY5N0JFOTgyIiwidmlzaXRvcl9pZCI6IjM2MzUzMjM2NTQ2OTE4NzUyMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbd3d66e629108462656fb9170e3c6a380796c279c90bb49ef39798f291620f69
hovercard-subject-tagpull_request:280131488
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/300/files
twitter:imagehttps://avatars.githubusercontent.com/u/7958850?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/7958850?s=400&v=4
og:image:altThis is not a bug fix. It's a minor speed improvement to statefbk.ctrb and statefbk.obsv. [It's the first time I have contributed to someone else's project so welcome feedback and advi...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None11e496cbe5d2a0371113a9b3a27479478e7142b71385ee8295d2fc71e856f899
turbo-cache-controlno-preview
diff-viewunified
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
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0e8a25656ebf36ff0bc778937941513a5c7c58ee
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-control/python-control/pull/300/changes#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F300%2Ffiles
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%2F300%2Ffiles
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%2Ffiles&source=header-repo&source_repo=python-control%2Fpython-control
Reloadhttps://github.com/python-control/python-control/pull/300/changes
Reloadhttps://github.com/python-control/python-control/pull/300/changes
Reloadhttps://github.com/python-control/python-control/pull/300/changes
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:masterhttps://github.com/python-control/python-control/tree/master
Conversation 12 https://github.com/python-control/python-control/pull/300
Commits 2 https://github.com/python-control/python-control/pull/300/commits
Checks 0 https://github.com/python-control/python-control/pull/300/checks
Files changed https://github.com/python-control/python-control/pull/300/files
Please reload this pagehttps://github.com/python-control/python-control/pull/300/changes
Change to code for ctrb and obsv https://github.com/python-control/python-control/pull/300/changes#top
Show all changes 2 commits https://github.com/python-control/python-control/pull/300/files
083ed75 Change to code for ctrb and obsv billtubbs May 18, 2019 https://github.com/python-control/python-control/pull/300/commits/083ed75378a3823e4693e47efefe99d9125ed6dc
9309259 Bug fix to osbv billtubbs May 18, 2019 https://github.com/python-control/python-control/pull/300/commits/9309259f4824f2126629b168521b41c1afa84915
Clear filters https://github.com/python-control/python-control/pull/300/files
Please reload this pagehttps://github.com/python-control/python-control/pull/300/changes
Please reload this pagehttps://github.com/python-control/python-control/pull/300/changes
control/statefbk.pyhttps://github.com/python-control/python-control/pull/300/changes#diff-dbb4a524ae36f7833fa7b5991007098ea0b11b1f8a5d30831c641f5e6d39e0cb
View file https://github.com/python-control/python-control/blob/9309259f4824f2126629b168521b41c1afa84915/control/statefbk.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-control/python-control/pull/300/{{ revealButtonHref }}
https://github.com/python-control/python-control/pull/300/changes#diff-dbb4a524ae36f7833fa7b5991007098ea0b11b1f8a5d30831c641f5e6d39e0cb
https://github.com/python-control/python-control/pull/300/changes#diff-dbb4a524ae36f7833fa7b5991007098ea0b11b1f8a5d30831c641f5e6d39e0cb
https://github.com/python-control/python-control/pull/300/changes#diff-dbb4a524ae36f7833fa7b5991007098ea0b11b1f8a5d30831c641f5e6d39e0cb
https://github.com/python-control/python-control/pull/300/changes#diff-dbb4a524ae36f7833fa7b5991007098ea0b11b1f8a5d30831c641f5e6d39e0cb
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.