issues: 1221885425
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1221885425 | I_kwDOAMm_X85I1H3x | 6549 | Improved Dataset broadcasting | 43316012 | open | 0 | 3 | 2022-04-30T17:51:37Z | 2022-05-01T14:37:43Z | COLLABORATOR | Is your feature request related to a problem?I am a bit puzzled about how xarrays is broadcasting Datasets. It seems to always add all dimensions to all variables. Is this what you want in general? See this example: ```python import xarray as xr da = xr.DataArray([[1, 2, 3]], dims=("x", "y")) <xarray.DataArray (x: 1, y: 3)>array([[1, 2, 3]])ds = xr.Dataset({"a": ("x", [1]), "b": ("z", [2, 3])}) <xarray.Dataset>Dimensions: (x: 1, z: 2)Dimensions without coordinates: x, zData variables:a (x) int32 1b (z) int32 2 3ds.broadcast_like(da) returns:<xarray.Dataset>Dimensions: (x: 1, y: 3, z: 2)Dimensions without coordinates: x, y, zData variables:a (x, y, z) int32 1 1 1 1 1 1b (x, y, z) int32 2 3 2 3 2 3I think it should return:<xarray.Dataset>Dimensions: (x: 1, y: 3, z: 2)Dimensions without coordinates: x, y, zData variables:a (x, y) int32 1 1 1 # notice here without "z" dimb (x, y, z) int32 2 3 2 3 2 3``` Describe the solution you'd likeI would like broadcasting to behave the same way as e.g. a simple addition.
In the upper example Describe alternatives you've considered
Additional contextMaybe one can add an option to broadcasting that controls this behavior? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6549/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |