html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/525#issuecomment-483835929,https://api.github.com/repos/pydata/xarray/issues/525,483835929,MDEyOklzc3VlQ29tbWVudDQ4MzgzNTkyOQ==,2789820,2019-04-16T20:44:32Z,2019-04-16T20:44:32Z,NONE,"Indeed, all of us over-riders have to start to return `NotImplemented` if we don't know what the other class is - and I write this having recently realized that in astropy's `Quantity` I have caused similar problems by trying to make a guess (despite being admonished to refuse to do that). Of course, numpy's `ndarray` is the worst culprit here, just coercing everything to array.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585 https://github.com/pydata/xarray/issues/525#issuecomment-248468400,https://api.github.com/repos/pydata/xarray/issues/525,248468400,MDEyOklzc3VlQ29tbWVudDI0ODQ2ODQwMA==,2789820,2016-09-20T23:39:29Z,2016-09-20T23:39:29Z,NONE,"@burnpanck - thanks for the very well-posed description of why units are so useful not as some meta-data, but as an integral property. Of course, this is also why making them part of a new dtype is a great idea! But failing that, I'd agree that it has to be part of something like an `ndarray` subclass; this is indeed what we do in `astropy.units.Quantity` (and `concatenate` does not work for us either...). Now, off-topic but still: what is a little less wonderful is that there seem to be quite a few independent units implementations around (even just in astronomy, there is that of `amuse`; ours is based on things initially developped by `pynbody`). It may well be hard to merge them at this stage, but it would be good to think how we could at least interoperate... ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585 https://github.com/pydata/xarray/issues/525#issuecomment-181916808,https://api.github.com/repos/pydata/xarray/issues/525,181916808,MDEyOklzc3VlQ29tbWVudDE4MTkxNjgwOA==,2789820,2016-02-09T15:35:37Z,2016-02-09T15:35:37Z,NONE,"@hgrecco - for astropy's `Quantity`, we currently also rely on `__array_prepare__` and `__array_wrap__`. The main annoyances are (1) one cannot change the input before a numpy ufunc is called, and therefore often has no choice but to let a wrong calculation proceed; (2) proper recognition in non-ufunc functions is sparse (e.g., `np.dot`, etc.; see http://docs.astropy.org/en/latest/known_issues.html#quantity-issues) Aside: at some point I'd hope to get the various implementations of units to talk together: it would be good to have an API that works such that units are inter-operable. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585 https://github.com/pydata/xarray/issues/525#issuecomment-141999146,https://api.github.com/repos/pydata/xarray/issues/525,141999146,MDEyOklzc3VlQ29tbWVudDE0MTk5OTE0Ng==,2789820,2015-09-21T14:29:47Z,2015-09-21T14:29:47Z,NONE,"p.s. For `concatenate`, you need unit conversion as well, so sadly `Quantity` does need to override that too (and currently cannot, which is rather annoying). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585 https://github.com/pydata/xarray/issues/525#issuecomment-141997335,https://api.github.com/repos/pydata/xarray/issues/525,141997335,MDEyOklzc3VlQ29tbWVudDE0MTk5NzMzNQ==,2789820,2015-09-21T14:22:33Z,2015-09-21T14:22:33Z,NONE,"@shoyer - fair enough, and sad we don't have `__numpy_ufunc__` yet... I agree that with Quantity inside, one would end up duplicating work for every chunk, which makes it less than ideal even though it would probably be the easier approach to implement. For the outside method, from the dask perspective, it would indeed be easiest if units were done as a dtype, since then you can punt all the decisions to helper routines. My guess, though, is that it will be a while before numpy will include what is required to tell, e.g., that if I add something in `m` to something in `cm`, the second argument has to be multiplied by `0.01`. But astropy does provide something just like that: `quantity_helpers` exposes a dict keyed by operation, which holds functions that return the required converters given the units. E.g., in the above example, internally [what happens](https://github.com/astropy/astropy/blob/master/astropy/units/quantity.py#L315) is ``` converters, result_unit = UFUNC_HELPERS[np.add](np.add, *units) result_unit # Unit(""m"") converters[0] # None converters[1] # .> converters[1](1.) # 0.01 ``` In `dask`, you could run the converters on your individual chunks, though obviously I don't know how easy it is to add an extra step like this without slowing down other aspects too much. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585 https://github.com/pydata/xarray/issues/525#issuecomment-141697319,https://api.github.com/repos/pydata/xarray/issues/525,141697319,MDEyOklzc3VlQ29tbWVudDE0MTY5NzMxOQ==,2789820,2015-09-19T18:53:43Z,2015-09-19T18:53:43Z,NONE,"@shoyer - as one who thinks unit support is probably the single best thing astropy has (and is co-maintainer of `astropy.units`), I thought I'd pipe in: why would it be a problem that astropy's `Quantity` is an `ndarray` subclass? I must admit not having used dask arrays, but since they use `ndarray` internally for the pieces, shouldn't the fact that `Quantity` has the same interface/methods, make it relatively easy to swap `ndarray` for `Quantity` internally? I'd be quite happy to help think about this (surely it cannot be as bad as it is for `MaskedArray` ;-). Alternatively, maybe it is easier to tag on the outside rather than the inside. This would also not seem to be that hard, given that astropy's `Quantity` is really just a wrapper around `ndarray` that carries a `Unit` instance. I think the parts that truly wrap might be separated from those that override `ndarray` methods, and would be willing to implement that if there is a good reason (like making dask quantities possible...). It may be that in this case one would not use `Quantity` proper, but rather just the parts of `units` where the real magic happens: in the `Unit` class (which does the unit conversion) and in `quantity_helpers.py` (which tells what unit conversion is necessary for a given operation/function). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,100295585