diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-16 13:13:28 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-16 13:13:28 +0000 |
commit | fffc07105b379b51414932f3794d9de19e37293a (patch) | |
tree | 80fcaeed980b037591767c1fcf461c3319f2dcb8 /AUTHORS | |
parent | ae9817b7795d3471a260597692ede846640c5ed2 (diff) | |
parent | f52122cf7e17beb26d7107fc70833d9df7587e74 (diff) | |
download | pint-fffc07105b379b51414932f3794d9de19e37293a.tar.gz |
Merge #805
805: Fix definition of dimensionless units r=hgrecco a=Jellby
There is something strange going on with dimensionless units/numbers:
```
>>> ureg.get_base_units('pi')
(3.141592653589793, <Unit('dimensionless')>)
>>> ureg.get_base_units('fine_structure_constant')
(1.0, <Unit('fine_structure_constant')>)
```
It seems dimensionless units defined in a file are interpreted as base units, while `pi` is hard-coded and interpreted correctly as a number. I think this is because for an empty list both `all()` and `not any()` are true. The fix is just changing the order of the tests, such that when a unit has no dimensions the `not any()` test passes first and the unit is marked as not-base. After the fix:
```
>>> ureg.get_base_units('pi')
(3.141592653589793, <Unit('dimensionless')>)
>>> ureg.get_base_units('fine_structure_constant')
(0.0072973525698, <Unit('dimensionless')>)
```
In addition, the hard-coded definition of `pi` is better done *before* loading the file definitions, I believe, so `pi` can be used in defining base units for `@system`, and also to allow redefining `pi` in a file, if desired. This also required removing the special treatment for `pi` in `_eval_token()`, which I don't think is need anyway.
Finally, I applied some corrections to the default definitions: Added `ln10` = ln(10), just to test the above fix with a number not subject to updates. Fixed the `deka-` prefix. Made the `acre_foot` consisent, I don't think it should use the survey foot for area times the international foot. Fixed the dry barrell, which I see everywhere defined as 7056 in^3, not 7065. Fixed spelling of "hundredweight" (if it was intentional, I still find it weird that the long and short ones are misspelled differently).
Co-authored-by: Jellby <jellby@yahoo.com>
Diffstat (limited to 'AUTHORS')
0 files changed, 0 insertions, 0 deletions