Skip to content

Commit 01aba18

Browse files
authored
r.tpi use 'int' instead of np.int; add test (#974)
1 parent 26df529 commit 01aba18

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/raster/r.tpi/r.tpi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def main():
9393

9494
# calculate radi for generalization
9595
radi = np.logspace(
96-
np.log(minradius), np.log(maxradius), steps, base=np.exp(1), dtype=np.int
96+
np.log(minradius), np.log(maxradius), steps, base=np.exp(1), dtype="int"
9797
)
9898
radi = np.unique(radi)
9999
sizes = radi * 2 + 1
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
MODULE: Test of r.tpi
5+
6+
AUTHOR(S): Steven Pawley <dr.stevenpawley gmail com>
7+
8+
PURPOSE: Test of r.tpi basic operation
9+
10+
COPYRIGHT: (C) 2022 by Steven Pawley and the GRASS Development Team
11+
12+
This program is free software under the GNU General Public
13+
License (>=v2). Read the file COPYING that comes with GRASS
14+
for details.
15+
"""
16+
import grass.script as gs
17+
18+
from grass.gunittest.case import TestCase
19+
from grass.gunittest.main import test
20+
21+
22+
class TestClassification(TestCase):
23+
"""Test basic operation of r.tpi"""
24+
25+
# input rasters
26+
dem_map = "elevation"
27+
tpi_map = "mtpi"
28+
29+
@classmethod
30+
def setUpClass(cls):
31+
"""Setup that is required for all tests"""
32+
cls.use_temp_region()
33+
cls.runModule("g.region", raster=cls.dem_map)
34+
35+
@classmethod
36+
def tearDownClass(cls):
37+
"""Remove the temporary region (and anything else we created)"""
38+
cls.del_temp_region()
39+
cls.runModule("g.remove", flags="f", type="raster", name=cls.tpi_map)
40+
41+
def test_mtpi(self):
42+
"""Checks that the output is created"""
43+
# train model
44+
self.assertModule(
45+
"r.tpi",
46+
input=self.dem_map,
47+
minradius=1,
48+
maxradius=31,
49+
steps=5,
50+
output=self.tpi_map,
51+
)
52+
self.assertRasterExists(self.tpi_map, msg="Output was not created")
53+
54+
55+
if __name__ == "__main__":
56+
test()

0 commit comments

Comments
 (0)