Opened 11 years ago
Last modified 9 years ago
#2269 new defect
r.univar silent instead of NaN
Reported by: | neteler | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 6.4.6 |
Component: | Raster | Version: | svn-releasebranch64 |
Keywords: | r.univar | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
r.univar should not remain silent when the computational region is only containing NULL cells. Instead "NaN" should be printed as result for the individual min, max, etc values.
GRASS 6.4.4svn (nc_spm_08):~ > g.region n=1 s=0 w=0 e=1 res=0.5 -p projection: 99 (Lambert Conformal Conic) zone: 0 datum: nad83 ellipsoid: a=6378137 es=0.006694380022900787 north: 1 south: 0 west: 0 east: 1 nsres: 0.5 ewres: 0.5 rows: 2 cols: 2 cells: 4 GRASS 6.4.4svn (nc_spm_08):~ > r.univar elevation 100% GRASS 6.4.4svn (nc_spm_08):~ > r.univar elevation -g GRASS 6.4.4svn (nc_spm_08):~ >
The issue is in r.univar, stats.c line 123. However, not that easy to fix since sometimes zones are considered, sometimes not.
Change History (4)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Do we have a standard how to represent NaN (not a number) in GRASS (as a text)?
For example in Python:
>>> a = float('nan') >>> a nan >>> a = float('NaN') >>> a nan >>> a = float('NAN') >>> a nan >>> a = float('nAn') >>> a nan
(And the same for inf
.)
Is it even appropriate that r.univar
would give NaNs? Wouldn't be non-zero return code and a error message more appropriate? (Perhaps not, but we should consider the options.)
comment:3 by , 10 years ago
The same applies for r3.univar
.
It is especially bad for -g
flag where module is used as a part of something bigger and the caller expects valid output when module ended with non-zero return code. Now it can end in the best case report and empty output when expecting something but no better error message can be provided.
See also testing framework (gunittest) where r.univar
and r3.univar
are used to check map properties and thus some informative error messages needs to be provided when something is wrong. See particularly r61459.
comment:4 by , 9 years ago
Milestone: | 6.4.4 → 6.4.6 |
---|
hmm, I thought there was already a ticket for this. guess not.