[GRASS-SVN] r69699 - in grass/trunk/lib/python/temporal: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 16 14:19:59 PDT 2016


Author: huhabla
Date: 2016-10-16 14:19:58 -0700 (Sun, 16 Oct 2016)
New Revision: 69699

Modified:
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/space_time_datasets.py
   grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra.py
   grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py
   grass/trunk/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py
Log:
temporal framework: Added new doctests for space time dataset, fixed bug in AbstractSpaceTimeDataset


Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2016-10-16 03:22:49 UTC (rev 69698)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2016-10-16 21:19:58 UTC (rev 69699)
@@ -408,7 +408,7 @@
         """
 
         if maps is None:
-            maps = get_registered_maps_as_objects(
+            maps = self.get_registered_maps_as_objects(
                 where=None, order="start_time", dbif=dbif)
 
         time_invalid = 0

Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py	2016-10-16 03:22:49 UTC (rev 69698)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py	2016-10-16 21:19:58 UTC (rev 69699)
@@ -97,6 +97,10 @@
             (2, None)
             >>> rmap.get_relative_time_unit()
             'years'
+            >>> rmap.is_in_db()
+            False
+            >>> rmap.is_stds()
+            False
 
             >>> newmap = rmap.get_new_instance("new at PERMANENT")
             >>> isinstance(newmap, RasterDataset)
@@ -426,6 +430,10 @@
             (2, None)
             >>> r3map.get_relative_time_unit()
             'years'
+            >>> r3map.is_in_db()
+            False
+            >>> r3map.is_stds()
+            False
 
             >>> newmap = r3map.get_new_instance("new at PERMANENT")
             >>> isinstance(newmap, Raster3DDataset)
@@ -767,6 +775,10 @@
             (2, None)
             >>> vmap.get_relative_time_unit()
             'years'
+            >>> vmap.is_in_db()
+            False
+            >>> vmap.is_stds()
+            False
 
             >>> newmap = vmap.get_new_instance("new at PERMANENT")
             >>> isinstance(newmap, VectorDataset)
@@ -1005,6 +1017,35 @@
 
 class SpaceTimeRasterDataset(AbstractSpaceTimeDataset):
     """Space time raster dataset class
+
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> strds = tgis.SpaceTimeRasterDataset("old at PERMANENT")
+            >>> strds.is_in_db()
+            False
+            >>> strds.is_stds()
+            True
+            >>> strds.get_type()
+            'strds'
+            >>> newstrds = strds.get_new_instance("newstrds at PERMANENT")
+            >>> isinstance(newstrds, SpaceTimeRasterDataset)
+            True
+            >>> newmap = strds.get_new_map_instance("newmap at PERMANENT")
+            >>> isinstance(newmap, RasterDataset)
+            True
+            >>> strds.reset("new at PERMANENT")
+            >>> strds.is_in_db()
+            False
+            >>> strds.get_id()
+            'new at PERMANENT'
+            >>> strds.reset(None)
+            >>> strds.is_in_db()
+            False
+            >>> strds.get_id()
+
+        ...
     """
     def __init__(self, ident):
         AbstractSpaceTimeDataset.__init__(self, ident)
@@ -1085,6 +1126,35 @@
 
 class SpaceTimeRaster3DDataset(AbstractSpaceTimeDataset):
     """Space time raster3d dataset class
+
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> str3ds = tgis.SpaceTimeRaster3DDataset("old at PERMANENT")
+            >>> str3ds.is_in_db()
+            False
+            >>> str3ds.is_stds()
+            True
+            >>> str3ds.get_type()
+            'str3ds'
+            >>> newstrds = str3ds.get_new_instance("newstrds at PERMANENT")
+            >>> isinstance(newstrds, SpaceTimeRaster3DDataset)
+            True
+            >>> newmap = str3ds.get_new_map_instance("newmap at PERMANENT")
+            >>> isinstance(newmap, Raster3DDataset)
+            True
+            >>> str3ds.reset("new at PERMANENT")
+            >>> str3ds.is_in_db()
+            False
+            >>> str3ds.get_id()
+            'new at PERMANENT'
+            >>> str3ds.reset(None)
+            >>> str3ds.is_in_db()
+            False
+            >>> str3ds.get_id()
+
+        ...
     """
 
     def __init__(self, ident):
@@ -1184,6 +1254,35 @@
 
 class SpaceTimeVectorDataset(AbstractSpaceTimeDataset):
     """Space time vector dataset class
+
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> stvds = tgis.SpaceTimeVectorDataset("old at PERMANENT")
+            >>> stvds.is_in_db()
+            False
+            >>> stvds.is_stds()
+            True
+            >>> stvds.get_type()
+            'stvds'
+            >>> newstvds = stvds.get_new_instance("newstvds at PERMANENT")
+            >>> isinstance(newstvds, SpaceTimeVectorDataset)
+            True
+            >>> newmap = stvds.get_new_map_instance("newmap at PERMANENT")
+            >>> isinstance(newmap, VectorDataset)
+            True
+            >>> stvds.reset("new at PERMANENT")
+            >>> stvds.is_in_db()
+            False
+            >>> stvds.get_id()
+            'new at PERMANENT'
+            >>> stvds.reset(None)
+            >>> stvds.is_in_db()
+            False
+            >>> stvds.get_id()
+
+        ...
     """
 
     def __init__(self, ident):

Modified: grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra.py	2016-10-16 03:22:49 UTC (rev 69698)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra.py	2016-10-16 21:19:58 UTC (rev 69699)
@@ -74,6 +74,7 @@
         ta.parse(expression="R = A : A",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 1)
@@ -90,6 +91,7 @@
         ta.parse(expression="R = A : D",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 3)
@@ -106,6 +108,7 @@
         ta.parse(expression="R = A !: D",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 1)
@@ -122,6 +125,7 @@
         ta.parse(expression="R = A {:,during} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 2)
@@ -138,6 +142,7 @@
         ta.parse(expression="R = A {:,equal|during} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 2)
@@ -155,6 +160,7 @@
         ta.parse(expression="R = A {!:,during} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 1)
@@ -172,6 +178,7 @@
         ta.parse(expression="R = A {:,during,d} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         for map_i in maplist:
@@ -194,6 +201,7 @@
         ta.parse(expression="R = C {:,contains} A",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         for map_i in maplist:
@@ -215,6 +223,7 @@
         ta.parse(expression="R = A {:,during,r} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
@@ -232,6 +241,7 @@
         ta.parse(expression="R = A {:,during,d} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
@@ -249,6 +259,7 @@
         ta.parse(expression="R = A {:,during,u} C",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         for map_i in maplist:
@@ -270,6 +281,7 @@
         ta.parse(expression="R = if(A # D == 1, A)",  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
@@ -288,6 +300,7 @@
                                        basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
@@ -306,6 +319,7 @@
                                                  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
@@ -323,6 +337,7 @@
         ta.parse(expression='R = tmap(singletmap)',  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 1)
@@ -340,6 +355,7 @@
         ta.parse(expression='R = A : tmap(singletmap)',  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 1)
@@ -357,6 +373,7 @@
         ta.parse(expression='R = merge(A,D)',  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 7)
@@ -374,6 +391,7 @@
         ta.parse(expression='R = merge(A, B {!:,contains} A)',  stdstype = 'strds', basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="strds")
+        self.assertTrue(D.is_in_db())
         D.select()
         maplist = D.get_registered_maps_as_objects()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)

Modified: grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py	2016-10-16 03:22:49 UTC (rev 69698)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py	2016-10-16 21:19:58 UTC (rev 69699)
@@ -54,6 +54,7 @@
                   basename="d", overwrite=True)
 
         D = tgis.open_old_stds("D", type="str3ds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
@@ -69,6 +70,7 @@
                   basename="d", overwrite=True)
 
         D = tgis.open_old_stds("D", type="str3ds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3

Modified: grass/trunk/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py	2016-10-16 03:22:49 UTC (rev 69698)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py	2016-10-16 21:19:58 UTC (rev 69699)
@@ -73,6 +73,7 @@
         tva.parse(expression="R = A : A", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_number_of_points(), 80) 
@@ -90,6 +91,7 @@
         ta.parse(expression="R = A {:,during,r} C",  basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         D.print_info()
         maplist = D.get_registered_maps_as_objects()
@@ -106,6 +108,7 @@
         tva.parse(expression="R = A {:,during} C", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_number_of_points(), 40) 
@@ -123,6 +126,7 @@
         tva.parse(expression="R = buff_p(A,0.5)", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_number_of_points(), 0) 
@@ -140,6 +144,7 @@
         tva.parse(expression="R = buff_a(buff_p(A,1),10)", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_number_of_points(), 0) 
@@ -157,6 +162,7 @@
         tva.parse(expression="R = buff_p(A,2) & buff_p(D,2)", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_number_of_points(), 0)
@@ -174,6 +180,7 @@
         tva.parse(expression="R = buff_p(A,1.5) {&,during,r} buff_p(B,1.5)", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_number_of_points(), 0)
@@ -191,6 +198,7 @@
         tva.parse(expression="R = buff_p(A,2.5) {&,during,l} buff_p(C,2.5)", basename="r", overwrite=True)
 
         D = tgis.open_old_stds("R", type="stvds")
+        self.assertTrue(D.is_in_db())
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_number_of_points(), 0)



More information about the grass-commit mailing list