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
(Related to #1300, which refers to Measurement instances. However, as the problem is not exactly the same I thought it would better to report separated issues)
Context
The attribute default_format of UnitRegistry and Quantity instances controls the default string representation.
When creating a quantity instance from the unit registry, the value of the default_format attribute is correctly propagated.
Expected behaviour
The behaviour of the different representation methods of Quantity instances is coherent and adheres to the value of the default_format attribute of the instance.
If the value of the default_format attribute is updated, the behaviour of the string representation methods of that instance changes accordingly.
The behaviour of the different representation methods is equivalent to that of related classes such as Measurement.
Issue
However, the behaviour of the different string representation methods of the quantity instance is inconsistent:
When updating the value of quantity.default_value with an empty string, _repr_html_ and _repr_latex_ adapt its behaviour accordingly, but __str__ keeps following what ureg.default_format specifies. If quantity.default_value is updated with a non-empty string all three methods update their behaviour
__repr__ method ignores both quantity.default_format and ureg.default_format. For comparison, the equivalent method from Measurement instances adhere to what it is specified in ureg.default_format.
Current version 0.24.3 Quantities do not care about Quantity.default_format directly on the instance, nor the documentation mentions it, so the inconsistency is gone.
(Related to #1300, which refers to
Measurement
instances. However, as the problem is not exactly the same I thought it would better to report separated issues)Context
The attribute
default_format
ofUnitRegistry
andQuantity
instances controls the default string representation.When creating a quantity instance from the unit registry, the value of the
default_format
attribute is correctly propagated.Expected behaviour
Quantity
instances is coherent and adheres to the value of thedefault_format
attribute of the instance.default_format
attribute is updated, the behaviour of the string representation methods of that instance changes accordingly.Measurement
.Issue
However, the behaviour of the different string representation methods of the quantity instance is inconsistent:
quantity.default_value
with an empty string,_repr_html_
and_repr_latex_
adapt its behaviour accordingly, but__str__
keeps following whatureg.default_format
specifies. Ifquantity.default_value
is updated with a non-empty string all three methods update their behaviour__repr__
method ignores bothquantity.default_format
andureg.default_format
. For comparison, the equivalent method from Measurement instances adhere to what it is specified inureg.default_format
.Minimal working example
The text was updated successfully, but these errors were encountered: