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

give unit registries a unit system #62

Merged
merged 1 commit into from
Jan 31, 2019

Conversation

ngoldbaum
Copy link
Member

@ngoldbaum ngoldbaum commented Jan 30, 2019

this required a fair amount of refactoring to avoid a circular dependency generated by the fact that the unit systems currently store Unit objects. That's not actually necessary, the unit systems only need to store the units that make up the system and can generate Unit objects to return to the user when __getitem__ is called.

Now that unit registries are associated with a unit system, the registry can be used to determine the appropriate unit system to use for a calculation. This allows the unit system to be controlled by an application by making use of a custom unit registry. Calls to in_base or get_base_equivalent will return data in the appropriately configured unit system associated with that registry.

I haven't yet added configuration for unit systems, but this at least makes it possible for application authors to have their own custom default unit system, as long as they make sure to always use their custom unit registry when they create new arrays.

this required a fair amount of refactoring to avoid a circular dependency
generated by the fact that the unit systems stored Unit objects. That's not
actually necessary, the unit systems only need to store the units that make up
the system and can generate Unit objects to return to the user when __getitem__
is called.

Now that unit registries are associated with a unit system, the registry can be
used to determine the appropriate unit system to use for a calculation. This
allows the unit system to be controlled by an application by making use of a
custom unit registry. Calls to in_base or get_base_equivalent will return data
in the appropriately configured unit system associated with that registry.
@jzuhone
Copy link
Contributor

jzuhone commented Jan 31, 2019

This is pretty great!

@ngoldbaum ngoldbaum merged commit 39151fd into yt-project:master Jan 31, 2019
@ngoldbaum ngoldbaum deleted the unit-systems-on-registries branch March 8, 2019 17:09
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