You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the ApplicationRegistry.set method (in pint.registry) requires that the new_registry parameter be an instance of UnitRegistry or LazyRegistry, and therefore does not allow instances of GenericUnitRegistry to be used:
defset(self, new_registry):
"""Set the new registry Parameters ---------- new_registry : ApplicationRegistry or LazyRegistry or UnitRegistry The new registry. See Also -------- set_application_registry """ifisinstance(new_registry, type(self)):
new_registry=new_registry.get()
ifnotisinstance(new_registry, (LazyRegistry, UnitRegistry)):
raiseTypeError("Expected UnitRegistry; got %s"%type(new_registry))
logger.debug(
"Changing app registry from %r to %r.", self._registry, new_registry
)
self._registry=new_registry
I was wondering if this is the intended behavior, or if it would make sense to also allow GenericUnitRegistry objects to be set as the application registry. I'd like to be able to use a custom generic unit registry class (as described here in the docs) with set_application_registry in a manner similar to the following:
Currently, doing something like that just raises a TypeError because of the behavior of ApplicationRegistry.set. Perhaps ApplicationRegistry.set could be adjusted to also allow GenericUnitRegistry objects?
The text was updated successfully, but these errors were encountered:
cometbeetle
changed the title
Should set_application_registry work with GenericUnitRegistry objects?
Should set_application_registry work with GenericUnitRegistry objects?
Nov 22, 2024
Right now, the
ApplicationRegistry.set
method (in pint.registry) requires that thenew_registry
parameter be an instance ofUnitRegistry
orLazyRegistry
, and therefore does not allow instances ofGenericUnitRegistry
to be used:I was wondering if this is the intended behavior, or if it would make sense to also allow
GenericUnitRegistry
objects to be set as the application registry. I'd like to be able to use a custom generic unit registry class (as described here in the docs) withset_application_registry
in a manner similar to the following:Currently, doing something like that just raises a
TypeError
because of the behavior ofApplicationRegistry.set
. PerhapsApplicationRegistry.set
could be adjusted to also allowGenericUnitRegistry
objects?The text was updated successfully, but these errors were encountered: