holoviz / datashader

Quickly and accurately render even the largest data.
http://datashader.org
BSD 3-Clause "New" or "Revised" License
3.26k stars 363 forks source link

RuntimeWarning: invalid value encountered in cast #1216

Closed ianthomas23 closed 1 year ago

ianthomas23 commented 1 year ago

Using numpy 1.24 we are seeing

RuntimeWarning: invalid value encountered in cast

when running tests. For example

$ pytest -v datashader/tests/test_pandas.py::test_categorical_count_binning
datashader/tests/test_pandas.py::test_categorical_count_binning[df0] PASSED                                                                                    [100%]

datashader/tests/test_pandas.py::test_categorical_count_binning[df0]
  /Users/iant/github/datashader/datashader/reductions.py:202: RuntimeWarning: invalid value encountered in cast
    index = ((values - self.bin0) / self.binsize).astype(int)

The same warning also occurs in transfer_functions:

datashader/tests/test_transfer_functions.py: 306 warnings
  /home/runner/work/datashader/datashader/datashader/transfer_functions/__init__.py:310: RuntimeWarning: invalid value encountered in cast
    r = interp(data, span, rspan, left=255).astype(np.uint8)

Thanks to @Hoxbro for identifying this downstream.