def test_align_multi_stream(RE, hw): a = Stream() b = FromEventStream( "event", ("data", "motor"), a, principle=True, event_stream_name="primary", ).map(op.add, 1) c = ToEventStream(b, ("out", )) c.sink(print) z = a.AlignEventStreams(c, event_stream_name="primary") sl = z.sink_to_list() RE.subscribe(lambda *x: a.emit(x)) def one_1d_step(detectors, motor, step): """ Inner loop of a 1D step scan This is the default function for ``per_step`` param in 1D plans. """ yield from checkpoint() yield from abs_set(motor, step, wait=True) yield from trigger_and_read(list(detectors) + [motor], name="dark") return (yield from trigger_and_read(list(detectors) + [motor])) osu = RE(scan([hw.img], hw.motor, 0, 10, 10, per_step=one_1d_step)) assert len(sl) == 10 + 3 for n, d in sl: if n == "start": assert d["original_start_uid"] == osu[0] if n == "event": print(d) assert d["data"]["out"] == d["data"]["motor"] + 1
def test_to_event_model_dict(RE, hw): source = Stream() t = FromEventStream("event", ("data", ), source, principle=True) n = ToEventStream(t) p = n.pluck(0).sink_to_list() d = n.pluck(1).sink_to_list() n.sink(print) RE.subscribe(unstar(source.emit)) RE.subscribe(print) RE(scan([hw.motor], hw.motor, 0, 9, 10)) print(d[1]["hints"]) # AAA assert set(p) == {"start", "stop", "event", "descriptor"} assert d[1]["hints"] == { "analyzer": { "fields": ["motor", "motor_setpoint"] } } assert d[2]["data"] == {"motor_setpoint": 0, "motor": 0} assert d[-1]["run_start"]