Title: Cleanup TransferFunction Input Sanitization by dapperfu · Pull Request #135 · python-control/python-control · GitHub
Open Graph Title: Cleanup TransferFunction Input Sanitization by dapperfu · Pull Request #135 · python-control/python-control
X Title: Cleanup TransferFunction Input Sanitization by dapperfu · Pull Request #135 · python-control/python-control
Description: This started out to address #112 & #130, but I found a few other small edge cases.
To simplify unit testing I broke the input cleaning out to a separate function and added as many test cases as I could think of.
Deep copy
It performs a deep copy on args before anything else.
Test Code:
num = [[[1], [2]]]
den = [[[1,1], [2,1]]]
print(num)
print(den)
control.TransferFunction(num, den)
print(num)
print(den)
Before:
[[[1], [2]]]
[[[1, 1], [2, 1]]]
[[array([1]), array([2])]]
[[array([1, 1]), array([2, 1])]]
After:
[[[1], [2]]]
[[[1, 1], [2, 1]]]
[[[1], [2]]]
[[[1, 1], [2, 1]]]
Validate All Input Types:
The previous input validation would only check the first element if it was a valid input type. This means you could feed in extra bad values in other positions and it would accept it, only to fail later.
Test Code:
num = [[[1,"a"]]]
den = [[[2,1]]]
print(num)
print(den)
sys = control.TransferFunction(num, den)
print(num)
print(den)
Before:
It would accept the values (and mutate the inputs):
[[[1, 'a']]]
[[[2, 1]]]
[[array(['1', 'a'],
dtype='
Open Graph Description: This started out to address #112 & #130, but I found a few other small edge cases. To simplify unit testing I broke the input cleaning out to a separate function and added as many test cases as...
X Description: This started out to address #112 & #130, but I found a few other small edge cases. To simplify unit testing I broke the input cleaning out to a separate function and added as many test case...
Opengraph URL: https://github.com/python-control/python-control/pull/135
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:048a56f5-3dc6-1fc0-7cef-d7fb09e9657a |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C826:2B554C:1C087C5:2745EE0:697BA6A5 |
| html-safe-nonce | 80e053e85776db7810ae0961bad81d492d962269fb290974fa14ee5f34f4e1ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODI2OjJCNTU0QzoxQzA4N0M1OjI3NDVFRTA6Njk3QkE2QTUiLCJ2aXNpdG9yX2lkIjoiMjkwMTI3NzAxNzU0MDEwOTk5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a76219b4187bfafec16062c87be5a9dc09fbddde0020f5381c9cdba07b6cd796 |
| hovercard-subject-tag | pull_request:106872793 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/135/checks |
| twitter:image | https://avatars.githubusercontent.com/u/223258?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/223258?s=400&v=4 |
| og:image:alt | This started out to address #112 & #130, but I found a few other small edge cases. To simplify unit testing I broke the input cleaning out to a separate function and added as many test cases as... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7ba9ae7380317898f1b98f4cf41e78605ff2d68007cb4db4e46bdaf7e9423d2e |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d52dd9b71f0e5da9cfd694fb2faae78a81d8e46f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width