Skip to content

Instantly share code, notes, and snippets.

@klauer
Created February 18, 2016 19:43
Show Gist options
  • Save klauer/8874424aacbf47eeb714 to your computer and use it in GitHub Desktop.
Save klauer/8874424aacbf47eeb714 to your computer and use it in GitHub Desktop.
bson issue
klauer@xf03id-srv1:~/dev/pyepics$ cat bug.py
from ophyd import (SimDetector, TIFFPlugin, HDF5Plugin)
from ophyd.device import (Component as Cpt, )
prefix = 'XF:31IDA-BI{Cam:Tbl}'
class MyDetector(SimDetector):
tiff1 = Cpt(TIFFPlugin, 'TIFF1:')
det = MyDetector(prefix)
det.wait_for_connection()
print(det.describe())
print(det.tiff1.capture.describe())
print(det.tiff1.dim0_sa.get(use_monitor=True))
print(det.tiff1.dim0_sa.get(use_monitor=False))
import bson
import numpy as np
from metadatastore.commands import _transform_data
import collections
timestamps = collections.defaultdict(lambda key=None: 0.0)
ddet = _transform_data(det.read(), timestamps)
dtiff = _transform_data(det.tiff1.read(), timestamps)
bson.BSON.encode(ddet)
bson.BSON.encode(dtiff)
@klauer
Copy link
Author

klauer commented Feb 18, 2016

Traceback (most recent call last):
  File "../bug.py", line 33, in <module>
    bson.BSON.encode(ddet)
  File "/home/klauer/ramdisk/mc/envs/ophyd0/lib/python3.5/site-packages/bson/__init__.py", line 935, in encode
    return cls(_dict_to_bson(document, check_keys, codec_options))
bson.errors.InvalidDocument: Cannot encode object: array([0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment