Closed radiac closed 11 years ago
Interesting. Could you please add a few more tests of this kind for addition, subtraction and other operations between types (not only NumberValue) ...since it seems units and values of the original objects are frequently being modified in this maner. I'm surprised its been like this this long. Also, please maybe do this tests in the development branch (relevant code was relocated to types.py). Thank you for reporting and helping!
I did wonder about that; I won't have a chance to look for a week or so, but if there's nothing further on this issue by then, I'll take a look on the development branch.
I think I've fixed this in master
, with a rewrite of NumberValue
that allows arbitrary combinations of units (useful for intermediate calculations). Please give it a whirl and let me know if I missed anything!
In my previous commit, the original value objects were modified before the operation. Although this fixed the problem in question, it meant that when one of the values was a variable, the unit would be missing next time the variable was used.
This commit removes the units from the new
NumberValue
instead, so the original values are unaffected. Apologies for this stupid error - I have also added a new test to cover this.