[GRASS-SVN] r66739 - grass/trunk/temporal/t.rast.to.rast3/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 4 03:09:30 PST 2015


Author: huhabla
Date: 2015-11-04 03:09:30 -0800 (Wed, 04 Nov 2015)
New Revision: 66739

Modified:
   grass/trunk/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py
Log:
temporal modules: Fixed test for t.rast.to.rast3

Modified: grass/trunk/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py	2015-11-04 10:12:25 UTC (rev 66738)
+++ grass/trunk/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py	2015-11-04 11:09:30 UTC (rev 66739)
@@ -15,10 +15,13 @@
 
 class TestSTRDSToRast3(TestCase):
 
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+
     def setUp(self):
         """Create input data
         """
-        self.use_temp_region()
         self.runModule("g.gisenv",  set="TGIS_USE_CURRENT_MAPSET=1")
         self.runModule("g.region",  s=0,  n=80,  w=0,  e=120,  b=0,  t=50,  res=10,  res3=10)
 
@@ -66,35 +69,23 @@
 
     def tearDown(self):
         """Remove generated data"""
-        #self.runModule("t.remove",  flags="rf",  type="strds",  
-        #                           inputs="precip_i,precip_f,precip_d")
-        #self.runModule('g.remove', type='raster', pattern='prec_*', flags='f')
-        self.del_temp_region()
+        self.runModule("t.remove",  flags="rf",  type="strds",
+                       inputs="precip_i,precip_f,precip_d")
+        self.runModule('g.remove', type='raster', pattern='prec_*', flags='f')
+        self.runModule('g.remove', type='raster_3d', pattern='precip_*', flags='f')
 
-    def otest_3m(self):
+    @classmethod
+    def tearDownClass(cls):
+        """Unset region"""
+        cls.del_temp_region()
+
+    def test_3m(self):
         """Convert STRDS into 3d raster map, granularity 3 months"""
 
         self.assertModule("t.rast.to.rast3",  input="precip_i",  output="precip_i")
         self.assertModule("t.rast.to.rast3",  input="precip_f",  output="precip_f")
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
 
-        univar_string="""n=576
-                        null_cells=0
-                        cells=576
-                        min=100
-                        max=600
-                        range=500
-                        mean=350
-                        mean_of_abs=350
-                        stddev=170.782512765993
-                        variance=29166.6666666667
-                        coeff_var=48.7950036474267
-                        sum=201600"""
-
-        self.assertRaster3dFitsUnivar(raster="precip_i", reference=univar_string, precision=2)
-        self.assertRaster3dFitsUnivar(raster="precip_f", reference=univar_string, precision=2)
-        self.assertRaster3dFitsUnivar(raster="precip_d", reference=univar_string, precision=2)
-
         tinfo_string="""north=80
                         south=0
                         east=120
@@ -220,36 +211,42 @@
 
 class TestSTRDSToRast3MultiGran(TestCase):
 
-    def setUp(self):
+    @classmethod
+    def setUpClass(cls):
         """Create input data
         """
-        self.use_temp_region()
-        self.runModule("g.gisenv",  set="TGIS_USE_CURRENT_MAPSET=1")
-        self.runModule("g.region",  s=0,  n=80,  w=0,  e=120,  b=0,  t=50,  res=10,  res3=10)
+        cls.use_temp_region()
+        cls.runModule("g.gisenv",  set="TGIS_USE_CURRENT_MAPSET=1")
+        cls.runModule("g.region",  s=0,  n=80,  w=0,  e=120,  b=0,  t=50,  res=10,  res3=10)
         
-        self.runModule("r.mapcalc", expression="prec_1d = 100.0")
-        self.runModule("r.mapcalc", expression="prec_2d = 200.0")
-        self.runModule("r.mapcalc", expression="prec_3d = 300.0")
-        self.runModule("r.mapcalc", expression="prec_4d = 400.0")
-        self.runModule("r.mapcalc", expression="prec_5d = 500.0")
-        self.runModule("r.mapcalc", expression="prec_6d = 600.0")
+        cls.runModule("r.mapcalc", expression="prec_1d = 100.0")
+        cls.runModule("r.mapcalc", expression="prec_2d = 200.0")
+        cls.runModule("r.mapcalc", expression="prec_3d = 300.0")
+        cls.runModule("r.mapcalc", expression="prec_4d = 400.0")
+        cls.runModule("r.mapcalc", expression="prec_5d = 500.0")
+        cls.runModule("r.mapcalc", expression="prec_6d = 600.0")
 
-        self.runModule("t.create", type="strds",  temporaltype="absolute",  
+        cls.runModule("t.create", type="strds",  temporaltype="absolute",
                        output="precip_d",  title="A test float",  
                        description="A test float values")
 
     def tearDown(self):
         """Remove generated data"""
-        #self.runModule("t.remove",  flags="rf",  type="strds", inputs="precip_d")
-        #self.runModule('g.remove', type='raster', pattern='prec_*', flags='f')
-        self.del_temp_region()
+        self.runModule('g.remove', type='raster_3d', pattern='precip_*', flags='f')
 
-    def otest_years(self):
+    @classmethod
+    def tearDownClass(cls):
+        """Remove generated data"""
+        cls.runModule("t.remove",  flags="rf",  type="strds", inputs="precip_d")
+        cls.runModule('g.remove', type='raster', pattern='prec_*', flags='f')
+        cls.del_temp_region()
+
+    def test_years(self):
         """Convert STRDS into 3d raster map, granularity5 years"""
 
         self.runModule("t.register", flags="i",  type="raster",  input="precip_d",  
                        maps="prec_1d,prec_2d,prec_3d,prec_4d,prec_5d,prec_6d",  
-                       start="2000-01-01", increment="5 years")
+                       start="2000-01-01", increment="5 years", overwrite=True)
 
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
 
@@ -272,12 +269,12 @@
 
         self.assertRaster3dFitsInfo(raster="precip_d", reference=tinfo_string, precision=2)
 
-    def otest_months(self):
+    def test_months(self):
         """Convert STRDS into 3d raster map, granularity 6 months"""
 
         self.runModule("t.register", flags="i",  type="raster",  input="precip_d",  
                        maps="prec_1d,prec_2d,prec_3d,prec_4d,prec_5d,prec_6d",  
-                       start="2000-01-01", increment="6 months")
+                       start="2000-01-01", increment="6 months", overwrite=True)
 
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
 
@@ -300,12 +297,12 @@
 
         self.assertRaster3dFitsInfo(raster="precip_d", reference=tinfo_string, precision=2)
 
-    def otest_days(self):
+    def test_days(self):
         """Convert STRDS into 3d raster map, granularity 7 days"""
 
         self.runModule("t.register", flags="i",  type="raster",  input="precip_d",  
                        maps="prec_1d,prec_2d,prec_3d,prec_4d,prec_5d,prec_6d",  
-                       start="2000-01-01", increment="7 days")
+                       start="2000-01-01", increment="7 days", overwrite=True)
 
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
         self.runModule("r3.info", map="precip_d")
@@ -329,12 +326,12 @@
 
         self.assertRaster3dFitsInfo(raster="precip_d", reference=tinfo_string, precision=2)
 
-    def otest_hours(self):
-        """Convert STRDS into 3d raster map, granularity 7 days"""
+    def test_hours(self):
+        """Convert STRDS into 3d raster map, granularity 3 hours"""
 
         self.runModule("t.register", flags="i",  type="raster",  input="precip_d",  
                        maps="prec_1d,prec_2d,prec_3d,prec_4d,prec_5d,prec_6d",  
-                       start="2000-01-01", increment="3 hours")
+                       start="2000-01-01", increment="3 hours", overwrite=True)
 
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
         self.runModule("r3.info", map="precip_d")
@@ -358,12 +355,12 @@
 
         self.assertRaster3dFitsInfo(raster="precip_d", reference=tinfo_string, precision=2)
 
-    def otest_minutes(self):
-        """Convert STRDS into 3d raster map, granularity 7 days"""
+    def test_minutes(self):
+        """Convert STRDS into 3d raster map, granularity 17 minutes"""
 
         self.runModule("t.register", flags="i",  type="raster",  input="precip_d",  
                        maps="prec_1d,prec_2d,prec_3d,prec_4d,prec_5d,prec_6d",  
-                       start="2000-01-01", increment="17 minutes")
+                       start="2000-01-01", increment="17 minutes", overwrite=True)
 
         self.assertModule("t.rast.to.rast3",  input="precip_d",  output="precip_d")
         self.runModule("r3.info", map="precip_d")



More information about the grass-commit mailing list