On Thu, Nov 2, 2017 at 8:46 AM, <josef.p...@gmail.com> wrote: > > > On Wed, Nov 1, 2017 at 6:55 PM, Nathan Goldbaum <nathan12...@gmail.com> > wrote: > >> I think the biggest issues could be resolved if __array_concatenate__ >> were finished. Unfortunately I don't feel like I can take that on right now. >> >> See Ryan May's talk at scipy about using an ndarray subclass for units >> and the issues he's run into: >> >> https://www.youtube.com/watch?v=qCo9bkT9sow >> > > > Interesting talk, but I don't see how general library code should know > what units the output has. > for example if units are some flows per unit of time and we average, sum > or integrate over time, then what are the new units? (e.g. pandas time > aggregation) > What are units of covariance or correlation between two variables with the > same units, and what are they between variables with different units? > > How do you concatenate and operate arrays with different units? > > interpolation or prediction would work with using the existing units. > > partially related: > statsmodels uses a wrapper for pandas Series and DataFrames and tries to > preserve the index when possible and make up a new DataFrame or Series if > the existing index doesn't apply. > E.g. predicted values and residuals are in terms of the original provided > index, and could also get original units assigned. That would also be > possible with prediction confidence intervals. But for the rest, see above. >
using pint >>> x <Quantity([0 1 2 3 4], 'meter')> >>> x / x <Quantity([ nan 1. 1. 1. 1.], 'dimensionless')> >>> x / (1 + x) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\...\python-3.4.4.amd64\lib\site-packages\pint\quantity.py", line 669, in __add__ raise DimensionalityError(self._units, 'dimensionless') return self._add_sub(other, operator.add) File "C:\...\python-3.4.4.amd64\lib\site-packages\pint\quantity.py", line 580, in _add_sub pint.errors.DimensionalityError: Cannot convert from 'meter' to 'dimensionless' np.exp(x) raises pint.errors.DimensionalityError: Cannot convert from 'meter' ([length]) to 'dimensionless' (dimensionless) Josef > > Josef > > >> >> >> On Wed, Nov 1, 2017 at 5:50 PM, Marten van Kerkwijk < >> m.h.vankerkw...@gmail.com> wrote: >> >>> From my experience with Quantity, routines that properly ducktype work >>> well, those that feel the need to accept list and blatantly do >>> `asarray` do not - even if in many cases they would have worked if >>> they used `asanyarray`... But there are lots of nice surprises, with, >>> e.g., `np.fft.fftfreq` just working as one would hope. Anyway, bottom >>> line, I think you should let this stop you from trying only if you >>> know something important does not work. -- Marten >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@python.org >>> https://mail.python.org/mailman/listinfo/numpy-discussion >>> >> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@python.org >> https://mail.python.org/mailman/listinfo/numpy-discussion >> >> >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion