Skip to content

Commit

Permalink
Merge branch 'mstimberg-jsonpickle_compatibility' into development
Browse files Browse the repository at this point in the history
* mstimberg-jsonpickle_compatibility:
  Enable handling of numpy arrays with recent `jsonpickle` versions
  • Loading branch information
pgleeson committed Jun 14, 2018
2 parents b6a92a7 + 6e9891c commit 1a41b6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then conda install unittest2 --yes; fi
- if [[ $TRAVIS_PYTHON_VERSION -ne "3.5" ]]; then conda install simplejson --yes ; fi
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then conda install pytables=3.2.0 --yes ; else conda install pytables=3.3.0 --yes ; fi
- pip install jsonpickle==0.7.2
- pip install jsonpickle
- pip install -r requirements.txt
- pip install .

Expand Down
6 changes: 6 additions & 0 deletions neuroml/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ class JSONWriter(object):
def __encode_as_json(cls,neuroml_document):
neuroml_document = cls.__sanitize_doc(neuroml_document)
from jsonpickle import encode as json_encode
try:
# Enable encoding of numpy arrays with recent jsonpickle versions
import jsonpickle.ext.numpy as jsonpickle_numpy
jsonpickle_numpy.register_handlers()
except ImportError:
pass # older version of jsonpickle
encoded = json_encode(neuroml_document)
return encoded

Expand Down

0 comments on commit 1a41b6b

Please sign in to comment.