seung-lab / cloud-files

Threaded Python and CLI client library for AWS S3, Google Cloud Storage (GCS), in-memory, and the local filesystem.
BSD 3-Clause "New" or "Revised" License
38 stars 8 forks source link

numpy import missing #4

Closed fcollman closed 4 years ago

fcollman commented 4 years ago
/opt/anaconda3/envs/minnietask/lib/python3.7/site-packages/cloudfiles/lib.py in default(self, obj)
     61 class NumpyEncoder(json.JSONEncoder):
     62   def default(self, obj):
---> 63     if isinstance(obj, np.ndarray):
     64       return obj.tolist()
     65     if isinstance(obj, np.integer):

NameError: name 'np' is not defined
william-silversmith commented 4 years ago

Do you think a required numpy dependency is okay just to support numpy JSON serialization?

fcollman commented 4 years ago

i think numpy is fairly ubiquitous at this point... you could however make it work in a dynamic way.. try except the numpy import and then only support this serialization if it was imported. Obviously if someone is trying to serialize a numpy result they are going to have it installed in their environment.