Title: labels are not checked during __setitem__ · Issue #269 · larray-project/larray · GitHub
Open Graph Title: labels are not checked during __setitem__ · Issue #269 · larray-project/larray
X Title: labels are not checked during __setitem__ · Issue #269 · larray-project/larray
Description: >>> arr = ndtest(3) >>> arr a | a0 | a1 | a2 | 0 | 1 | 2 >>> arr2 = arr['a1:'].set_labels(x.a, 'b1,b2') >>> arr2 a | b1 | b2 | 1 | 2 # works when it should fail >>> arr['a1':] = arr2 It was done on purpose to allow for: arr[['a0', 'a1']]...
Open Graph Description: >>> arr = ndtest(3) >>> arr a | a0 | a1 | a2 | 0 | 1 | 2 >>> arr2 = arr['a1:'].set_labels(x.a, 'b1,b2') >>> arr2 a | b1 | b2 | 1 | 2 # works when it should fail >>> arr['a1':] = arr2 It was done on...
X Description: >>> arr = ndtest(3) >>> arr a | a0 | a1 | a2 | 0 | 1 | 2 >>> arr2 = arr['a1:'].set_labels(x.a, 'b1,b2') >>> arr2 a | b1 | b2 | 1 | 2 # works when...
Opengraph URL: https://github.com/larray-project/larray/issues/269
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"labels are not checked during __setitem__","articleBody":"```python\r\n>>> arr = ndtest(3)\r\n>>> arr\r\na | a0 | a1 | a2\r\n | 0 | 1 | 2\r\n>>> arr2 = arr['a1:'].set_labels(x.a, 'b1,b2')\r\n>>> arr2\r\na | b1 | b2\r\n | 1 | 2\r\n# works when it should fail\r\n>>> arr['a1':] = arr2\r\n```\r\nIt was done on purpose to allow for:\r\n```python\r\narr[['a0', 'a1']] = arr[['a1', 'a0']]\r\n```\r\nIt would be a bit cumbersome to require a set_labels or drop_labels in this case, but it is probably worth it anyway because this is probably a rare operation and not checking can let errors pass silently which defeats the purpose of having labels in the first place.\r\n\r\n```python\r\narr[['a0', 'a1']] = arr[['a1', 'a0']].drop_labels(x.a)\r\narr[['a0', 'a1']] = arr[['a1', 'a0']].set_labels(x.a, ['a0', 'a1'])\r\n# assuming we have automatic align, we could express this with:\r\narr[:] = arr.set_labels(x.a, {'a0': 'a1', 'a1': 'a0'})\r\n# or (if axis a contains more labels than just a0 and a1)\r\narr[['a0', 'a1']] = arr.set_labels(x.a, {'a0': 'a1', 'a1': 'a0'})\r\n```\r\nIf one has only two values to swap, like above, one could write that as:\r\n```python\r\na1 = arr['a1'].copy()\r\narr['a1'] = arr['a0']\r\narr['a0'] = a1\r\n```","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2017-05-22T10:20:07Z","url":"https://github.com/larray-project/larray/issues/269"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:a8721c57-e26e-70f5-f92d-4a129c231394 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0B0:D064:21A158C:2DA2B5F:6B0021AD |
| html-safe-nonce | fc28a74b1cf448e2dad3498fa911730da58d2b0a7521ecaee4fa300d3688eebc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEIwOkQwNjQ6MjFBMTU4QzoyREEyQjVGOjZCMDAyMUFEIiwidmlzaXRvcl9pZCI6Ijc5ODg2ODUxNjcxNTk5NDM1OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0ca44c198c90a624390d8d76177b87293bb130aecfc91725fa4e5ed87598059d |
| hovercard-subject-tag | issue:230349614 |
| 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/larray-project/larray/269/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4cd82e68e49fb0b277e53a3a563107e9b803f22d41752689a0eea3d58b2d5ce2/larray-project/larray/issues/269 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4cd82e68e49fb0b277e53a3a563107e9b803f22d41752689a0eea3d58b2d5ce2/larray-project/larray/issues/269 |
| og:image:alt | >>> arr = ndtest(3) >>> arr a | a0 | a1 | a2 | 0 | 1 | 2 >>> arr2 = arr['a1:'].set_labels(x.a, 'b1,b2') >>> arr2 a | b1 | b2 | 1 | 2 # works when it should fail >>> arr['a1':] = arr2 It was done on... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gdementen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/larray-project/larray git https://github.com/larray-project/larray.git |
| octolytics-dimension-user_id | 26460981 |
| octolytics-dimension-user_login | larray-project |
| octolytics-dimension-repository_id | 16981067 |
| octolytics-dimension-repository_nwo | larray-project/larray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16981067 |
| octolytics-dimension-repository_network_root_nwo | larray-project/larray |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width