-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix _extent
when called on an extent
#852
Changes from 6 commits
1fea23f
96a0e22
59d7b12
749dd33
1125693
5312187
e8e0add
3aff33f
adf1aac
87a371f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -762,3 +762,10 @@ test = rebuild(ga; name = :test) | |
@test_throws "strictly positive" Rasters.sample(StableRNG(123), test, 3, skipmissing = true, replace = false) | ||
@test_throws "Cannot draw" Rasters.sample(StableRNG(123), test, 5, replace = false) | ||
end | ||
|
||
@testset "extent" begin | ||
ga = Raster(A, (X(1.0:1:2.0), Y(1.0:1:2.0)); missingval=missing) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also test this for an Extent, that is based on float32 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tiemvanderdeure we need this to merge There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought you said you wanted to fix that in a separate PR? Right now this would fail, I guess? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it? I don't totally understand, won't it just convert to Float64? We just need to check the input works There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I meant is the |
||
ext = extent(ga) | ||
@test ext === Extent(X=(1.0,2.0), Y=(1.0,2.0)) | ||
@test Rasters._extent(ext) === ext | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this one, but do we really want to force the convert to float64? This will mean that
rasterize
with an extent in integers or float32 will return float64 dimensionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We convert everything else already. I think there were 2 reasons - accuracy of ext + res/size is much better with Float64, and it reduces compilation for force the extent to always be the same object.
But we can change everything back to allow
Float32
in another PR if you think its necessaryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want
_extent(ext::Extent; kw...) = Extents.Extent(X=ext.X, Y=ext.Y)
. Ifext
doesn't have an X or Y field it will give a reasonable error message.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay if it gets converted elsewhere then nevermind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually want to force
::XYExtent
on the method to be consistentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have the Float32 converstion elsewhere but lets conform with the current setup for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but without that my actual example failed when I used a Float32 extent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked and I don't think this gets converted anywhere else, though. With the above definition of _extent I can rasterize to Float32 dimensions no problem. I haven't run into this yet, but don't see why we shouldn't allow it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I didn't realize
XYExtent
has the Float64 type hard-coded in. Guess that is needed for type stability?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think type stability was one reason, this recursive calls were not compiling away and forcing the type fixes that