Skip to content

Commit

Permalink
Merge pull request #782 from danielballan/test-string-column
Browse files Browse the repository at this point in the history
Test string column
  • Loading branch information
danielballan authored Aug 24, 2023
2 parents c04a26d + 17fa6d5 commit 6be981b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion databroker/mongo_normalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def __init__(
for key, field_metadata in descriptor["data_keys"].items():
if field_metadata["dtype"] == "string":
# Skip this if it has a dtype_str with an itemsize.
dtype_str = field_metadata().get("dtype_str")
dtype_str = field_metadata.get("dtype_str")
if dtype_str is not None:
if numpy.dtype(dtype_str).itemsize != 0:
continue
Expand Down
20 changes: 20 additions & 0 deletions databroker/tests/test_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,23 @@ def test_v2_accessor(db, RE, hw):
assert db.v2[uid].start["uid"] == h.start["uid"]
# v2-style CatalogOfBlueskyRuns has v2 accessor
assert db.v2.v2.v2[uid].start["uid"] == h.start["uid"]


def test_string_column(db, RE, hw):
"Test string data."
from ophyd.sim import EnumSignal


class StringSignal(EnumSignal):
def describe(self):
desc = super().describe()
desc[self.name]["dtype"] = "string"
return desc

if not hasattr(db, "v2"):
raise pytest.skip("v0 has no v2 accessor")

RE.subscribe(db.insert)
signal = StringSignal(value="A", enum_strings=("A", "B"), name="signal")
uid, = get_uids(RE(count([signal], 5)))
data = db.v2[uid]["primary"]["data"]

0 comments on commit 6be981b

Please sign in to comment.