python-quantities-developers team mailing list archive
-
python-quantities-developers team
-
Mailing list archive
-
Message #00023
.units returns a string currently, is this set in stone?
The way the properties .units and .dimensionality currently work is ok, but
I feel as though they could be reworked so that doing common operations is
easier and more obvious (however, I am not sure exactly how to do so).
Here are some common operations:
1) check the equivalence of two sets of units
- currently x.units == y.units works, but works through string comparison
which seems inelegant, but maybe doesn't have any actual drawbacks
2) check the compatibility of two sets of units
- currently x.simplified.units == y.simplified.units is the most straight
forward way to do this, but this adds unnecessary array multiplication
- I think it would be intuitive if x.dimensionality == y.dimensionality
accomplished this but this would require some refactoring
3) check that quantity is dimensionless
- currently x.dimensionality = dimensionless.dimensionality accomplishes
this
- it would be intuitive if x.units == dimensionless accomplished this
(could be tricky since dimensionless is a Quantity)
I don't know if there is a way to accomplish all of these at once in an
elegant way, I am just throwing out ideas and observations.
I think that ".dimensionality" when contrasted with ".units" sounds like a
way to compare the compatibility of the units ( e.g. #2)
Thoughts?
Follow ups