SpikeInterface / spikeinterface

A Python-based module for creating flexible and robust spike sorting pipelines.
https://spikeinterface.readthedocs.io
MIT License
487 stars 187 forks source link

Out of range float values are not JSON compliant #3202

Open bxy666666 opened 1 month ago

bxy666666 commented 1 month ago

Traceback (most recent call last): File "G:\bxy\spikeinterface-main\examples\get_started\quickstart.py", line 114, in w1 = sw.plot_quality_metrics(we_KS2, display=False, backend="sortingview") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\spikeinterface\widgets\quality_metrics.py", line 44, in init MetricsBaseWidget.init( File "C:\Python312\Lib\site-packages\spikeinterface\widgets\metrics.py", line 80, in init BaseWidget.init(self, plot_data, backend=backend, backend_kwargs) File "C:\Python312\Lib\site-packages\spikeinterface\widgets\base.py", line 82, in init self.do_plot() File "C:\Python312\Lib\site-packages\spikeinterface\widgets\base.py", line 103, in do_plot func(self.data_plot, self.backend_kwargs) File "C:\Python312\Lib\site-packages\spikeinterface\widgets\metrics.py", line 263, in plot_sortingview self.url = handle_display_and_url(self, self.view, backend_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\spikeinterface\widgets\utils_sortingview.py", line 42, in handle_display_and_url url = view.url(label=figlabel) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\sortingview\views\View.py", line 101, in url return fig.url_from_url_dict(self.url_dict(label=label, state=state, allow_float64=allow_float64)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\sortingview\views\View.py", line 82, in url_dict {"type": view.type, "viewId": view.id, "dataUri": _upload_data_and_return_uri(view.to_dict(), allow_float64=allow_float64)} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\sortingview\views\View.py", line 153, in _upload_data_and_return_uri return kcl.store_json(fig.serialize_data(data, allow_float64=allow_float64), local=local) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\kachery_cloud\core.py", line 18, in store_json text = simplejson.dumps(x, separators=separators, indent=indent, allow_nan=False, sort_keys=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\simplejson__init__.py", line 395, in dumps kw).encode(obj) ^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\simplejson\encoder.py", line 298, in encode chunks = self.iterencode(o) ^^^^^^^^^^^^^^^^^^ File "C:\Users\bxy\AppData\Roaming\Python\Python312\site-packages\simplejson\encoder.py", line 379, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ ValueError: Out of range float values are not JSON compliant

zm711 commented 1 month ago

@magland, this seems to be a kachery issue. Have you seen this before?

magland commented 1 month ago

@zm711 I think this probably means that there are NaN values in the dataset, which cannt be serialized to valid JSON. Not sure the best way to remedy that

alejoe91 commented 1 month ago

We should have a remedy in place for that: https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/widgets/metrics.py#L233-L240

Maybe it's something else?

magland commented 1 month ago

We should have a remedy in place for that: https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/widgets/metrics.py#L233-L240

Maybe it's something else?

It's hard to say... we'd need to somehow intercept that data before it gets to that point and check for things that would trigger

"Out of range float values are not JSON compliant"

zm711 commented 1 month ago

When was that added @alejoe91? Based on the script provided it looks like this is waveform_extractor based code. Maybe that fix wasn't around for this version?

alejoe91 commented 1 month ago

No that has been there for several monts, if not more than a year