home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 864494256

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
864494256 MDU6SXNzdWU4NjQ0OTQyNTY= 5205 Clip function with minimum or maximum nan value 21273359 closed 1     9 2021-04-22T03:06:24Z 2021-04-22T17:34:59Z 2021-04-22T17:34:58Z NONE      

Hi team,

  1. Concise description about the problem: Clip function with minimum or maximum nan value

I see that with 1-dim DataArray, we can clip with minimum or maximum nan value:

python xx = xr.DataArray([1, 3, 5], dims = "x") xx.clip(np.nan, 4)

Result:

xarray.DataArrayx: 3 array([1., 3., 4.]) Coordinates: (0) Attributes: (0)

But with 2-dims DataArray, if one of two bounds is np.nan, we will receive nan value:

python da = xr.DataArray(np.arange(18).reshape(3, 6), coords = {"x": range(3), "y":range(6)}, dims = ("x", "y")) lower = xr.DataArray([1, 2, np.nan], coords = {"x": [0, 1, 2]}, dims = ["x"]) upper = xr.DataArray([4, 10, 14], coords = {"x": [0, 1, 2]}, dims = ["x"]) lower = xr.broadcast(da, lower)[1] upper = xr.broadcast(da, upper)[1] da.clip(lower, upper)

Result:

xarray.DataArrayx: 3y: 6 array([[ 1., 1., 2., 3., 4., 4.], [ 6., 7., 8., 9., 10., 10.], [nan, nan, nan, nan, nan, nan]]) Coordinates: x (x) int64 0 1 2 y (y) int64 0 1 2 3 4 5 Attributes: (0)

  1. Describe the solution i would like:

The clip function perform well with 2-dims as it done in 1-dims

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

Links from other tables

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