Title: Document that scalar Groups are considered to be abc.Collection but are not · Issue #1174 · larray-project/larray · GitHub
Open Graph Title: Document that scalar Groups are considered to be abc.Collection but are not · Issue #1174 · larray-project/larray
X Title: Document that scalar Groups are considered to be abc.Collection but are not · Issue #1174 · larray-project/larray
Description: Collections (https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) are defined by anything which has __len__, __iter__ and __contains__. This is the case for Group, including scalar ones. >>> import co...
Open Graph Description: Collections (https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) are defined by anything which has __len__, __iter__ and __contains__. This is the case for Gro...
X Description: Collections (https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) are defined by anything which has __len__, __iter__ and __contains__. This is the case for Gro...
Opengraph URL: https://github.com/larray-project/larray/issues/1174
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document that scalar Groups are considered to be abc.Collection but are not","articleBody":"Collections (https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) are defined by anything which has `__len__`, `__iter__` and `__contains__`. This is the case for Group, including scalar ones.\n\n```python\n>>> import collections.abc\n>>> g = la.LGroup(1)\n>>> isinstance(g, collections.abc.Collection)\nTrue\n>>> len(g)\nTypeError: len() of unsized object (1)\n>>> iter(g)\nTypeError: 'int' object is not iterable\n>>> 'a' in g\nTypeError: argument of type 'int' is not iterable\n```\n\nNote that the same problem is present in Numpy for scalar arrays:\n\n```python\nsc = np.array(1)\n>>> len(sc)\nTypeError: len() of unsized object\n>>> iter(sc)\nTypeError: iteration over a 0-d array\n>>> isinstance(sc, collections.abc.Collection)\nTrue\n```\n\nI do not think this problem is properly fixable. We could probably only define the methods depending on the instance (inside getattr) but this feels wrong and the fact that NumPy does not do it like that is probably an hint that we shouldn't do it either. However, we should at least have some comment in the code explaining why and the consequences thereof.","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2026-03-19T15:42:08Z","url":"https://github.com/larray-project/larray/issues/1174"}
| 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:0efa70d3-3f90-d24d-5a46-607a4d29cbc4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 823E:1AD4B2:5CD0:7BFE:6B0016D8 |
| html-safe-nonce | cd06998005d0f6b1ee388513b5d42b7a526e7122af7216aada72221509a9d3c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjNFOjFBRDRCMjo1Q0QwOjdCRkU6NkIwMDE2RDgiLCJ2aXNpdG9yX2lkIjoiNTExNzYzNjU2MDcxNTUxOTcwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1b12c32023e645c00d962f75d4b761ed3873c80f9cf89c3d00d07c452fb8f454 |
| hovercard-subject-tag | issue:4102553758 |
| 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/1174/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55334db412c37a2b5e57a937884a4e1c6e4b102ca7c08a181442b9a976bdfd3f/larray-project/larray/issues/1174 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55334db412c37a2b5e57a937884a4e1c6e4b102ca7c08a181442b9a976bdfd3f/larray-project/larray/issues/1174 |
| og:image:alt | Collections (https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) are defined by anything which has __len__, __iter__ and __contains__. This is the case for Gro... |
| 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 | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width