Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

layer1[layer2] can only return exactly the same layer #107

Closed
gabrieldansereau opened this issue Jun 4, 2021 · 0 comments · Fixed by #106
Closed

layer1[layer2] can only return exactly the same layer #107

gabrieldansereau opened this issue Jun 4, 2021 · 0 comments · Fixed by #106

Comments

@gabrieldansereau
Copy link
Member

Unless there's something I don't see, our current overload for getindex(layer1, layer2) (used when calling layer1[layer2]) can only return exactly the same layer as layer1, which makes it a bit useless.

Calling _layers_are_compatible(layer1, layer2) means the overload only works when the two layers have the same size AND bounding coordinates. But then we return layer1 with the bounding coordinates of layer2, which are necessarily the same as layer[1].

I think this overload would be more useful if it allowed to subset a layer based on another layer if both have the same stride and the 2nd one is entirely contained in the first one, as in the example below.

l1, l2 = SimpleSDMPredictor(WorldClim, BioClim, 1:2)
l3 = SimpleSDMPredictor(WorldClim, BioClim, 1; left = -145.0, right = -50.0, bottom = 20.0, top = 75.0)
stride(l1) == stride(l3) # same stride

l4 = l1[l2] # works
l4 == l1 # but it's exactly the same

l5 = l1[l3] # doesn't work as layers have different sizes, but should work
l5 == l3 # should return true
@gabrieldansereau gabrieldansereau changed the title layer1[layer2] can only return exactly the same layer layer1[layer2] can only return exactly the same layer Jun 4, 2021
@gabrieldansereau gabrieldansereau linked a pull request Jun 4, 2021 that will close this issue
19 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant