tloubrieu-jpl commented on a change in pull request #104: URL: https://github.com/apache/incubator-sdap-nexus/pull/104#discussion_r451858049
########## File path: analysis/webservice/webmodel/CustomEncoder.py ########## @@ -0,0 +1,49 @@ +import json +from datetime import datetime +from decimal import Decimal + +import numpy as np + + +class CustomEncoder(json.JSONEncoder): + def default(self, obj): + """If input object is an ndarray it will be converted into a dict + holding dtype, shape and the data, base64 encoded. + """ + numpy_types = ( + np.bool_, + # np.bytes_, -- python `bytes` class is not json serializable + # np.complex64, -- python `complex` class is not json serializable + # np.complex128, -- python `complex` class is not json serializable + # np.complex256, -- python `complex` class is not json serializable + # np.datetime64, -- python `datetime.datetime` class is not json serializable Review comment: It is a piece of code I moved but I did not change the content. I don't even see where this class is used. Where do you think we should convert it to a string ? Generally speaking for code simplicity I would keep a datetime object in the code and only convert it from inputs or to outputs but there might argument against that (size of the object ?). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org