Closed rafaqz closed 2 years ago
You could rename intersect to intersection, that makes it more distinct and follows convention.
Yeah I just saw that in ArchGDAL. The problem is the base Julia convention is intersect
.
All new functions could have an optional strict
argument, that's false
by default, indicating whether the result only operates on shared dimensions or not?
Is the idea to throw an error if they dont match when strict = true
?
Hmm, maybe just strict isn't enough if we want to be verbose. In the case of mismatching dimensions (but at least 1 overlap)
I dislike the error, so maybe only give back nothing/false in case of strict? The union feels odd here, because the name implies things about the resolving of keys already.
What's the behaviour if none of the keys overlap?
Yeah union is wierd. Like should we even include non shared dimensions in the default output? What does a union mean accross dimensions?
Probably returning nothing
is best for strict, you're right.
Ok mostly done these. My main remaining question is if union
returns all dimensions available or just the shared dimensions. The name does kind of suggests it will return all - but currently it just returns shared dimensions
That's seems fine, the name is slightly confusing, but it's just about the extents, not about dimensions.
I've fixed a test for union (returning nothing
instead of ()
) for no shared dimensions and added docstrings for the strict
keyword. Feel free to merge if you agree.
This PR adds utility methods:
intersects
: returns aBool
(can we think of a better name more different tointersect
?intersect
returns the intersectionExtent
ornothing
if there is no intersection.union
gets the union extent. I'm not sure if it should include all dimensions or only the shared dimensions? what makes sense here.For this to work well, and for other uses in Rasters.jl/DimensionalData.jl, I also added Base methods and did some work on the type to make
Extent
more similar toNamedTuple
.Use of
Val
in keys is so all the named tuple indexing compiles away - which gives 15nsunion
andintersect
rather than300ns
.@evetion if you could have a look over this that would be great