Title: String syntax does not work for single integer groups · Issue #1080 · larray-project/larray · GitHub
Open Graph Title: String syntax does not work for single integer groups · Issue #1080 · larray-project/larray
X Title: String syntax does not work for single integer groups · Issue #1080 · larray-project/larray
Description: For text labels, it works nicely: >>> arr = ndtest(3) >>> arr a a0 a1 a2 0 1 2 >>> arr.sum('a1;a0,a2') a a1 a0,a2 1 2 When the labels are integers, though, the string syntax falls short: >>> arr = ndtest("a=0,1,2") >>> arr a 0 1 2 0 1 2 ...
Open Graph Description: For text labels, it works nicely: >>> arr = ndtest(3) >>> arr a a0 a1 a2 0 1 2 >>> arr.sum('a1;a0,a2') a a1 a0,a2 1 2 When the labels are integers, though, the string syntax falls short: >>> arr = ...
X Description: For text labels, it works nicely: >>> arr = ndtest(3) >>> arr a a0 a1 a2 0 1 2 >>> arr.sum('a1;a0,a2') a a1 a0,a2 1 2 When the labels are integers, though, the st...
Opengraph URL: https://github.com/larray-project/larray/issues/1080
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String syntax does not work for single integer groups","articleBody":"For text labels, it works nicely:\r\n\r\n```python\r\n>>> arr = ndtest(3)\r\n>>> arr\r\na a0 a1 a2\r\n 0 1 2\r\n>>> arr.sum('a1;a0,a2')\r\na a1 a0,a2\r\n 1 2\r\n```\r\n\r\nWhen the labels are integers, though, the string syntax falls short:\r\n\r\n```python\r\n>>> arr = ndtest(\"a=0,1,2\")\r\n>>> arr\r\na 0 1 2\r\n 0 1 2\r\n>>> arr.sum('1;0,2')\r\nValueError: '1' is not a valid label for any axis:\r\n a [3]: 0 1 2\r\n```\r\n\r\nThis is almost not a bug, because it all comes down to me refusing to make the following work (because in the case of int-like labels, it would prevent targeting a single label):\r\n\r\n```python\r\n>>> arr['1']\r\nValueError: '1' is not a valid label for any axis:\r\n a [3]: 0 1 2\r\n>>> arr.sum('1')\r\nValueError: '1' is not a valid label for any axis:\r\n a [3]: 0 1 2\r\n```\r\nI am still not ready to lift this restriction (even though int-like labels are a bad idea and are not well supported by the string syntax anyway), at least until we have some way to express them (probably related to #34).\r\n\r\nHowever, I think it would be reasonable to support single elements within \"aggregation\" strings, which we are already interpreting (split on `;`). The above case does not work just because we first split on `;` ***then*** determine whether this must be interpreted.\r\n\r\nFWIW, the current workaround is either to avoid using the string syntax or use a sequence of one element instead:\r\n\r\n```python\r\n>>> arr['1,']\r\na 1\r\n 1\r\n>>> arr.sum('1,;0,2')\r\na [1], 0,2\r\n 1 2\r\n```\r\nbut this is not obvious at all.\r\n\r\nBTW: the default label is ugly in this case. I think it should be '1,' instead of '[1],', but this should be a separate issue.","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2023-09-26T07:03:02Z","url":"https://github.com/larray-project/larray/issues/1080"}
| 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:a087d2a3-d114-8eb7-1126-519303952fc3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D396:1CF166:207F157:2C251E6:6B001F9F |
| html-safe-nonce | f9e6b1634278b009e3f26d2eb83670c3a8695c0b4be45e52a3fc44cc5360e53d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzk2OjFDRjE2NjoyMDdGMTU3OjJDMjUxRTY6NkIwMDFGOUYiLCJ2aXNpdG9yX2lkIjoiNDE0Mjc2ODcxMDY4NTMwMjY4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7d26ca42e6aaeb7e58bb9b0973939657cde7f568b6b290ae0c33b83ae1765c0a |
| hovercard-subject-tag | issue:1912822609 |
| 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/1080/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db139c1bbb893d375f81ea7788132b6b0ea10dacee0334898ab7957f7f3ea77c/larray-project/larray/issues/1080 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db139c1bbb893d375f81ea7788132b6b0ea10dacee0334898ab7957f7f3ea77c/larray-project/larray/issues/1080 |
| og:image:alt | For text labels, it works nicely: >>> arr = ndtest(3) >>> arr a a0 a1 a2 0 1 2 >>> arr.sum('a1;a0,a2') a a1 a0,a2 1 2 When the labels are integers, though, the string syntax falls short: >>> arr = ... |
| 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