From 78469bbe3f57b64c9f3132846a43b4fcdeb20085 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed <fawzi.mohamed@fhi-berlin.mpg.de> Date: Tue, 31 Jan 2017 21:39:00 +0100 Subject: [PATCH] fix numpy json support --- common/python/nomadcore/json_support.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/python/nomadcore/json_support.py b/common/python/nomadcore/json_support.py index 724a7f2..9679a62 100644 --- a/common/python/nomadcore/json_support.py +++ b/common/python/nomadcore/json_support.py @@ -1,16 +1,17 @@ from builtins import object import json from nomadcore.compact_sha import sha512 +import numpy """Various functions to simplify and standardize dumping objects to json""" def numpyEncoder(o): """new default function for json class so that numpy arrays and sets can be encoded""" # check if object is a numpy array - if isinstance(o, np.ndarray): + if isinstance(o, numpy.ndarray): # ensure that we have an array with row-major memory order (C like) if not o.flags['C_CONTIGUOUS']: - o = np.ascontiguousarray(o) + o = numpy.ascontiguousarray(o) return o.tolist() # see default method in python/json/encoder.py elif isinstance(o, set): -- GitLab