[GRASS-SVN] r61158 - in grass/trunk/lib/python/temporal: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 4 10:54:55 PDT 2014
Author: huhabla
Date: 2014-07-04 10:54:55 -0700 (Fri, 04 Jul 2014)
New Revision: 61158
Added:
grass/trunk/lib/python/temporal/testsuite/
grass/trunk/lib/python/temporal/testsuite/unittests_register.py
grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py
grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py
Removed:
grass/trunk/lib/python/temporal/unittests_register.py
grass/trunk/lib/python/temporal/unittests_temporal_raster3d_algebra.py
grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py
Log:
Moved unittests of the temporal framework into a testsuite directory. The unittest_register.py test
was implemented to use the gunittest framework from Vaclav GSoC project.
Copied: grass/trunk/lib/python/temporal/testsuite/unittests_register.py (from rev 61157, grass/trunk/lib/python/temporal/unittests_register.py)
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_register.py (rev 0)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_register.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -0,0 +1,307 @@
+"""!Unit test to register raster maps with absolute and relative
+ time using tgis.register_maps_in_space_time_dataset()
+
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+import grass.script as grass
+import grass.temporal as tgis
+from gunittest.case import GrassTestCase
+import datetime
+
+class TestRegisterFunctions(GrassTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """!Initiate the temporal GIS and set the region
+ """
+ # Use always the current mapset as temporal database
+ cls.assertModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
+ tgis.init()
+ grass.overwrite = True
+ grass.use_temp_region()
+ cls.assertModule("g.region", n=80.0, s=0.0, e=120.0,
+ w=0.0, t=1.0, b=0.0, res=10.0)
+
+ def setUp(self):
+ """!Create the test maps and the space time raster datasets
+ """
+ self.assertModule("r.mapcalc", overwrite=True, quiet=True,
+ expression="register_map_1 = 1")
+ self.assertModule("r.mapcalc", overwrite=True, quiet=True,
+ expression="register_map_2 = 2")
+ self.assertEqual(ret, 0)
+
+
+ self.strds_abs = tgis.open_new_stds(name="register_test_abs", type="strds", temporaltype="absolute",
+ title="Test strds", descr="Test strds", semantic="field")
+ self.strds_rel = tgis.open_new_stds(name="register_test_rel", type="strds", temporaltype="relative",
+ title="Test strds", descr="Test strds", semantic="field")
+
+ def test_absolute_time_strds_1(self):
+ """!Test the registration of maps with absolute time in a
+ space time raster dataset
+ """
+ tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
+ maps="register_map_1,register_map_2",
+ start="2001-01-01", increment="1 day", interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+ self.strds_abs.select()
+ start, end = self.strds_abs.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+ def test_absolute_time_strds_2(self):
+ """!Test the registration of maps with absolute time in a
+ space time raster dataset.
+ The timestamps are set using the C-Interface beforehand, so that the register function needs
+ to read the timetsamp from the map metadata.
+ """
+
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001")
+ ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001")
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
+ maps="register_map_1,register_map_2")
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+ self.strds_abs.select()
+ start, end = self.strds_abs.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+ def test_absolute_time_1(self):
+ """!Test the registration of maps with absolute time
+ """
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2",
+ start="2001-01-01", increment="1 day", interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+ def test_absolute_time_2(self):
+ """!Test the registration of maps with absolute time
+ """
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2",
+ start="2001-01-01 10:30:01", increment="8 hours", interval=False)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
+
+ def test_absolute_time_3(self):
+ """!Test the registration of maps with absolute time.
+ The timestamps are set using the C-Interface beforehand, so that the register function needs
+ to read the timetsamp from the map metadata.
+ """
+
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001 10:30:01")
+ ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1 Jan 2001 18:30:01")
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2")
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
+
+ def test_relative_time_strds_1(self):
+ """!Test the registration of maps with relative time in a
+ space time raster dataset
+ """
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
+ maps="register_map_1,register_map_2", start=0,
+ increment=1, unit="day", interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 0)
+ self.assertEqual(end, 1)
+ self.assertEqual(unit, "day")
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1)
+ self.assertEqual(end, 2)
+ self.assertEqual(unit, "day")
+
+ self.strds_rel.select()
+ start, end, unit = self.strds_rel.get_relative_time()
+ self.assertEqual(start, 0)
+ self.assertEqual(end, 2)
+ self.assertEqual(unit, "day")
+
+ def test_relative_time_strds_2(self):
+ """!Test the registration of maps with relative time in a
+ space time raster dataset. The timetsamps are set for the maps using the
+ C-interface before registration.
+ """
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
+ ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
+ maps="register_map_1,register_map_2")
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1000000)
+ self.assertEqual(end, 1500000)
+ self.assertEqual(unit, "seconds")
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1500000)
+ self.assertEqual(end, 2000000)
+ self.assertEqual(unit, "seconds")
+
+ self.strds_rel.select()
+ start, end, unit = self.strds_rel.get_relative_time()
+ self.assertEqual(start, 1000000)
+ self.assertEqual(end, 2000000)
+ self.assertEqual(unit, "seconds")
+
+ def test_relative_time_1(self):
+ """!Test the registration of maps with relative time
+ """
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2",
+ start=0, increment=1, unit="day", interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 0)
+ self.assertEqual(end, 1)
+ self.assertEqual(unit, "day")
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1)
+ self.assertEqual(end, 2)
+ self.assertEqual(unit, "day")
+
+ def test_relative_time_2(self):
+ """!Test the registration of maps with relative time
+ """
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2",
+ start=1000000, increment=500000, unit="seconds", interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1000000)
+ self.assertEqual(end, 1500000)
+ self.assertEqual(unit, "seconds")
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1500000)
+ self.assertEqual(end, 2000000)
+ self.assertEqual(unit, "seconds")
+
+ def test_relative_time_3(self):
+ """!Test the registration of maps with relative time. The timetsamps are set beforhand using
+ the C-interface.
+ """
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
+ ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+ maps="register_map_1,register_map_2")
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1000000)
+ self.assertEqual(end, 1500000)
+ self.assertEqual(unit, "seconds")
+
+ map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+ map.select()
+ start, end, unit = map.get_relative_time()
+ self.assertEqual(start, 1500000)
+ self.assertEqual(end, 2000000)
+ self.assertEqual(unit, "seconds")
+
+ def tearDown(self):
+ """!Remove maps from temporal database
+ """
+ self.assertModule("t.unregister", maps="register_map_1,register_map_2", quiet=True)
+ self.assertModule("g.remove", rast="register_map_1,register_map_2", quiet=True)
+ self.strds_abs.delete()
+ self.strds_rel.delete()
+
+ @classmethod
+ def tearDownClass(cls):
+ """!Remove the temporary region
+ """
+ grass.del_temp_region()
+
+if __name__ == '__main__':
+ from gunittest.main import test
+ test()
+
+
Copied: grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py (from rev 61116, grass/trunk/lib/python/temporal/unittests_temporal_raster3d_algebra.py)
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py (rev 0)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -0,0 +1,84 @@
+"""!Unit test to register raster maps with absolute and relative
+ time using tgis.register_maps_in_space_time_dataset()
+
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+import grass.script
+import grass.temporal as tgis
+import unittest
+import datetime
+import os
+
+class TestRegisterFunctions(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """!Initiate the temporal GIS and set the region
+ """
+ tgis.init(True) # Raise on error instead of exit(1)
+ grass.script.use_temp_region()
+ ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
+ w=0.0, t=100.0, b=0.0, res=10.0)
+
+ ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+ ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+ ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+ ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+
+
+ tgis.open_new_stds(name="A", type="str3ds", temporaltype="absolute",
+ title="A", descr="A", semantic="field", overwrite=True)
+
+ tgis.register_maps_in_space_time_dataset(type="rast3d", name="A", maps="a1,a2,a3,a4",
+ start="2001-01-01", increment="1 day", interval=True)
+
+ def test_temporal_neighbors_1(self):
+ """Simple temporal neighborhood computation test"""
+ tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A[-1] + A[1]',
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="str3ds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
+ self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def test_temporal_neighbors_2(self):
+ """Simple temporal neighborhood computation test"""
+ tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A[0,0,0,-1] + A[0,0,0,1]',
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="str3ds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
+ self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def tearDown(self):
+ ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="D", quiet=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """!Remove the temporary region
+ """
+ ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="A", quiet=True)
+ grass.script.del_temp_region()
+
+if __name__ == '__main__':
+ unittest.main()
+
+
Copied: grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py (from rev 61116, grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py)
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py (rev 0)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -0,0 +1,374 @@
+"""!Unit test to register raster maps with absolute and relative
+ time using tgis.register_maps_in_space_time_dataset()
+
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+import grass.script
+import grass.temporal as tgis
+import unittest
+import datetime
+import os
+
+class TestRegisterFunctions(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """!Initiate the temporal GIS and set the region
+ """
+ tgis.init(True) # Raise on error instead of exit(1)
+ grass.script.use_temp_region()
+ ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
+ w=0.0, t=1.0, b=0.0, res=10.0)
+
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
+ ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+
+
+ tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+ title="A", descr="A", semantic="field", overwrite=True)
+ tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+ title="B", descr="B", semantic="field", overwrite=True)
+ tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+ title="B", descr="C", semantic="field", overwrite=True)
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
+ start="2001-01-01", increment="1 day", interval=True)
+ tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+ start="2001-01-01", increment="2 day", interval=True)
+
+ tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+ start="2001-01-02", increment="2 day", interval=True)
+
+
+ def test_temporal_conditional_time_dimension_bug(self):
+ """Testing the conditional time dimension bug, that uses the time
+ dimension of the conditional statement instead the time dimension
+ of the then/else statement."""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = if({contains}, B == 5, A - 1, A + 1)", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
+ self.assertEqual(D.metadata.get_max_max(), 5) # 4 + 1
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+ self.assertEqual( D.check_temporal_topology(), True)
+ self.assertEqual(D.get_granularity(), u'1 day')
+
+ def test_simple_arith_hash_1(self):
+ """Simple arithmetic test including the hash operator"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A + A{equal,=#}A', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2)
+ self.assertEqual(D.metadata.get_max_max(), 5)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+
+ def test_simple_arith_td_1(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2)
+ self.assertEqual(D.metadata.get_max_max(), 5)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_simple_arith_td_2(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 1)
+ self.assertEqual(D.metadata.get_max_max(), 4)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_simple_arith_td_3(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2)
+ self.assertEqual(D.metadata.get_max_max(), 5)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+
+ def test_simple_arith_td_4(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 1)
+ self.assertEqual(D.metadata.get_max_max(), 4)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+
+ def test_simple_arith_if_1(self):
+ """Simple arithmetic test with if condition"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = if({equal}, start_date() >= "2001-01-02", A + A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 3)
+ self.assertEqual(D.metadata.get_min_min(), 4)
+ self.assertEqual(D.metadata.get_max_max(), 8)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_simple_arith_if_2(self):
+ """Simple arithmetic test with if condition"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = if({equal}, A#A == 1, A - A)', basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 0)
+ self.assertEqual(D.metadata.get_max_max(), 0)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_complex_arith_if_1(self):
+ """Complex arithmetic test with if condition"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = if(start_date() < "2001-01-03" && A#A == 1, A{starts,=+}C, A{finishes,=+}C)', \
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 9) # 2 + 7 a2 + c1
+ self.assertEqual(D.metadata.get_max_max(), 10) # 3 + 7 a3 + c1
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def test_simple_arith_1(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {equal,*} A {equal,+} A", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2) # 1*1 + 1
+ self.assertEqual(D.metadata.get_max_max(), 20) # 4*4 + 4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_simple_arith_2(self):
+ """Simple arithmetic test that creates an empty strds"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {during,*} A {during,+} A", basename="d", overwrite=True)
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 0)
+
+ def test_simple_arith_3(self):
+ """Simple arithmetic test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A / A + A*A/A", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2) # 1/1 + 1*1/1
+ self.assertEqual(D.metadata.get_max_max(), 5) # 4/4 + 4*4/4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_intersection_1(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {equal,&+} B", basename="d", overwrite=True)
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 0)
+
+ def test_temporal_intersection_2(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {during,&+} B", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
+ self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_intersection_3(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {starts,&+} B", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
+ self.assertEqual(D.metadata.get_max_max(), 9) # 3 + 6
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def test_temporal_intersection_4(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {finishes,&+} B", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 7) # 2 + 5
+ self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_intersection_5(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = A {starts|finishes,&+} B", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
+ self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_intersection_6(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = B {overlaps,|+} C", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 1)
+ self.assertEqual(D.metadata.get_min_min(), 12) # 5 + 7
+ self.assertEqual(D.metadata.get_max_max(), 12) # 5 + 7
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def test_temporal_intersection_7(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = B {overlapped,|+} C", basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 1)
+ self.assertEqual(D.metadata.get_min_min(), 13) # 6 + 7
+ self.assertEqual(D.metadata.get_max_max(), 13) # 6 + 7
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_intersection_8(self):
+ """Simple temporal intersection test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A {during,=+} buff_t(C, "1 day") ',
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 8) # 1 + 7 a1 + c1
+ self.assertEqual(D.metadata.get_max_max(), 11) # 4 + 7 a4 + c1
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+ def test_temporal_neighbors_1(self):
+ """Simple temporal neighborhood computation test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A[-1] + A[1]',
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
+ self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def test_temporal_neighbors_2(self):
+ """Simple temporal neighborhood computation test"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A[0,0,-1] + A[0,0,1]',
+ basename="d", overwrite=True)
+
+ D = tgis.open_old_stds("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 2)
+ self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
+ self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 2))
+ self.assertEqual(end, datetime.datetime(2001, 1, 4))
+
+ def tearDown(self):
+ ret = grass.script.run_command("t.remove", flags="rf", input="D", quiet=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """!Remove the temporary region
+ """
+ ret = grass.script.run_command("t.remove", flags="rf", input="A,B,C", quiet=True)
+ grass.script.del_temp_region()
+
+if __name__ == '__main__':
+ unittest.main()
+
+
Deleted: grass/trunk/lib/python/temporal/unittests_register.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_register.py 2014-07-04 16:44:59 UTC (rev 61157)
+++ grass/trunk/lib/python/temporal/unittests_register.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -1,308 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative
- time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script as grass
-import grass.temporal as tgis
-import unittest
-import datetime
-
-class TestRegisterFunctions(unittest.TestCase):
-
- @classmethod
- def setUpClass(cls):
- """!Initiate the temporal GIS and set the region
- """
- # Use always the current mapset as temporal database
- ret = grass.run_command("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
- tgis.init()
- grass.overwrite = True
- grass.use_temp_region()
- ret = grass.run_command("g.region", n=80.0, s=0.0, e=120.0,
- w=0.0, t=1.0, b=0.0, res=10.0)
-
- def setUp(self):
- """!Create the test maps and the space time raster datasets
- """
- ret = 0
- ret += grass.run_command("r.mapcalc", overwrite=True, quiet=True,
- expression="register_map_1 = 1")
- ret += grass.run_command("r.mapcalc", overwrite=True, quiet=True,
- expression="register_map_2 = 2")
- self.assertEqual(ret, 0)
-
-
- self.strds_abs = tgis.open_new_stds(name="register_test_abs", type="strds", temporaltype="absolute",
- title="Test strds", descr="Test strds", semantic="field")
- self.strds_rel = tgis.open_new_stds(name="register_test_rel", type="strds", temporaltype="relative",
- title="Test strds", descr="Test strds", semantic="field")
-
- def test_absolute_time_strds_1(self):
- """!Test the registration of maps with absolute time in a
- space time raster dataset
- """
- tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
- maps="register_map_1,register_map_2",
- start="2001-01-01", increment="1 day", interval=True)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
- self.strds_abs.select()
- start, end = self.strds_abs.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
- def test_absolute_time_strds_2(self):
- """!Test the registration of maps with absolute time in a
- space time raster dataset.
- The timestamps are set using the C-Interface beforehand, so that the register function needs
- to read the timetsamp from the map metadata.
- """
-
- ciface = tgis.get_tgis_c_library_interface()
- ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001")
- ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001")
-
- tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
- maps="register_map_1,register_map_2")
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
- self.strds_abs.select()
- start, end = self.strds_abs.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
- def test_absolute_time_1(self):
- """!Test the registration of maps with absolute time
- """
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2",
- start="2001-01-01", increment="1 day", interval=True)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
- def test_absolute_time_2(self):
- """!Test the registration of maps with absolute time
- """
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2",
- start="2001-01-01 10:30:01", increment="8 hours", interval=False)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
-
- def test_absolute_time_3(self):
- """!Test the registration of maps with absolute time.
- The timestamps are set using the C-Interface beforehand, so that the register function needs
- to read the timetsamp from the map metadata.
- """
-
- ciface = tgis.get_tgis_c_library_interface()
- ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001 10:30:01")
- ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1 Jan 2001 18:30:01")
-
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2")
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end = map.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
-
- def test_relative_time_strds_1(self):
- """!Test the registration of maps with relative time in a
- space time raster dataset
- """
-
- tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
- maps="register_map_1,register_map_2", start=0,
- increment=1, unit="day", interval=True)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 0)
- self.assertEqual(end, 1)
- self.assertEqual(unit, "day")
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1)
- self.assertEqual(end, 2)
- self.assertEqual(unit, "day")
-
- self.strds_rel.select()
- start, end, unit = self.strds_rel.get_relative_time()
- self.assertEqual(start, 0)
- self.assertEqual(end, 2)
- self.assertEqual(unit, "day")
-
- def test_relative_time_strds_2(self):
- """!Test the registration of maps with relative time in a
- space time raster dataset. The timetsamps are set for the maps using the
- C-interface before registration.
- """
- ciface = tgis.get_tgis_c_library_interface()
- ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
- ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
-
- tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
- maps="register_map_1,register_map_2")
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1000000)
- self.assertEqual(end, 1500000)
- self.assertEqual(unit, "seconds")
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1500000)
- self.assertEqual(end, 2000000)
- self.assertEqual(unit, "seconds")
-
- self.strds_rel.select()
- start, end, unit = self.strds_rel.get_relative_time()
- self.assertEqual(start, 1000000)
- self.assertEqual(end, 2000000)
- self.assertEqual(unit, "seconds")
-
- def test_relative_time_1(self):
- """!Test the registration of maps with relative time
- """
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2",
- start=0, increment=1, unit="day", interval=True)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 0)
- self.assertEqual(end, 1)
- self.assertEqual(unit, "day")
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1)
- self.assertEqual(end, 2)
- self.assertEqual(unit, "day")
-
- def test_relative_time_2(self):
- """!Test the registration of maps with relative time
- """
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2",
- start=1000000, increment=500000, unit="seconds", interval=True)
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1000000)
- self.assertEqual(end, 1500000)
- self.assertEqual(unit, "seconds")
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1500000)
- self.assertEqual(end, 2000000)
- self.assertEqual(unit, "seconds")
-
- def test_relative_time_3(self):
- """!Test the registration of maps with relative time. The timetsamps are set beforhand using
- the C-interface.
- """
- ciface = tgis.get_tgis_c_library_interface()
- ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
- ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
-
- tgis.register_maps_in_space_time_dataset(type="rast", name=None,
- maps="register_map_1,register_map_2")
-
- map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1000000)
- self.assertEqual(end, 1500000)
- self.assertEqual(unit, "seconds")
-
- map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
- map.select()
- start, end, unit = map.get_relative_time()
- self.assertEqual(start, 1500000)
- self.assertEqual(end, 2000000)
- self.assertEqual(unit, "seconds")
-
- def tearDown(self):
- """!Remove maps from temporal database
- """
- ret = grass.run_command("t.unregister", maps="register_map_1,register_map_2", quiet=True)
- ret = grass.run_command("g.remove", rast="register_map_1,register_map_2", quiet=True)
- self.assertEqual(ret, 0)
- self.strds_abs.delete()
- self.strds_rel.delete()
-
- @classmethod
- def tearDownClass(cls):
- """!Remove the temporary region
- """
- grass.del_temp_region()
-
-if __name__ == '__main__':
- unittest.main()
-
-
Deleted: grass/trunk/lib/python/temporal/unittests_temporal_raster3d_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_temporal_raster3d_algebra.py 2014-07-04 16:44:59 UTC (rev 61157)
+++ grass/trunk/lib/python/temporal/unittests_temporal_raster3d_algebra.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -1,84 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative
- time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script
-import grass.temporal as tgis
-import unittest
-import datetime
-import os
-
-class TestRegisterFunctions(unittest.TestCase):
-
- @classmethod
- def setUpClass(cls):
- """!Initiate the temporal GIS and set the region
- """
- tgis.init(True) # Raise on error instead of exit(1)
- grass.script.use_temp_region()
- ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
- w=0.0, t=100.0, b=0.0, res=10.0)
-
- ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
- ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
- ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
- ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
-
-
- tgis.open_new_stds(name="A", type="str3ds", temporaltype="absolute",
- title="A", descr="A", semantic="field", overwrite=True)
-
- tgis.register_maps_in_space_time_dataset(type="rast3d", name="A", maps="a1,a2,a3,a4",
- start="2001-01-01", increment="1 day", interval=True)
-
- def test_temporal_neighbors_1(self):
- """Simple temporal neighborhood computation test"""
- tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A[-1] + A[1]',
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="str3ds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
- self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def test_temporal_neighbors_2(self):
- """Simple temporal neighborhood computation test"""
- tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A[0,0,0,-1] + A[0,0,0,1]',
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="str3ds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
- self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def tearDown(self):
- ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="D", quiet=True)
-
- @classmethod
- def tearDownClass(cls):
- """!Remove the temporary region
- """
- ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="A", quiet=True)
- grass.script.del_temp_region()
-
-if __name__ == '__main__':
- unittest.main()
-
-
Deleted: grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-07-04 16:44:59 UTC (rev 61157)
+++ grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-07-04 17:54:55 UTC (rev 61158)
@@ -1,374 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative
- time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script
-import grass.temporal as tgis
-import unittest
-import datetime
-import os
-
-class TestRegisterFunctions(unittest.TestCase):
-
- @classmethod
- def setUpClass(cls):
- """!Initiate the temporal GIS and set the region
- """
- tgis.init(True) # Raise on error instead of exit(1)
- grass.script.use_temp_region()
- ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
- w=0.0, t=1.0, b=0.0, res=10.0)
-
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
- ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
-
-
- tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
- title="A", descr="A", semantic="field", overwrite=True)
- tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
- title="B", descr="B", semantic="field", overwrite=True)
- tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
- title="B", descr="C", semantic="field", overwrite=True)
-
- tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
- start="2001-01-01", increment="1 day", interval=True)
- tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
- start="2001-01-01", increment="2 day", interval=True)
-
- tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
- start="2001-01-02", increment="2 day", interval=True)
-
-
- def test_temporal_conditional_time_dimension_bug(self):
- """Testing the conditional time dimension bug, that uses the time
- dimension of the conditional statement instead the time dimension
- of the then/else statement."""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = if({contains}, B == 5, A - 1, A + 1)", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
- self.assertEqual(D.metadata.get_max_max(), 5) # 4 + 1
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
- self.assertEqual( D.check_temporal_topology(), True)
- self.assertEqual(D.get_granularity(), u'1 day')
-
- def test_simple_arith_hash_1(self):
- """Simple arithmetic test including the hash operator"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A + A{equal,=#}A', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 2)
- self.assertEqual(D.metadata.get_max_max(), 5)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
- def test_simple_arith_td_1(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 2)
- self.assertEqual(D.metadata.get_max_max(), 5)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_simple_arith_td_2(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 1)
- self.assertEqual(D.metadata.get_max_max(), 4)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_simple_arith_td_3(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 2)
- self.assertEqual(D.metadata.get_max_max(), 5)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
- def test_simple_arith_td_4(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 1)
- self.assertEqual(D.metadata.get_max_max(), 4)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
- def test_simple_arith_if_1(self):
- """Simple arithmetic test with if condition"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = if({equal}, start_date() >= "2001-01-02", A + A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 3)
- self.assertEqual(D.metadata.get_min_min(), 4)
- self.assertEqual(D.metadata.get_max_max(), 8)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_simple_arith_if_2(self):
- """Simple arithmetic test with if condition"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = if({equal}, A#A == 1, A - A)', basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 0)
- self.assertEqual(D.metadata.get_max_max(), 0)
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_complex_arith_if_1(self):
- """Complex arithmetic test with if condition"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = if(start_date() < "2001-01-03" && A#A == 1, A{starts,=+}C, A{finishes,=+}C)', \
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 9) # 2 + 7 a2 + c1
- self.assertEqual(D.metadata.get_max_max(), 10) # 3 + 7 a3 + c1
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def test_simple_arith_1(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {equal,*} A {equal,+} A", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 2) # 1*1 + 1
- self.assertEqual(D.metadata.get_max_max(), 20) # 4*4 + 4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_simple_arith_2(self):
- """Simple arithmetic test that creates an empty strds"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {during,*} A {during,+} A", basename="d", overwrite=True)
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 0)
-
- def test_simple_arith_3(self):
- """Simple arithmetic test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A / A + A*A/A", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 2) # 1/1 + 1*1/1
- self.assertEqual(D.metadata.get_max_max(), 5) # 4/4 + 4*4/4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_intersection_1(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {equal,&+} B", basename="d", overwrite=True)
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 0)
-
- def test_temporal_intersection_2(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {during,&+} B", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
- self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_intersection_3(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {starts,&+} B", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
- self.assertEqual(D.metadata.get_max_max(), 9) # 3 + 6
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def test_temporal_intersection_4(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {finishes,&+} B", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 7) # 2 + 5
- self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_intersection_5(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = A {starts|finishes,&+} B", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
- self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_intersection_6(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = B {overlaps,|+} C", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 1)
- self.assertEqual(D.metadata.get_min_min(), 12) # 5 + 7
- self.assertEqual(D.metadata.get_max_max(), 12) # 5 + 7
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def test_temporal_intersection_7(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression="D = B {overlapped,|+} C", basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 1)
- self.assertEqual(D.metadata.get_min_min(), 13) # 6 + 7
- self.assertEqual(D.metadata.get_max_max(), 13) # 6 + 7
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_intersection_8(self):
- """Simple temporal intersection test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A {during,=+} buff_t(C, "1 day") ',
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 4)
- self.assertEqual(D.metadata.get_min_min(), 8) # 1 + 7 a1 + c1
- self.assertEqual(D.metadata.get_max_max(), 11) # 4 + 7 a4 + c1
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 1))
- self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
- def test_temporal_neighbors_1(self):
- """Simple temporal neighborhood computation test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A[-1] + A[1]',
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
- self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def test_temporal_neighbors_2(self):
- """Simple temporal neighborhood computation test"""
- tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
- tra.parse(expression='D = A[0,0,-1] + A[0,0,1]',
- basename="d", overwrite=True)
-
- D = tgis.open_old_stds("D", type="strds")
- D.select()
- self.assertEqual(D.metadata.get_number_of_maps(), 2)
- self.assertEqual(D.metadata.get_min_min(), 4) # 1 + 3
- self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
- start, end = D.get_absolute_time()
- self.assertEqual(start, datetime.datetime(2001, 1, 2))
- self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
- def tearDown(self):
- ret = grass.script.run_command("t.remove", flags="rf", input="D", quiet=True)
-
- @classmethod
- def tearDownClass(cls):
- """!Remove the temporary region
- """
- ret = grass.script.run_command("t.remove", flags="rf", input="A,B,C", quiet=True)
- grass.script.del_temp_region()
-
-if __name__ == '__main__':
- unittest.main()
-
-
More information about the grass-commit
mailing list