New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: Out of range float values are not JSON compliant #5439
Comments
@Evgeny7777 there is no chance to be able to help diagnose a problem like this without much more information (OS, 32/64 bit, locale settings, etc.), as well as a complete code sample to reproduce it. |
Issue #2288 seems related. |
Most probably it was NaN in data indeed, worked after clean up. Thanks |
@Evgeny7777, we do actually serialize |
Agreed, @Evgeny7777 if you can share a minimal code sample that reproduces this it would still be helpful. |
Bryan, will try to reproduce next week. It definitely was happening with пятница, 4 ноября 2016 г. пользователь Bryan Van de Ven написал:
sent from iPhone |
This should be resolved entirely by #5544 |
SOS: Guys, I started to learn bokeh and already have a problem. Does anybody know why? Help me please I want just one simple scatter to be drawn, have errors below: `--------------------------------------------------------------------------- /anaconda/lib/python3.6/site-packages/bokeh/io.py in show(obj, browser, new, notebook_handle) /anaconda/lib/python3.6/site-packages/bokeh/io.py in _show_with_state(obj, state, browser, new, notebook_handle) /anaconda/lib/python3.6/site-packages/bokeh/io.py in _show_file_with_state(obj, state, new, controller) /anaconda/lib/python3.6/site-packages/bokeh/io.py in save(obj, filename, resources, title, state, validate) /anaconda/lib/python3.6/site-packages/bokeh/io.py in _save_helper(obj, filename, resources, title, validate) /anaconda/lib/python3.6/site-packages/bokeh/embed.py in standalone_html_page_for_models(models, resources, title) /anaconda/lib/python3.6/site-packages/bokeh/embed.py in file_html(models, resources, title, template, template_variables) /anaconda/lib/python3.6/site-packages/bokeh/embed.py in _standalone_docs_json_and_render_items(models) /anaconda/lib/python3.6/site-packages/bokeh/document.py in to_json(self) /anaconda/lib/python3.6/site-packages/bokeh/document.py in to_json_string(self, indent) /anaconda/lib/python3.6/site-packages/bokeh/core/json_encoder.py in serialize_json(obj, pretty, indent, **kwargs) /anaconda/lib/python3.6/json/init.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw) /anaconda/lib/python3.6/json/encoder.py in encode(self, o) /anaconda/lib/python3.6/json/encoder.py in iterencode(self, o, _one_shot) ValueError: Out of range float values are not JSON compliant` |
Just wanted to point out this could be triggered if trying to do |
@jxramos if you need to send nan and inf values you must put your data into numpy arrays. For reasons that are 100% outside of our control, that is the only reliable efficient way to send nan and inf. |
I still get the error from the server in bokeh 1.3.4:
I am using python 3.6.9. I define nan via numpy. In my plot I dont want to show the zero values and therefore convert them to nan. I see that I dont get an error (and everything works fine) if I construct the columndatasource without nan values and later do an plot update and put nan values in the columndatasource. I do get an error when I try to construct a columndatasource with nan values. (If really needed I can make up a piece of code). |
@davilex404 we would definitely need a complete minimal reproducer to run in order to investigate. Just to clarify though:
It's not sufficient to merely define a single nan value using |
@bryevdv hereby a minimal reproducer: import pandas as pd // I did not want to plot zero values, and therefore made them np.nan. d = {'x': [1, 2, 3], 'y': [6, 0, 4]} // comment this line out and: "ValueError: Out of range float values are not JSON compliant" is not there anymore. cds = ColumnDataSource(df) p = figure(title='example') p.extra_y_ranges = {'y_axis2' : Range1d(cds.data['y'].min(), cds.data['y'].max())} show(p) |
The value error is given after calling show(p), but the problem is created by cds.data['y'].min() and cds.data['y'].max() in: The problem is that with np.nan in the set of y values the min() and max() functions return nan: cds.data['y'].min() returns nan, if a nan is in the set. (Same applies for max()). If there is a non-nan value in the set, I want that the min() function returns that value: this is what the function numpy.nanmin does. |
By the way: when taking out the lines to construct the right-hand y-axis I can plot the y-values with nan values in the y dataset (the nan values are not depicted of course). |
@KeesKoot48 I am not sure what you expect or are asking for. Bokeh can send NaN values in NumPy arrays that are columns in a CDS (because those are subject to a non-JSON encoding) but not elsewhere. Which is not even especially relevant the code you show: range start/end can't be NaN because there is nothing at all sensible that can be done with NaN values there. Range start/end are used to determine where and how to draw the axes. They must be actual numbers, end ensuring that, when they are set explicitly by the user, as above, is up to the user. |
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode |
Hello, i'm getting and error with
show(p, notebook_handle=True)
, withshow(p)
it's ok, using 0.12.3May provide more details if necessary, error is below
The text was updated successfully, but these errors were encountered: