Skip to content

Commit 2feac6e

Browse files
committed
added summary of known issues to documentation. Thank you Tony Yu.
1 parent 37e5b19 commit 2feac6e

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

doc/source/user/credits.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ John Salvatier
2424
added support for the Quantity iterator, contributed to support for
2525
simplified representations of units, comparison operators, and
2626
contributed unit tests.
27+
28+
Tony Yu
29+
contributed several bug fixes and contributed to the documentation.

doc/source/user/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ User's Guide
99

1010
installation.rst
1111
tutorial.rst
12+
issues.rst
1213
license.rst
1314
credits.rst

doc/source/user/issues.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
************
2+
Known Issues
3+
************
4+
5+
Quantities arrays are designed to work like normal numpy arrays. However, a few
6+
operations are not yet fully functioning.
7+
8+
.. note::
9+
In the following code examples, it's assumed that you've initiated the
10+
following imports:
11+
12+
>>> import numpy as np
13+
>>> import quantities as pq
14+
15+
16+
Addition and subtraction
17+
========================
18+
19+
The addition (or subtraction) of quantities with different (but compatible)
20+
units raises an error.
21+
22+
>>> a = 1 * pq.m
23+
>>> b = 100 * pq.cm
24+
>>> a + b
25+
Traceback (most recent call last):
26+
...
27+
ValueError: can not add units of m and cm
28+
29+
You can get around this error by making sure all quantities have the same
30+
units.
31+
32+
>>> b.units = pq.m
33+
>>> print a + b
34+
2.0 m
35+
36+
37+
Temperature conversion
38+
======================
39+
40+
Quantities is not designed to handle coordinate systems that require a point of
41+
reference, like positions on a map or absolute temperature scales. Proper
42+
support of coordinate systems would be a fairly large undertaking and is
43+
outside the scope of this project. Furthermore, consider the following::
44+
45+
>>> T_0 = 100 * pq.K
46+
>>> T_1 = 200 * pq.K
47+
>>> dT = T_1-T_0
48+
>>> dT.units = pq.degF
49+
50+
To properly support the above example, quantities would have to distinguish
51+
absolute temperatures with temperature differences. It would have to know how
52+
to combine these two different animals, etc. The quantities project has
53+
therefore elected to limit the scope to relative quantities.
54+
55+
As a consequence, quantities treats temperatures as a temperature difference.
56+
This is a distinction without a difference when considering Kelvin and Rankine,
57+
or transformations between the two scales, since both scales have zero offset.
58+
Temperature scales in Celsius and Fahrenheit are different and would require a
59+
non-zero offset, which is not supported in Quantities unit transformation
60+
framework.
61+
62+
63+
`umath` functions
64+
=================
65+
66+
Many common math functions ignore the dimensions of quantities. For example,
67+
trigonometric functions (e.g. `np.sin`) suffer this fate. For these functions,
68+
quantities arrays are treated like normal arrays and the calculations proceed
69+
as normal (except that a "not implemented" warning is raised). Note, however,
70+
this behavior is not ideal since some functions should behave differently for
71+
different units. For example, you would expect `np.sin` to give different
72+
results for an angle of 1° versus an angle of 1 radian; instead, `np.sin`
73+
extracts the magnitude of the input and assumes that it is already in radians.
74+
75+
To properly handle quantities, use the corresponding quantities functions
76+
whenever possible. For example, `pq.sin` will properly handle the angle inputs
77+
described above. For an exhaustive list, see the functions defined in
78+
`pq.umath`.
79+
80+
81+
Functions which ignore/drop units
82+
=================================
83+
84+
There are additional numpy functions not in `pq.umath` that ignore and drop
85+
units. Below is a list known functions in this category
86+
87+
* `vstack`
88+
* `interp`
89+

0 commit comments

Comments
 (0)