Skip to content
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

Python plot fails with strange error when using ndarray instead of list #7668

Closed
altavir opened this issue Jul 9, 2018 · 1 comment
Closed

Comments

@altavir
Copy link

altavir commented Jul 9, 2018

When using python plot examples with np.linspace(...) instead of list literal [...], it fails with json error:

~\Anaconda3\lib\site-packages\beakerx\plot\chart.py in add(self, item)
    222     def add(self, item):
    223         self.chart.add(item)
--> 224         self.model = self.chart.transform()
    225         return self
    226 

~\Anaconda3\lib\site-packages\beakerx\utils.py in transform(self)
     46 
     47     def transform(self):
---> 48         model = json.dumps(self, cls=ObjectEncoder)
     49         return json.loads(model)
     50 

~\Anaconda3\lib\json\__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    236         check_circular=check_circular, allow_nan=allow_nan, indent=indent,
    237         separators=separators, default=default, sort_keys=sort_keys,
--> 238         **kw).encode(obj)
    239 
    240 

~\Anaconda3\lib\json\encoder.py in encode(self, o)
    197         # exceptions aren't as detailed.  The list call should be roughly
    198         # equivalent to the PySequence_Fast that ''.join() would do.
--> 199         chunks = self.iterencode(o, _one_shot=True)
    200         if not isinstance(chunks, (list, tuple)):
    201             chunks = list(chunks)

~\Anaconda3\lib\json\encoder.py in iterencode(self, o, _one_shot)
    255                 self.key_separator, self.item_separator, self.sort_keys,
    256                 self.skipkeys, _one_shot)
--> 257         return _iterencode(o, 0)
    258 
    259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

ValueError: Circular reference detected
@altavir
Copy link
Author

altavir commented Jul 9, 2018

Adding tolist() to arguments solves the problem. Seems to be specific ndarray problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants