NSLS-II / metadatastore

DEPRECATED: Incorporated into https://github.com/NSLS-II/databroker
Other
2 stars 11 forks source link

Cannot encode object error in search #268

Closed jrmlhermitte closed 7 years ago

jrmlhermitte commented 7 years ago

See following error:

# both these give error:

In [32]: a = np.arange(10, dtype=np.int32)
In [33]: list(chxdb(test=a[1]))
In [34]: a = np.arange(10, dtype=np.int64)
In [35]: list(chxdb(test=a[1]))

InvalidDocument: Cannot encode object: 1

# but these work fine
In [30]: a = np.arange(10, dtype=float)
In [31]: list(chxdb(test=a[1]))
Out[31]: []

In [7]: list(chxdb(test=1))

(chxdb is a databroker object from chx beamline)

As a digression, here's an interesting one is (this of course should return error):

In [6]: list(chxdb(test=np.ndarray([1])))
InvalidDocument: Cannot encode object: array([ 3.14159265])

(why is np.pi in here???)

(versions:

In [43]: databroker.__version__
Out[43]: '0.8.4+3.g49798b2'
In [46]: metadatastore.__version__
Out[46]: '0.6.4+3.gf107e05'
tacaswell commented 7 years ago

The source of those errors is that to go into pymongo (and hence down into mongo) the kwargs get turned into json and the default json encoder knows how to deal with python floats, but not numpy datatypes.

Not sure about pi though...

danielballan commented 7 years ago

The numpy array encoding issue as fixed in https://github.com/NSLS-II/metadatastore/pull/266 (and since ported into the databroker repo, along with the rest of metadatastore). It will be deployed in the next cycle.

What is happening with pi???!