pydata / pydata/xarray

Function warning when sequence is all np.nan

Open
#9,870 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

When processing the data, even with the bottleneck package installed, there is still a Warning when the sequence is empty. is it because bottleneck can't handle the .quantile function and still ends up calling the numpy function?

bottleneck: speeds up NaN-skipping and rolling window aggregations by a large factor

import xarray as xr
import numpy as np
array = np.random.randn(3,5,5)
array[:,2,2]=np.nan
data = xr.DataArray(array,
                    coords={'time': np.arange(3),
                            'lon': np.arange(5),
                            'lat': np.arange(5)}
                            )
data.quantile(0.95,dim='time', method='median_unbiased')
/home/yu/miniconda3/envs/learn/lib/python3.11/site-packages/numpy/lib/nanfunctions.py:1563: RuntimeWarning: All-NaN slice encountered
  return function_base._ureduce(a,

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided xarray DataArray example with the bottleneck package installed and confirm the RuntimeWarning from NumPy's nanfunctions.py. Trace the DataArray.quantile path to determine how all-NaN slices are handled; done means the intended quantile behavior is established and the warning behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.