openPMD / openPMD-viewer

:snake: Python visualization tools for openPMD files
https://openpmd-viewer.readthedocs.io/
Other
63 stars 49 forks source link

invalid value encountered in cast #401

Open berceanu opened 10 months ago

berceanu commented 10 months ago

I encountered a cast Warning and tracked it down to this line:

https://github.com/openPMD/openPMD-viewer/blob/b36dc4331c5fe5a1e8666faf608faf6b6ef4b2ca/openpmd_viewer/openpmd_timeseries/data_reader/io_reader/utilities.py#L70

In order to see it, one needs to set np.seterr(all='raise'). I get:

    multiarray.copyto(a, fill_value, casting='unsafe')
  File "<__array_function__ internals>", line 200, in copyto
FloatingPointError: invalid value encountered in cast

Without raising warnings as errors, one just gets the warning, with no stack trace and no way to see where it is coming from.

<__array_function__ internals>:200: RuntimeWarning: invalid value encountered in cast

I suspect this is caused by having an int type which is being filled with NaN, that is of float type?

ax3l commented 8 months ago

I am not sure if we have not fixed this already with https://github.com/openPMD/openPMD-viewer/commit/a978fc1d59bbb7d7572a7dbb9433a31f8e9f02a3 by now.

@berceanu can you retry and link a data set that shows the warning/error, so we can reproduce and fix it?