home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1903416932

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1903416932 I_kwDOAMm_X85xc9Zk 8210 Inconsistent Type Hinting for dims Parameter in xarray Methods 13301940 open 0     7 2023-09-19T17:15:43Z 2023-09-20T15:03:45Z   MEMBER      

None is not really practical in current xarray so not allowing it as a dimension is probably the easiest path, but type hinting will not be correct.

I want dims to have a type hint that is consistent, easy to read and understand. In a dream world it would look something like this: python InputDim = Hashable # Single dimension InputDims = Iterable[InputDim , ...] # multiple dimensions InputDimOrDims = Union[InputDim, InputDims] # Single or multiple dimensions

Then we can easily go through our xarray methods and easily replace dim and dims arguments.

Hashable could be fine in NamedArray, we haven't introduced None as a typical default value there yet.

But it wouldn't be easy in xarray because we use None as default value a lot, which will (I suspect) lead to a bunch of refactoring and deprecations. I haven't tried it maybe it's doable?

Another idea is to try and make a HashableExcludingNone: python HashableExcludingNone = Union[int, str, tuple, ...] # How many more Hashables are there? InputDim = HashableExcludingNone # Single dimension InputDims = Iterable[InputDim , ...] # multiple dimensions InputDimOrDims = Union[InputDim, InputDims] # Single or multiple dimensions I suspect this is harder than it seems.

Another idea is drop the idea of Hashable and just allow a few common ones that are used: python InputDim = str # Single dimension InputDims = tuple[InputDim , ...] # multiple dimensions InputDimOrDims = Union[InputDim, InputDims] # Single or multiple dimensions Very clear! I think a few users (and maintainers) will be sad because of the lack of flexibility though.

No easy paths, and trying to be backwards compatible is very demotivating.

Originally posted by @Illviljan in https://github.com/pydata/xarray/pull/8075#discussion_r1330437962

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8210/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.569ms · About: xarray-datasette