Breaking: Implement AbstractArray interface for AbstractDimStack#871
Breaking: Implement AbstractArray interface for AbstractDimStack#871tiemvanderdeure wants to merge 16 commits intorafaqz:mainfrom
AbstractArray interface for AbstractDimStack#871Conversation
|
Lots of method ambiguities to work through. Possibly we can get even more out of this by making it an |
|
Yes I was already working on that. It mean I had to add the DimTuple to the type signature of |
AbstractArray interface for AbstractDimStackAbstractArray interface for AbstractDimStack
|
except for all the ambiguities the only tests that are broken are in |
|
Okay I actually managed to get rid of all ambiguities, I think. Most of it I could just delete, but I also explicitly specified that the eltype of a I ran some of the tests locally but let's see what they say. |
|
Yeah its always a One day we can make a |
|
I think this should work for the most part now, but would like to suggest one more breaking change. Currently the way DimArrays are treated in |
|
The problem is broadcasting over NamedTuple is a very inefficient and annoying way to e.g. multiply all layers of a stack by a scalar, especially if you have mixed size layers. That change will probably break (There are reasons it's not AbstractArray ;) Trying the Rasters tests may help clarify this |
Wouldn't that already require something like
I know, but I'm positively surprised that deleting a bunch of methods and some small tweaks made tests pass.
I'll give it a try and see how much of is broken on this branch |
|
Ok maybe a little clearer is multiplying by another raster that is a subset of the dimensions, often a bitmask. broadcast_dims means the same code works for a Raster and a RasterStack but that will break with your approach. We will at least need to provide a function that does that. Maybe or a |
For whatever it's worth: I got methods and stack tests to pass just by changing a few |
|
Okay with that example I see the problem more clearly. A keyword is an option but also makes a pretty basic and intuitive function more complicated. On this branch I think the easiest way to solve a case like this is where |
|
Except
|
|
Both those changes work well together, I think? So Then we can define |
|
Why a warning? |
|
We don't have to, I was thinking it could be worth warning because the function doesn't do anything in that case. Anyway, I gave it a shot and you can tell me what you think about that implementation. Multiple dispatch got complicated because |
|
Right. We just don't want warnings because we'll actually use this on Rasters. |
|
Aargh what are these Plots segfaults/compilation errors. So annoying |
|
What do you think here @rafaqz? The only thing here that I ended up actually breaking at the user end is the behaviour of |
|
There are still some conceptual problems, like |
But we should we try to figure those out? I'm sure you have a much better understanding than I do.
How so worse? The implementation didn't change at all so I think those should be the exact same? |
|
sum on an AbstractDimStack is currently calculated by layer. But as an AbstractArray some layers are repeated over missing dimensions so sum over the indexed values would be a much larger number ( But if we switch to AbstractArray we have to lose the mixed dimensionality in a lot of contexts to be consistent. And I'm not sure it's worth it. Instead we can implement broadcast on AbstractDimStack to be over all layers and always return a mixed size stack like the original. And other things like that, because we define the behaviour of the object rather than following an existing definition. |
See #870