I imagine the best test will need pretty low level access to the cellhd structure to look at the compression flags. Is that what you mean? Or would a better way include looking at the output of r.compress
?
On Fri, Oct 2, 2015 at 7:12 PM, Seth Price <seth@planet.com> wrote:
I imagine the best test will need pretty low level access to the cellhd
structure to look at the compression flags. Is that what you mean? Or would
a better way include looking at the output of `r.compress`?
Yes, best would be to test the individual functions on the lowest level
(lib/raster3d and raster3d/r3.flow). However, this is hard to do (you need
to write a C program* and implement all tests yourself). I suggest to start
with high level tests; this is much easier (you need to write a script
ideally using existing Python packages).
Comparing r.univar output for a raster map before and after r.compress
execution sounds like a good start. For the testing framework, the right
approach is to copy and existing map to the current Mapset, run r.univar to
get the output, run r.compress, run r.univar again and diff the results.
This can be done in Bash or Python; Bash looks simpler at the beginning,
but existing functionally in Python (esp. the gunittest package) will make
things easier at the end.
Vaclav
Some gunittest references:
https://grass.osgeo.org/grass71/manuals/libpython/gunittest_testing.html#tests-of-grass-modules
https://grass.osgeo.org/grass71/manuals/libpython/gunittest.html#gunittest.case.TestCase.runModule
https://grass.osgeo.org/grass71/manuals/libpython/gunittest.html#gunittest.case.TestCase.assertModuleKeyValue
* Parts of library which are available through ctypes can be also tested
relatively easily in Python without a need to write a wrapper C program.
On Sat, Oct 3, 2015 at 5:05 PM, Vaclav Petras <wenzeslaus@gmail.com> wrote:
On Fri, Oct 2, 2015 at 7:12 PM, Seth Price <seth@planet.com> wrote:
...
I suggest to start
with high level tests; this is much easier (you need to write a script
ideally using existing Python packages).
Suggestion for a test:
What about generating an uncompressed map (actually 3: Int, Float,
Double prec), calculate md5 checksums (get through: g.extension
g.compare.md5) then compress it, uncompress it, recalculate md5 and
compare to the previously calculated values.
Markus
On Sat, Oct 3, 2015 at 12:19 PM, Markus Neteler <neteler@osgeo.org> wrote:
On Sat, Oct 3, 2015 at 5:05 PM, Vaclav Petras <wenzeslaus@gmail.com> wrote:
On Fri, Oct 2, 2015 at 7:12 PM, Seth Price <seth@planet.com> wrote:
…
I suggest to start
with high level tests; this is much easier (you need to write a script
ideally using existing Python packages).Suggestion for a test:
What about generating an uncompressed map (actually 3: Int, Float,
Double prec), calculate md5 checksums (get through: g.extension
g.compare.md5) then compress it, uncompress it, recalculate md5 and
compare to the previously calculated values.
Good idea. At least for int/CELL it should always work. Unfortunately, the functionality is not yet available in gunittest. Hence, g.compare.md5 is necessary. The functionality is there only for files (not rasters).
What you can do now with gunittest is assertRastersNoDifference which diffs two rasters in r.mapcalc and compares the r.univar result with predefined statistics (apparently more complex).
In any case, small random (or imported) data or existing data (from basic NC Location) should be used.