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

asscalar is no longer available in NumPy #254

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions kmapper/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,12 @@ def _render_d3_vis(

# Jinja default json serializer can't handle np arrays; provide custom encoding
def my_dumper(obj, **kwargs):
def np_encoder(object, **kwargs):
def np_encoder(object):
if isinstance(object, np.generic):
return np.asscalar(object)
return object.item()
if isinstance(object, np.ndarray):
return object.tolist()
return json.JSONEncoder().default(object)

return json.dumps(obj, default=np_encoder, **kwargs)

Expand Down
Loading