Title: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem · Issue #957 · python-control/python-control · GitHub
Open Graph Title: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem · Issue #957 · python-control/python-control
X Title: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem · Issue #957 · python-control/python-control
Description: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem: import control as ct class System: @classmethod def _outputs(cls, t, x, u, params: dict): v = u[0] i = u[1] k = u[2] return k*v**2 + i @classmethod def bui...
Open Graph Description: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem: import control as ct class System: @classmethod def _outputs(cls, t, x, u, params: dict): v = u[0] i = u[1] k = u[2...
X Description: TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem: import control as ct class System: @classmethod def _outputs(cls, t, x, u, params: dict): v = u[0] i = u[1] k = u[2...
Opengraph URL: https://github.com/python-control/python-control/issues/957
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem","articleBody":"TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem:\r\n\r\n```python\r\n\r\nimport control as ct\r\n\r\nclass System:\r\n @classmethod\r\n def _outputs(cls, t, x, u, params: dict):\r\n v = u[0]\r\n i = u[1]\r\n k = u[2]\r\n\r\n return k*v**2 + i\r\n\r\n @classmethod\r\n def build(cls):\r\n return ct.NonlinearIOSystem(\r\n None,\r\n cls._outputs,\r\n name=\"system\",\r\n states=None,\r\n inputs=('v', 'i', 'V'),\r\n outputs=('I',),\r\n params=params,\r\n )\r\n\r\nT = np.arange(100) # simulation time in seconds\r\nU = np.ones(shape=(3, len(T)))\r\n\r\nsys = System.build()\r\nydata = ct.input_output_response(sys, T=T, U=U, solve_ivp_method=\"Radau\").to_pandas()\r\n\r\n---------------------------------------------------------------------------\r\nTypeError Traceback (most recent call last)\r\nCell In[106], [line 28](vscode-notebook-cell:?execution_count=106\u0026line=28)\r\n [25](vscode-notebook-cell:?execution_count=106\u0026line=25) U = np.ones(shape=(3, len(T)))\r\n [27](vscode-notebook-cell:?execution_count=106\u0026line=27) sys = System.build()\r\n---\u003e [28](vscode-notebook-cell:?execution_count=106\u0026line=28) ydata = ct.input_output_response(sys, T=T, U=U, solve_ivp_method=\"Radau\").to_pandas()\r\n [29](vscode-notebook-cell:?execution_count=106\u0026line=29) ydata\r\n\r\nFile [~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:655](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:655), in TimeResponseData.to_pandas(self)\r\n [650](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:650) data.update(\r\n [651](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:651) {name: self.u[i] for i, name in enumerate(self.input_labels)})\r\n [652](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:652) data.update(\r\n [653](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:653) {name: self.y[i] for i, name in enumerate(self.output_labels)})\r\n [654](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:654) data.update(\r\n--\u003e [655](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:655) {name: self.x[i] for i, name in enumerate(self.state_labels)})\r\n [657](https://file+.vscode-resource.vscode-cdn.net/home/joaoantoniocardoso/workspace_TCC/repo_2022_2/models/2020/panel/~/workspace_TCC/repo_2022_2/.env/lib/python3.10/site-packages/control/timeresp.py:657) return pandas.DataFrame(data)\r\n\r\nTypeError: 'NoneType' object is not iterable\r\n```\r\n\r\nNot optimal, but as a workaround, I'm introducing a state:\r\n\r\n```python\r\nclass System:\r\n @classmethod\r\n def _updates(cls, t, x, u, params: dict):\r\n return 0\r\n\r\n @classmethod\r\n def _outputs(cls, t, x, u, params: dict):\r\n v = u[0]\r\n i = u[1]\r\n k = u[2]\r\n\r\n return k*v**2 + i\r\n\r\n @classmethod\r\n def build(cls):\r\n return ct.NonlinearIOSystem(\r\n cls._updates,\r\n cls._outputs,\r\n name=\"system\",\r\n states=1,\r\n inputs=('v', 'i', 'V'),\r\n outputs=('I',),\r\n params=params,\r\n )\r\n```","author":{"url":"https://github.com/joaoantoniocardoso","@type":"Person","name":"joaoantoniocardoso"},"datePublished":"2024-01-03T18:02:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/957/python-control/issues/957"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:df15431a-f9f9-cc8e-8b20-224791b7e74b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B732:AB0E6:6BEF89:97A927:697A6A72 |
| html-safe-nonce | 8c07d9b7904979da42472b54783396fa033f63dbd6a6610ecf3dd0181739915a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzMyOkFCMEU2OjZCRUY4OTo5N0E5Mjc6Njk3QTZBNzIiLCJ2aXNpdG9yX2lkIjoiMTMxODg3NTg2NDQxODExODI1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6fb46d5222200abdc616b3e3d0b7067e16cb1b79828856e866223e23d21d76ac |
| hovercard-subject-tag | issue:2064441121 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python-control/python-control/957/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fb59aa1a4ded2228c80b68ccf39821acb052e9105488b07279287832452b7a1b/python-control/python-control/issues/957 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fb59aa1a4ded2228c80b68ccf39821acb052e9105488b07279287832452b7a1b/python-control/python-control/issues/957 |
| og:image:alt | TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem: import control as ct class System: @classmethod def _outputs(cls, t, x, u, params: dict): v = u[0] i = u[1] k = u[2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joaoantoniocardoso |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4f4c032790588250388c2e36a0e1ea776c0a3f887d37d994e1ac3d7ea79d34ef |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06b3a5a9a6214e1e06e508d250d778cbaf17c577 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width