Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JSON Doesn't Allow Inf/NaN #210

Open
@brunobeltran

Description

@brunobeltran

Currently, if I try to load in any variables from Matlab that contain infs or NaNs, the program does the "right thing", but the variables get returned polluted with error messages where the fields should be.

In the IPython Notebook, this can cause the get_variable routine to hang indefinitely. Usually, however, we get something like the following:

In [1]: lab.run_code('a.b = inf; a.c = [inf -inf nan 1 0];')
Out[1]:
{'content': {'datadir': '/tmp/MatlabData/', 'figures': [], 'stdout': ''},
 'result': [],
 'stack': [],
 'success': True}

In [2]: lab.get_variable('a')
Out[2]:
{'b': 'Java exception occurred: \norg.json.JSONException: JSON does not allow non-finite numbers.\n\tat org.json.JSONObject.testValidity(JSONObject.java:1288)\n\tat org.json.JSONObject.put(JSONObject.java:1100)\n\tat org.json.JSONObject.put(JSONObject.java:1037)',
 'c': array([[ inf, -inf,  nan,   1.,   0.]])}

Seems like a simple hack around the problem would be to simply return scalars as 1-by-1 numpy arrays instead...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions