You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if we have an integer value z, we check to see if it's a NoData value by checking equality against NODATA (which is Int.MinValue). For Doubles, we need to check if the value is NaN (using java.lang.Double.isNaN). This can cause issues when users forget which value type they are working with.
For example,
valr:Raster= getRaster(...)
valvInt= r.get(0,0)
if(vInt ==NODATA) {
println("First value does not have data")
} else {
println("First value has data")
}
valvDouble= r.getDouble(0,0)
if(java.lang.Double.isNaN(vDouble)) {
println("First value does not have data")
} else {
println("First value has data")
}
You'll see code like this all over the codebase. It's important to remember that, if it's a Double, use the Double version of checking against NoData, and if it's an Int, use the Int. Bugs have arisen many times from using the incorrect method for checking for a NoData value.
To alleviate this situation, we could create an implicit Value class from Ints and Doubles that had a .isNoData method, which would be @inlined. This would evaluate to the correct check, and so all places where there was an z == NODATA or java.lang.Double.isNaN(z) call we could replace with z.isNoData.
This issue includes grepping through the whole codebase and replacing any z == NODATA or java.lang.Double.isNaN(z) call with z.isNoData.
The text was updated successfully, but these errors were encountered:
See #324 comments for a discussion about this.
Currently, if we have an integer value z, we check to see if it's a NoData value by checking equality against NODATA (which is Int.MinValue). For Doubles, we need to check if the value is NaN (using java.lang.Double.isNaN). This can cause issues when users forget which value type they are working with.
For example,
You'll see code like this all over the codebase. It's important to remember that, if it's a Double, use the Double version of checking against NoData, and if it's an Int, use the Int. Bugs have arisen many times from using the incorrect method for checking for a NoData value.
To alleviate this situation, we could create an implicit Value class from Ints and Doubles that had a .isNoData method, which would be @inlined. This would evaluate to the correct check, and so all places where there was an
z == NODATA
orjava.lang.Double.isNaN(z)
call we could replace withz.isNoData
.This issue includes grepping through the whole codebase and replacing any
z == NODATA
orjava.lang.Double.isNaN(z)
call withz.isNoData
.The text was updated successfully, but these errors were encountered: