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
When fetching imperial gallons via a registry created just as reg1 = UnitRegistry() using reg1.sys.imperial.gallon it returns the correct unit. When fetching the same unit using reg2 = UnitRegistry(system="imperial") and then referencing reg2.gallon the wrong (US) unit is returned.
For example, this works:
importpintprint(pint.__version__)
plain_reg=pint.UnitRegistry()
print("Default system: ", plain_reg.default_system)
imp_pint=1*plain_reg.sys.imperial.pintus_pint=1*plain_reg.sys.US.pintprint("Pints via plain registry:", imp_pint.to("litre").m, imp_pint.to("litre").m/us_pint.to("litre").m)
imp_gallon=1*plain_reg.sys.imperial.gallonus_gallon=1*plain_reg.sys.US.gallonprint("Gallons via plain registry:", imp_gallon.to("litre").m, imp_gallon.to("litre").m/us_gallon.to("litre").m)
It gives the expected:
0.24.3
Default system: mks
Pints via plain registry: 0.5682612500000002 1.2009499255048557
Gallons via plain registry: 4.546090000000001 1.2009499255048557
This does not work correctly:
importpintprint(pint.__version__)
imperial_reg=pint.UnitRegistry(system="imperial")
us_reg=pint.UnitRegistry(system="US")
print("Imperial system: ", imperial_reg.default_system)
print("US system: ", us_reg.default_system)
imp_reg_pint=1*imperial_reg.pintus_reg_pint=1*us_reg.pintprint("Pints via system registries:", imp_reg_pint.to("litre").m, imp_reg_pint.to("litre").m/us_reg_pint.to("litre").m)
imp_reg_gallon=1*imperial_reg.gallonus_reg_gallon=1*us_reg.gallonprint("Gallons via system registries:", imp_reg_gallon.to("litre").m, imp_reg_gallon.to("litre").m/us_reg_gallon.to("litre").m)
The result is:
0.24.3
Imperial system: imperial
US system: US
Pints via system registries: 0.4731764729999999 1.0
Gallons via system registries: 3.785411783999999 1.0
In the later case, even though a system was specified when creating the registry and is shown as being the default, it is not being used when fetching the volume measures. Instead it is fetching the US volume measurements.
The text was updated successfully, but these errors were encountered:
When fetching imperial gallons via a registry created just as
reg1 = UnitRegistry()
usingreg1.sys.imperial.gallon
it returns the correct unit. When fetching the same unit usingreg2 = UnitRegistry(system="imperial")
and then referencingreg2.gallon
the wrong (US) unit is returned.For example, this works:
It gives the expected:
This does not work correctly:
The result is:
In the later case, even though a system was specified when creating the registry and is shown as being the default, it is not being used when fetching the volume measures. Instead it is fetching the US volume measurements.
The text was updated successfully, but these errors were encountered: