Skip to content

look at merge cycler and make sure it works with any combination of pseudo-axis #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
awalter-bnl opened this issue May 15, 2019 · 2 comments
Labels
good first issue hackathon Good issues for the upcoming bluesky hackathon

Comments

@awalter-bnl
Copy link
Contributor

We need to check if the merge_cycler works with pyhkl when scanning just h, (h and k), (h,k and l) and not just 2

@tacaswell
Copy link
Contributor

I think that is what

def test_mesh_pseudo(hw, RE):
p3x3 = hw.pseudo3x3
sig = hw.sig
d = DocCollector()
RE.subscribe(d.insert)
rs, = RE(bp.grid_scan([sig],
p3x3.pseudo1, 0, 3, 5,
p3x3.pseudo2, 7, 10, 7, False))
df = pd.DataFrame([_['data']
for _ in d.event[d.descriptor[rs][0]['uid']]])
for k in p3x3.describe():
assert k in df
for k in sig.describe():
assert k in df
assert all(df[sig.name] == 0)
assert all(df[p3x3.pseudo3.name] == 0)
def test_rmesh_pseudo(hw, RE):
p3x3 = hw.pseudo3x3
p3x3.set(1, -2, 100)
init_pos = p3x3.position
sig = hw.sig
d = DocCollector()
RE.subscribe(d.insert)
rs, = RE(bp.rel_grid_scan(
[sig],
p3x3.pseudo1, 0, 3, 5,
p3x3.pseudo2, 7, 10, 7, False))
df = pd.DataFrame([_['data']
for _ in d.event[d.descriptor[rs][0]['uid']]])
for k in p3x3.describe():
assert k in df
for k in sig.describe():
assert k in df
assert all(df[sig.name] == 0)
assert all(df[p3x3.pseudo3.name] == 100)
assert len(df) == 35
assert min(df[p3x3.pseudo1.name]) == 1
assert init_pos == p3x3.position
def test_relative_pseudo(hw, RE, db):
RE.subscribe(db.insert)
p = hw.pseudo3x3
p.set(1, 1, 1)
base_pos = p.position
# this triggers the merging code path
rs, = RE(bp.relative_inner_product_scan([p],
5,
p.pseudo1, -1, 1,
p.pseudo2, -2, -1))
tb1 = db[rs].table().drop('time', 1)
assert p.position == base_pos
# this triggers this does not
rs, = RE(bp.relative_inner_product_scan([p],
5,
p.real1, 1, -1,
p.real2, 2, 1))
tb2 = db[rs].table().drop('time', 1)
assert p.position == base_pos
# same columns
assert set(tb1) == set(tb2)
# same number of points
assert len(tb1) == len(tb2)
def get_hint(c):
h = c.hints['fields']
return h[0] if h else c.name
for c in list(p.pseudo_positioners) + list(p.real_positioners):
col = get_hint(c)
print(col)
assert (tb1[col] == tb2[col]).all()
assert (tb1[get_hint(p.pseudo1)] == np.linspace(0, 2, 5)).all()
def test_reset_wrapper(hw, RE):
p = hw.pseudo3x3
m_col = MsgCollector()
RE.msg_hook = m_col
RE(bp.relative_inner_product_scan([], 1,
p.pseudo1, 0, 1,
p.pseudo2, 0, 1))
expecte_objs = [p, None, None,
p, None, p,
None, None, p,
None, None, p,
p, None]
assert len(m_col.msgs) == 14
assert [m.obj for m in m_col.msgs] == expecte_objs
@pytest.mark.parametrize('pln', [bps.mv, bps.mvr])
def test_pseudo_mv(hw, RE, pln):
p = hw.pseudo3x3
m_col = MsgCollector()
RE.msg_hook = m_col
RE(pln(p.pseudo1, 1,
p.pseudo2, 1))
expecte_objs = [p, None]
assert len(m_col.msgs) == 2
assert [m.obj for m in m_col.msgs] == expecte_objs
is testing.

@awalter-bnl
Copy link
Contributor Author

Thanks for the link @tacaswell, It appears you are correct. This does test 2 axes a t once. I think we may want to add another test with all 3 pseudo axes in a scan as well however for completeness (although I have no reason to suspect it won’t work with 3).

@stan-dot stan-dot added the hackathon Good issues for the upcoming bluesky hackathon label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue hackathon Good issues for the upcoming bluesky hackathon
Projects
None yet
Development

No branches or pull requests

4 participants