[GRASS-SVN] r59684 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 11 03:11:52 PDT 2014
Author: huhabla
Date: 2014-04-11 03:11:51 -0700 (Fri, 11 Apr 2014)
New Revision: 59684
Modified:
grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py
Log:
New tests for missing features and temporal algebra bug added.
Modified: grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py 2014-04-11 08:48:39 UTC (rev 59683)
+++ grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py 2014-04-11 10:11:51 UTC (rev 59684)
@@ -301,7 +301,7 @@
m = copy.deepcopy(self.m_mapcalc)
m_expression = newident + "=" + map_i.cmd_list
- m.inputs["expression"].value = m_expression
+ m.inputs["expression"].value = str(m_expression)
m.flags["overwrite"].value = self.overwrite
process_queue.put(m)
else:
Modified: grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-04-11 08:48:39 UTC (rev 59683)
+++ grass/trunk/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-04-11 10:11:51 UTC (rev 59684)
@@ -50,8 +50,42 @@
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_space_time_dataset("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_space_time_dataset("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 with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
@@ -64,9 +98,8 @@
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 with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
@@ -80,7 +113,7 @@
self.assertEqual(end, datetime.datetime(2001, 1, 5))
def test_simple_arith_td_3(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
@@ -95,7 +128,7 @@
def test_simple_arith_td_4(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
@@ -187,7 +220,7 @@
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)
More information about the grass-commit
mailing list