Browse Source

fix doctests in temporal and pygrass libraries

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68365 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 9 years ago
parent
commit
8ef5a0ea29

+ 5 - 5
lib/python/pygrass/vector/__init__.py

@@ -674,7 +674,7 @@ class VectorTopo(Vector):
             3
             3
             >>> for entry in result:
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (1, 1, 21)
             (1, 1, 21)
             (2, 1, 21)
             (2, 1, 21)
             (3, 1, 21)
             (3, 1, 21)
@@ -685,7 +685,7 @@ class VectorTopo(Vector):
             3
             3
             >>> for entry in result:
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (4, 2, 57)
             (4, 2, 57)
             (5, 2, 57)
             (5, 2, 57)
             (6, 2, 57)
             (6, 2, 57)
@@ -702,7 +702,7 @@ class VectorTopo(Vector):
 
 
             >>> for entry in result:
             >>> for entry in result:
             ...     f_id, cat, wkb = entry
             ...     f_id, cat, wkb = entry
-            ...     print(f_id, cat, len(wkb))
+            ...     print((f_id, cat, len(wkb)))
             (19, 3, 21)
             (19, 3, 21)
             (18, 3, 21)
             (18, 3, 21)
             (20, 3, 21)
             (20, 3, 21)
@@ -800,7 +800,7 @@ class VectorTopo(Vector):
             4
             4
             >>> for entry in result:
             >>> for entry in result:
             ...     a_id, cat, wkb = entry
             ...     a_id, cat, wkb = entry
-            ...     print(a_id, cat, len(wkb))
+            ...     print((a_id, cat, len(wkb)))
             (1, 3, 225)
             (1, 3, 225)
             (2, 3, 141)
             (2, 3, 141)
             (3, 3, 93)
             (3, 3, 93)
@@ -811,7 +811,7 @@ class VectorTopo(Vector):
             4
             4
             >>> for entry in result:
             >>> for entry in result:
             ...     a_id, cat, wkb = entry
             ...     a_id, cat, wkb = entry
-            ...     print(a_id, cat, len(wkb))
+            ...     print((a_id, cat, len(wkb)))
             (1, 3, 225)
             (1, 3, 225)
             (2, 3, 141)
             (2, 3, 141)
             (3, 3, 93)
             (3, 3, 93)

+ 12 - 10
lib/python/temporal/spatio_temporal_relationships.py

@@ -17,6 +17,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+from __future__ import print_function
+
 from .abstract_dataset import *
 from .abstract_dataset import *
 from .datetime_math import *
 from .datetime_math import *
 import grass.lib.vector as vector
 import grass.lib.vector as vector
@@ -94,8 +96,8 @@ class SpatioTemporalTopologyBuilder(object):
             >>> for map in mapsA:
             >>> for map in mapsA:
             ...     if map.get_equal():
             ...     if map.get_equal():
             ...         relations = 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 a0 has equal relation to map b0
             Map a1 has equal relation to map b1
             Map a1 has equal relation to map b1
             Map a2 has equal relation to map b2
             Map a2 has equal relation to map b2
@@ -104,8 +106,8 @@ class SpatioTemporalTopologyBuilder(object):
             >>> for map in mapsB:
             >>> for map in mapsB:
             ...     if map.get_equal():
             ...     if map.get_equal():
             ...         relations = 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 b0 has equal relation to map a0
             Map b1 has equal relation to map a1
             Map b1 has equal relation to map a1
             Map b2 has equal relation to map a2
             Map b2 has equal relation to map a2
@@ -132,7 +134,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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)
             (0, 1)
             ('PRECEDES', (1, 2))
             ('PRECEDES', (1, 2))
             (1, 2)
             (1, 2)
@@ -171,7 +173,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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))
             (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)))
             ('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))
             (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
@@ -210,7 +212,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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))
             (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)))
             ('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)))
             ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
@@ -254,7 +256,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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))
             (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)))
             ('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)))
             ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
@@ -303,7 +305,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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))
             (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)))
             ('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)))
             ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
@@ -338,7 +340,7 @@ class SpatioTemporalTopologyBuilder(object):
             ...     m = map.get_temporal_relations()
             ...     m = map.get_temporal_relations()
             ...     for key in m.keys():
             ...     for key in m.keys():
             ...         if key not in ["NEXT", "PREV"]:
             ...         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))
             (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)))
             ('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)))
             ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))

+ 1 - 1
lib/python/temporal/temporal_algebra.py

@@ -1464,7 +1464,7 @@ class TemporalAlgebraParser(object):
              >>> p = tgis.TemporalOperatorParser()
              >>> p = tgis.TemporalOperatorParser()
              >>> operator = "{+, during}"
              >>> operator = "{+, during}"
              >>> p.parse(operator, optype = 'raster')
              >>> p.parse(operator, optype = 'raster')
-             >>> print(p.relations, p.temporal, p.function)
+             >>> print((p.relations, p.temporal, p.function))
              (['during'], 'l', '+')
              (['during'], 'l', '+')
 
 
         """
         """

+ 3 - 3
lib/python/temporal/temporal_raster_base_algebra.py

@@ -14,7 +14,7 @@ for details.
     >>> p = TemporalRasterAlgebraLexer()
     >>> p = TemporalRasterAlgebraLexer()
     >>> p.build()
     >>> p.build()
     >>> p.debug = True
     >>> p.debug = True
-    >>> expression =  'R = A {+,equal,l} B '
+    >>> expression =  'R = A {+,equal,l} B'
     >>> p.test(expression)
     >>> p.test(expression)
     R = A {+,equal,l} B
     R = A {+,equal,l} B
     LexToken(NAME,'R',1,0)
     LexToken(NAME,'R',1,0)
@@ -22,7 +22,7 @@ for details.
     LexToken(NAME,'A',1,4)
     LexToken(NAME,'A',1,4)
     LexToken(T_ARITH2_OPERATOR,'{+,equal,l}',1,6)
     LexToken(T_ARITH2_OPERATOR,'{+,equal,l}',1,6)
     LexToken(NAME,'B',1,18)
     LexToken(NAME,'B',1,18)
-    >>> expression =  'R = A {*,equal|during,r} B '
+    >>> expression =  'R = A {*,equal|during,r} B'
     >>> p.test(expression)
     >>> p.test(expression)
     R = A {*,equal|during,r} B
     R = A {*,equal|during,r} B
     LexToken(NAME,'R',1,0)
     LexToken(NAME,'R',1,0)
@@ -30,7 +30,7 @@ for details.
     LexToken(NAME,'A',1,4)
     LexToken(NAME,'A',1,4)
     LexToken(T_ARITH1_OPERATOR,'{*,equal|during,r}',1,6)
     LexToken(T_ARITH1_OPERATOR,'{*,equal|during,r}',1,6)
     LexToken(NAME,'B',1,25)
     LexToken(NAME,'B',1,25)
-    >>> expression =  'R = A {+,equal|during} B '
+    >>> expression =  'R = A {+,equal|during} B'
     >>> p.test(expression)
     >>> p.test(expression)
     R = A {+,equal|during} B
     R = A {+,equal|during} B
     LexToken(NAME,'R',1,0)
     LexToken(NAME,'R',1,0)