home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 706639713

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/4501#issuecomment-706639713 https://api.github.com/repos/pydata/xarray/issues/4501 706639713 MDEyOklzc3VlQ29tbWVudDcwNjYzOTcxMw== 1217238 2020-10-11T02:26:42Z 2020-10-11T02:26:42Z MEMBER

Hi @chrisroat, thanks for the clear bug report!

It indeed be nice if squeeze followed by expand_dims preserved the original inputs, but I don't think that is possible in general -- the squeeze operation removes information.

For example, this array does currently satisfy your desired property, but wouldn't if we made the change you request: python arr1 = xr.DataArray(np.zeros((1,5)), dims=['y', 'x'], coords={'e': 10}) arr2 = arr1.squeeze('y').expand_dims('y') xr.testing.assert_identical(arr1, arr2) # passes

I suspect our best option for achieving this behavior would be to add another optional argument to expand_dims, e.g., perhaps - expand_dims(..., expand_coords=False): don't expand coordinates (default behavior) - expand_dims(..., expand_coords=True): expand all coordinates - expand_dims(..., expand_coords=['e']): only expand the coordinate 'e'

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  718716799
Powered by Datasette · Queries took 0.632ms · About: xarray-datasette