Skip to content
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

Expose units symbol & name on KeyData objects #449

Merged
merged 7 commits into from
Oct 9, 2023
Merged

Expose units symbol & name on KeyData objects #449

merged 7 commits into from
Oct 9, 2023

Conversation

takluyver
Copy link
Member

As two new properties, .units and .units_name. These combine the unit & metric prefix attributes written by Karabo to give symbols like 'μJ' or 'fs'. They will be None if these attributes aren't available. Pint recognises either the symbol or the name (for the couple of cases I tried).

There's no caching at present. I assume people won't retrieve units many times for the same key, and the OS disk cache could help a bit anyway.

@takluyver takluyver added the enhancement New feature or request label Oct 5, 2023
extra_data/keydata.py Outdated Show resolved Hide resolved
extra_data/keydata.py Show resolved Hide resolved
extra_data/keydata.py Outdated Show resolved Hide resolved
@JamesWrigley
Copy link
Member

(oh, and this should probably be documented too)

extra_data/keydata.py Fixed Show fixed Hide fixed
Copy link
Member

@JamesWrigley JamesWrigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@takluyver
Copy link
Member Author

Thanks!

prnote: New properties units and units_name on KeyData objects to retrieve units metadata written by Karabo.

@philsmt
Copy link
Contributor

philsmt commented Oct 9, 2023

LGTM!

Some time ago I scanned over several runs and found only unitSymbol and metricPrefixSymbol to be present in any reliable manner. If necessary, we can add a note to the documentation.

@takluyver takluyver merged commit b532940 into master Oct 9, 2023
10 checks passed
@takluyver takluyver deleted the units branch October 9, 2023 16:22
@takluyver takluyver modified the milestones: 1.14, 1.15 Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants