Skip to content

Commit

Permalink
r.centroids: Fix module and test (#815)
Browse files Browse the repository at this point in the history
* Fixes wrong variable names in the r.centroids code.
* Fixes test for r.centroids.
* Fixes also r.sample.category test by defining an appropriate computational region. (Unrelated)
  • Loading branch information
petrasovaa committed Oct 8, 2022
1 parent f2d9ada commit be22388
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/raster/r.centroids/r.centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def main():
options, flags = gs.parser()

# options and flags into variables
ipl = options["input"]
opl = options["output"]
in_raster = options["input"]
out_vector = options["output"]
gs.run_command(
"r.volume",
quiet=True,
Expand Down
5 changes: 2 additions & 3 deletions src/raster/r.centroids/testsuite/test_r_centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ def setUpClass(cls):
# to not override mapset's region (which might be used by other tests)
cls.use_temp_region()
# cls.runModule or self.runModule is used for general module calls
cls.runModule("g.region", raster="basins")
cls.runModule("g.region", raster="basin")

@classmethod
def tearDownClass(cls):
"""Remove temporary region"""
cls.del_temp_region()

@classmethod
def tearDown(self):
"""
Remove the outputs created from the centroids module
Expand All @@ -51,7 +50,7 @@ def test_output(self):
# assertModule is used to call module which we test
# we expect module to finish successfully
self.assertModule(
"r.centroids", input="basins", output=self.centroids, overwrite=True
"r.centroids", input="basin", output=self.centroids, overwrite=True
)

self.assertVectorEqualsAscii(
Expand Down
1 change: 1 addition & 0 deletions src/raster/r.sample.category/testsuite/test_numbers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
num_points_expected=42
num_cats_expected=7

g.region raster=landclass96
r.sample.category input=landclass96 output=landclass_points npoints=6 --o

num_points=$(v.db.select -c landclass_points | wc -l)
Expand Down

0 comments on commit be22388

Please sign in to comment.