[GRASS-SVN] r68365 - in grass/trunk/lib/python: pygrass/vector temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 2 09:11:53 PDT 2016


Author: zarch
Date: 2016-05-02 09:11:53 -0700 (Mon, 02 May 2016)
New Revision: 68365

Modified:
   grass/trunk/lib/python/pygrass/vector/__init__.py
   grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
   grass/trunk/lib/python/temporal/temporal_algebra.py
   grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
Log:
fix doctests in temporal and pygrass libraries

Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py	2016-05-02 16:11:41 UTC (rev 68364)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py	2016-05-02 16:11:53 UTC (rev 68365)
@@ -674,7 +674,7 @@
             3
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (1, 1, 21)
             (2, 1, 21)
             (3, 1, 21)
@@ -685,7 +685,7 @@
             3
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (4, 2, 57)
             (5, 2, 57)
             (6, 2, 57)
@@ -702,7 +702,7 @@
 
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (19, 3, 21)
             (18, 3, 21)
             (20, 3, 21)
@@ -800,7 +800,7 @@
             4
             >>> for entry in result:
             ...     a_id, cat, wkb = entry
-            ...     print(a_id, cat, len(wkb))
+            ...     print((a_id, cat, len(wkb)))
             (1, 3, 225)
             (2, 3, 141)
             (3, 3, 93)
@@ -811,7 +811,7 @@
             4
             >>> for entry in result:
             ...     a_id, cat, wkb = entry
-            ...     print(a_id, cat, len(wkb))
+            ...     print((a_id, cat, len(wkb)))
             (1, 3, 225)
             (2, 3, 141)
             (3, 3, 93)

Modified: grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
===================================================================
--- grass/trunk/lib/python/temporal/spatio_temporal_relationships.py	2016-05-02 16:11:41 UTC (rev 68364)
+++ grass/trunk/lib/python/temporal/spatio_temporal_relationships.py	2016-05-02 16:11:53 UTC (rev 68365)
@@ -17,6 +17,8 @@
 
 :authors: Soeren Gebbert
 """
+from __future__ import print_function
+
 from .abstract_dataset import *
 from .datetime_math import *
 import grass.lib.vector as vector
@@ -94,8 +96,8 @@
             >>> for map in mapsA:
             ...     if map.get_equal():
             ...         relations = map.get_equal()
-            ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-            ...               relations[0].get_name())
+            ...         print("Map %s has equal relation to map %s"%(map.get_name(),
+            ...               relations[0].get_name()))
             Map a0 has equal relation to map b0
             Map a1 has equal relation to map b1
             Map a2 has equal relation to map b2
@@ -104,8 +106,8 @@
             >>> for map in mapsB:
             ...     if map.get_equal():
             ...         relations = map.get_equal()
-            ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-            ...               relations[0].get_name())
+            ...         print("Map %s has equal relation to map %s"%(map.get_name(),
+            ...               relations[0].get_name()))
             Map b0 has equal relation to map a0
             Map b1 has equal relation to map a1
             Map b2 has equal relation to map a2
@@ -132,7 +134,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (0, 1)
             ('PRECEDES', (1, 2))
             (1, 2)
@@ -171,7 +173,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
             ('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
             (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
@@ -210,7 +212,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
             ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
             ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
@@ -254,7 +256,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
             ('OVERLAPS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
             ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
@@ -303,7 +305,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
             ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
             ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
@@ -338,7 +340,7 @@
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
-            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            ...             print((key, m[key][0].get_temporal_extent_as_tuple()))
             (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
             ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
             ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))

Modified: grass/trunk/lib/python/temporal/temporal_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_algebra.py	2016-05-02 16:11:41 UTC (rev 68364)
+++ grass/trunk/lib/python/temporal/temporal_algebra.py	2016-05-02 16:11:53 UTC (rev 68365)
@@ -1464,7 +1464,7 @@
              >>> p = tgis.TemporalOperatorParser()
              >>> operator = "{+, during}"
              >>> p.parse(operator, optype = 'raster')
-             >>> print(p.relations, p.temporal, p.function)
+             >>> print((p.relations, p.temporal, p.function))
              (['during'], 'l', '+')
 
         """

Modified: grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py	2016-05-02 16:11:41 UTC (rev 68364)
+++ grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py	2016-05-02 16:11:53 UTC (rev 68365)
@@ -14,7 +14,7 @@
     >>> p = TemporalRasterAlgebraLexer()
     >>> p.build()
     >>> p.debug = True
-    >>> expression =  'R = A {+,equal,l} B '
+    >>> expression =  'R = A {+,equal,l} B'
     >>> p.test(expression)
     R = A {+,equal,l} B
     LexToken(NAME,'R',1,0)
@@ -22,7 +22,7 @@
     LexToken(NAME,'A',1,4)
     LexToken(T_ARITH2_OPERATOR,'{+,equal,l}',1,6)
     LexToken(NAME,'B',1,18)
-    >>> expression =  'R = A {*,equal|during,r} B '
+    >>> expression =  'R = A {*,equal|during,r} B'
     >>> p.test(expression)
     R = A {*,equal|during,r} B
     LexToken(NAME,'R',1,0)
@@ -30,7 +30,7 @@
     LexToken(NAME,'A',1,4)
     LexToken(T_ARITH1_OPERATOR,'{*,equal|during,r}',1,6)
     LexToken(NAME,'B',1,25)
-    >>> expression =  'R = A {+,equal|during} B '
+    >>> expression =  'R = A {+,equal|during} B'
     >>> p.test(expression)
     R = A {+,equal|during} B
     LexToken(NAME,'R',1,0)



More information about the grass-commit mailing list