-
Notifications
You must be signed in to change notification settings - Fork 12
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
standardize export & restore of diffractometer configuration #279
Conversation
prjemian
commented
Oct 26, 2023
- close Store operational information locally for use outside of bluesky #256
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (for me, tomorrow):
- Review 'hkl/configuration.py'
- Review 'tests/conftest.py'
- Review 'tests/test_configuration.py'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really useful feature, and nicely done. I left some comments and suggestions, but none of them are fatal.
In discussion, @rodolakis is concerned that the |
While a nice thing to have, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice addition and great test coverage!
I added a few non-blocking comments.
return dict( | ||
reflection=dict(h=h, k=k, l=l), | ||
flag=refl.flag_get(), | ||
wavelength=geom.wavelength_get(1), | ||
position={k: v for k, v in zip(geom.axis_names_get(), geom.axis_values_get(1))}, | ||
orientation_reflection=refl in self._orientation_reflections, | ||
) | ||
return { | ||
"reflection": {"h": h, "k": k, "l": l}, | ||
"flag": refl.flag_get(), # not used by hklpy | ||
"wavelength": geom.wavelength_get(1), | ||
"position": dict(zip(geom.axis_names_get(), geom.axis_values_get(1))), | ||
"orientation_reflection": refl in self._orientation_reflections, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did not dict
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict(zip(geom.axis_names_get(), geom.axis_values_get(1)))
was still used, not sure if there is a huge benefit, but it's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. That was the form suggested, rather than a dict comprehension. Go figure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pylint flagged the simpler dict(a=1, b="two")
style for replacement with {"a": 1, "b": "two"}
. Looks cumbersome to me and adds invisible benefit for such small dictionaries. But it makes pylint happy.
hkl/tests/data/e4c-config.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need to add this file and other non-Python files to https://github.com/bluesky/hklpy/blob/main/MANIFEST.in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why not to reuse docs/source/_static/e4c-config.json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2146ed2. Unit test is in-source.
|
||
before.pop("datetime") | ||
after.pop("datetime") | ||
assert before == after, "should be same configuration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We found it useful to use https://pypi.org/project/dictdiffer/ to compare large/nested dictionaries. It may be useful here as well.
""" | ||
|
||
def __init__(self, diffractometer): | ||
from .diffract import Diffractometer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not import it on the top of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid potential for circular import.
Co-authored-by: Max Rakitin <mrakitin@users.noreply.github.com>
… into 256-orientation-dict
Co-authored-by: Max Rakitin <mrakitin@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
It looks like when |
Sounds like a bug. Thanks for the report! |