[GRASS-git] [OSGeo/grass] 494713: db.univar: Ignore rows with NULLs with -e (#1341)

Vaclav Petras noreply at github.com
Fri Feb 19 09:35:42 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/OSGeo/grass
  Commit: 49471321fa4dea3357659e1a934dd05f4e01420a
      https://github.com/OSGeo/grass/commit/49471321fa4dea3357659e1a934dd05f4e01420a
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M scripts/db.univar/db.univar.py
    M scripts/db.univar/testsuite/test_db_univar.py

  Log Message:
  -----------
  db.univar: Ignore rows with NULLs with -e (#1341)

When value in a row is NULL, basic statistics ignore the rows
(e.g., not counted in N), however,
prior to this PR, the extended stats (-e) were processing all rows.
This was causing two issues:
1. db.univar/v.db.univar failed with 'could not convert string to float', or
2. wrong results when number of NULLs happened to be less than N/4.

Now the NULL values (represented as empty strings) are always skipped in
the same was as for the basic stats,
i.e., not being counted towards the quartiles anymore (which is what was
causing the wrong results when number of NULL values was low).
With where conditions such as 'IS NOT NULL' neither of these issues emerged.
Now a similar condition is in the code for extended stats too.

This PR refactors the rstrip calls, so they are in the code only once per loop.

The test now tests a run with both basic and extended stats with data
which contains NULL values. Actual values are not tested as before,
but setup and teardown steps are cleaned up (e.g. not trying to delete
elevation raster).




More information about the grass-commit mailing list