Skip to content

Add support for scaling factors to gemd-python#180

Merged
kroenlein merged 3 commits intomainfrom
feature/scaling-factors
Jan 30, 2023
Merged

Add support for scaling factors to gemd-python#180
kroenlein merged 3 commits intomainfrom
feature/scaling-factors

Conversation

@kroenlein
Copy link
Copy Markdown
Collaborator

Pint does not support scaling factors in units (e.g., support ticket). In order to provide support for units encountered in the wild (e.g., g / 2.5 cm), this PR adds support for strictly numeric scaling factors.

It dynamically adds a dimensionless scaling unit for any number encountered (where Number is defined using the same tokenizer as the core Pint library). Multiplication between a scaling factor and a unit also bind tighter than division (i.e., if that scaling factor is preceded by division and followed by a unit, it also puts that unit in the denominator).

Internal Citrine reference: https://citrine.atlassian.net/browse/PLA-6256

@kroenlein kroenlein requested a review from bfolie January 30, 2023 16:20
@kroenlein
Copy link
Copy Markdown
Collaborator Author

pint > 0.18 requires unit names be valid identifiers. Moved the munged version to first position in the definition statement, which unfortunately means that the pretty format isn't as pretty as it might be.

@kroenlein kroenlein requested a review from dleblanc January 30, 2023 20:39
Copy link
Copy Markdown

@dleblanc dleblanc left a comment

Choose a reason for hiding this comment

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

LGTM

@kroenlein kroenlein merged commit 9a6dd30 into main Jan 30, 2023
@kroenlein kroenlein deleted the feature/scaling-factors branch January 30, 2023 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants