[GRASS-SVN] r74506 - in grass/trunk/lib/python/pygrass: raster vector

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 16 14:11:35 PDT 2019


Author: annakrat
Date: 2019-05-16 14:11:35 -0700 (Thu, 16 May 2019)
New Revision: 74506

Modified:
   grass/trunk/lib/python/pygrass/raster/__init__.py
   grass/trunk/lib/python/pygrass/raster/abstract.py
   grass/trunk/lib/python/pygrass/vector/__init__.py
   grass/trunk/lib/python/pygrass/vector/geometry.py
   grass/trunk/lib/python/pygrass/vector/table.py
Log:
pygrass: fixing doctests (only for Python 3)

Modified: grass/trunk/lib/python/pygrass/raster/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/__init__.py	2019-05-16 21:11:05 UTC (rev 74505)
+++ grass/trunk/lib/python/pygrass/raster/__init__.py	2019-05-16 21:11:35 UTC (rev 74506)
@@ -67,7 +67,7 @@
         >>> elev.has_cats()
         True
         >>> elev.mode
-        u'r'
+        'r'
         >>> elev.mtype
         'CELL'
         >>> elev.num_cats()
@@ -85,13 +85,13 @@
         >>> elev.hist.title = "A test map"
         >>> elev.hist.write()
         >>> elev.hist.title
-        u'A test map'
+        'A test map'
         >>> elev.hist.keyword
-        u'This is a test map'
+        'This is a test map'
 
         >>> attrs = list(elev.hist)
         >>> attrs[0]
-        ('name', u'Raster_test_map')
+        ('name', 'Raster_test_map')
         >>> attrs[2]
         ('mtype', '')
 
@@ -99,27 +99,27 @@
         to interact with the raster categories.
 
         >>> elev.cats          # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-        [(u'A', 11, None),
-         (u'B', 12, None),
+        [('A', 11, None),
+         ('B', 12, None),
         ...
-         (u'P', 44, None)]
+         ('P', 44, None)]
 
         >>> elev.cats.labels() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-        [u'A', u'B', u'C', u'D', u'E',
-         u'F', u'G', u'H', u'I', u'J',
-         u'K', u'L', u'M', u'n', u'O', u'P']
+        ['A', 'B', 'C', 'D', 'E',
+         'F', 'G', 'H', 'I', 'J',
+         'K', 'L', 'M', 'n', 'O', 'P']
         >>> elev.cats[0]
-        (u'A', 11, None)
+        ('A', 11, None)
         >>> elev.cats[2]
-        (u'C', 13, None)
+        ('C', 13, None)
         >>> elev.cats[0] = ('AA', 11)
         >>> elev.cats[1] = ('BB', 12)
         >>> elev.cats.write()
         >>> elev.cats.read()
         >>> elev.cats[0]
-        (u'AA', 11, None)
+        ('AA', 11, None)
         >>> elev.cats[1]
-        (u'BB', 12, None)
+        ('BB', 12, None)
 
         Open a raster map using the *with statement*:
 

Modified: grass/trunk/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/abstract.py	2019-05-16 21:11:05 UTC (rev 74505)
+++ grass/trunk/lib/python/pygrass/raster/abstract.py	2019-05-16 21:11:35 UTC (rev 74506)
@@ -217,7 +217,7 @@
 
         >>> ele = RasterAbstractBase(test_raster_name)
         >>> ele.name
-        u'abstract_test_map'
+        'abstract_test_map'
         >>> ele.exist()
         True
 
@@ -403,7 +403,7 @@
         >>> ele = RasterAbstractBase(test_raster_name)
         >>> name = ele.name_mapset().split("@")
         >>> name
-        [u'abstract_test_map']
+        ['abstract_test_map']
 
         """
         if name is None:

Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py	2019-05-16 21:11:05 UTC (rev 74505)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py	2019-05-16 21:11:35 UTC (rev 74506)
@@ -161,7 +161,7 @@
 
             >>> new.table.conn.commit()
             >>> new.table.execute().fetchall()
-            [(1, u'pub'), (2, u'resturant')]
+            [(1, 'pub'), (2, 'resturant')]
 
         close the vector map ::
 
@@ -177,9 +177,9 @@
             >>> new.read(2)
             Point(1.000000, 1.000000)
             >>> new.read(1).attrs['name']
-            u'pub'
+            'pub'
             >>> new.read(2).attrs['name']
-            u'resturant'
+            'resturant'
             >>> new.close()
             >>> new.remove()
 
@@ -577,7 +577,7 @@
             >>> test_vect.write(point1, cat=2, attrs=('resturant',))
             >>> test_vect.table.conn.commit()  # save changes in the DB
             >>> test_vect.table_to_dict()
-            {1: [1, u'pub'], 2: [2, u'resturant']}
+            {1: [1, 'pub'], 2: [2, 'resturant']}
             >>> test_vect.close()
 
         Now rewrite one point of the vector map: ::
@@ -662,16 +662,16 @@
             >>> test_vect.open('r')
 
             >>> test_vect.table_to_dict()
-            {1: [1, u'point', 1.0], 2: [2, u'line', 2.0], 3: [3, u'centroid', 3.0]}
+            {1: [1, 'point', 1.0], 2: [2, 'line', 2.0], 3: [3, 'centroid', 3.0]}
 
             >>> test_vect.table_to_dict(where="value > 2")
-            {3: [3, u'centroid', 3.0]}
+            {3: [3, 'centroid', 3.0]}
 
             >>> test_vect.table_to_dict(where="value > 0")
-            {1: [1, u'point', 1.0], 2: [2, u'line', 2.0], 3: [3, u'centroid', 3.0]}
+            {1: [1, 'point', 1.0], 2: [2, 'line', 2.0], 3: [3, 'centroid', 3.0]}
 
             >>> test_vect.table.filters.get_sql()
-            u'SELECT cat,name,value FROM vector_doctest_map WHERE value > 0 ORDER BY cat;'
+            'SELECT cat,name,value FROM vector_doctest_map WHERE value > 0 ORDER BY cat;'
 
         """
 

Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py	2019-05-16 21:11:05 UTC (rev 74505)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py	2019-05-16 21:11:35 UTC (rev 74506)
@@ -163,9 +163,9 @@
         >>> test_vect.open('r')
         >>> v1 = test_vect[1]
         >>> v1.attrs['name']
-        u'point'
+        'point'
         >>> v1.attrs['name', 'value']
-        (u'point', 1.0)
+        ('point', 1.0)
         >>> test_vect.close()
 
         """
@@ -186,15 +186,15 @@
         >>> test_vect.open('r')
         >>> v1 = test_vect[1]
         >>> v1.attrs['name']
-        u'point'
+        'point'
 
         >>> v1.attrs['name'] = "new_point_1"
         >>> v1.attrs['name']
-        u'new_point_1'
+        'new_point_1'
 
         >>> v1.attrs['name', 'value'] = "new_point_2", 100.
         >>> v1.attrs['name', 'value']
-        (u'new_point_2', 100.0)
+        ('new_point_2', 100.0)
         >>> v1.attrs['name', 'value'] = "point", 1.
         >>> v1.attrs.table.conn.commit()
         >>> test_vect.close()
@@ -234,7 +234,7 @@
            >>> test_vect.open('r')
            >>> v1 = test_vect[1]
            >>> v1.attrs.values()
-           (1, u'point', 1.0)
+           (1, 'point', 1.0)
             >>> test_vect.close()
 
         """
@@ -252,7 +252,7 @@
            >>> test_vect.open('r')
            >>> v1 = test_vect[1]
            >>> v1.attrs.keys()
-           [u'cat', u'name', u'value']
+           ['cat', 'name', 'value']
             >>> test_vect.close()
 
         """
@@ -374,7 +374,7 @@
 
             >>> pnt = Point(10, 100)
             >>> pnt.to_wkt()
-            u'POINT (10.0000000000000000 100.0000000000000000)'
+            'POINT (10.0000000000000000 100.0000000000000000)'
         """
         return decode(libvect.Vect_line_to_wkt(self.c_points, self.gtype, not self.is2D))
 
@@ -1303,7 +1303,6 @@
 
     def __init__(self, **kargs):
         super(Boundary, self).__init__(**kargs)
-
         v_id = kargs.get('v_id', 0)
         self.dir = libvect.GV_FORWARD if v_id > 0 else libvect.GV_BACKWARD
         self.c_left = ctypes.pointer(ctypes.c_int())

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2019-05-16 21:11:05 UTC (rev 74505)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2019-05-16 21:11:35 UTC (rev 74506)
@@ -80,13 +80,13 @@
 
     >>> filter = Filters('table')
     >>> filter.get_sql()
-    u'SELECT * FROM table;'
+    'SELECT * FROM table;'
     >>> filter.where("area<10000").get_sql()
-    u'SELECT * FROM table WHERE area<10000;'
+    'SELECT * FROM table WHERE area<10000;'
     >>> filter.select("cat", "area").get_sql()
-    u'SELECT cat, area FROM table WHERE area<10000;'
+    'SELECT cat, area FROM table WHERE area<10000;'
     >>> filter.order_by("area").limit(10).get_sql()
-    u'SELECT cat, area FROM table WHERE area<10000 ORDER BY area LIMIT 10;'
+    'SELECT cat, area FROM table WHERE area<10000 ORDER BY area LIMIT 10;'
 
     """
     def __init__(self, tname):
@@ -186,7 +186,7 @@
     >>> cols_sqlite = Columns(test_vector_name,
     ...                       sqlite3.connect(get_path(path)))
     >>> cols_sqlite.tname
-    u'table_doctest_map'
+    'table_doctest_map'
 
     For a postgreSQL table:
 
@@ -306,12 +306,12 @@
         >>> cols_sqlite = Columns(test_vector_name,
         ...                       sqlite3.connect(get_path(path)))
         >>> cols_sqlite.sql_descr()                   # doctest: +ELLIPSIS
-        u'cat INTEGER, name varchar(50), value double precision'
+        'cat INTEGER, name varchar(50), value double precision'
         >>> import psycopg2 as pg                         # doctest: +SKIP
         >>> cols_pg = Columns(test_vector_name,
         ...                   pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
         >>> cols_pg.sql_descr()                 # doctest: +ELLIPSIS +SKIP
-        u'cat INTEGER, name varchar(50), value double precision'
+        'cat INTEGER, name varchar(50), value double precision'
         """
         if remove:
             return ', '.join(['%s %s' % (key, val) for key, val in self.items()
@@ -328,12 +328,12 @@
         >>> cols_sqlite = Columns(test_vector_name,
         ...                       sqlite3.connect(get_path(path)))
         >>> cols_sqlite.types()                       # doctest: +ELLIPSIS
-        [u'INTEGER', u'varchar(50)', u'double precision']
+        ['INTEGER', 'varchar(50)', 'double precision']
         >>> import psycopg2 as pg                         # doctest: +SKIP
         >>> cols_pg = Columns(test_vector_name,
         ...                   pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
         >>> cols_pg.types()                     # doctest: +ELLIPSIS +SKIP
-        [u'INTEGER', u'varchar(50)', u'double precision']
+        ['INTEGER', 'varchar(50)', 'double precision']
 
         """
         return self.odict.values()
@@ -347,12 +347,12 @@
         >>> cols_sqlite = Columns(test_vector_name,
         ...                       sqlite3.connect(get_path(path)))
         >>> cols_sqlite.names()                      # doctest: +ELLIPSIS
-        [u'cat', u'name', u'value']
+        ['cat', 'name', 'value']
         >>> import psycopg2 as pg                         # doctest: +SKIP
         >>> cols_pg = Columns(test_vector_name,       # doctest: +SKIP
         ...                   pg.connect('host=localhost dbname=grassdb'))
         >>> cols_pg.names()                     # doctest: +ELLIPSIS +SKIP
-        [u'cat', u'name', u'value']
+        ['cat', 'name', 'value']
 
         """
         if remove:
@@ -373,12 +373,12 @@
         >>> cols_sqlite = Columns(test_vector_name,
         ...                       sqlite3.connect(get_path(path)))
         >>> cols_sqlite.items()                       # doctest: +ELLIPSIS
-        [(u'cat', u'INTEGER'), (u'name', u'varchar(50)'), (u'value', u'double precision')]
+        [('cat', 'INTEGER'), ('name', 'varchar(50)'), ('value', 'double precision')]
         >>> import psycopg2 as pg                         # doctest: +SKIP
         >>> cols_pg = Columns(test_vector_name,
         ...                   pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
         >>> cols_pg.items()                     # doctest: +ELLIPSIS +SKIP
-        [(u'cat', u'INTEGER'), (u'name', u'varchar(50)'), (u'value', u'double precision')]
+        [('cat', 'INTEGER'), ('name', 'varchar(50)'), ('value', 'double precision')]
 
         """
         return self.odict.items()
@@ -588,15 +588,15 @@
     >>> link.layer
     1
     >>> link.name
-    u'link0'
+    'link0'
     >>> link.table_name
-    u'table_doctest_map'
+    'table_doctest_map'
     >>> link.key
-    u'cat'
+    'cat'
     >>> link.database
-    u'$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
+    '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
     >>> link.driver
-    u'sqlite'
+    'sqlite'
     >>> link
     Link(1, link0, sqlite)
 
@@ -737,12 +737,12 @@
         >>> conn = link.connection()
         >>> cur = conn.cursor()
         >>> link.table_name
-        u'table_doctest_map'
+        'table_doctest_map'
         >>> cur.execute("SELECT cat, name, value from %s" %
         ...             link.table_name)              # doctest: +ELLIPSIS
         <sqlite3.Cursor object at ...>
         >>> cur.fetchone()     #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-        (1, u'point', 1.0)
+        (1, 'point', 1.0)
         >>> cur.close()
         >>> conn.close()
 
@@ -782,10 +782,10 @@
         ...             'sqlite')
         >>> table = link.table()
         >>> table.filters.select('cat', 'name', 'value')
-        Filters(u'SELECT cat, name, value FROM table_doctest_map;')
+        Filters('SELECT cat, name, value FROM table_doctest_map;')
         >>> cur = table.execute()
         >>> cur.fetchone()
-        (1, u'point', 1.0)
+        (1, 'point', 1.0)
         >>> cur.close()
 
         """
@@ -958,7 +958,7 @@
     >>> tab_sqlite = Table(name=test_vector_name,
     ...                    connection=sqlite3.connect(get_path(path)))
     >>> tab_sqlite.name
-    u'table_doctest_map'
+    'table_doctest_map'
     >>> import psycopg2                                   # doctest: +SKIP
     >>> tab_pg = Table(test_vector_name,
     ...                psycopg2.connect('host=localhost dbname=grassdb',
@@ -1004,7 +1004,7 @@
         >>> tab_sqlite = Table(name=test_vector_name,
         ...                    connection=sqlite3.connect(get_path(path)))
         >>> tab_sqlite
-        Table(u'table_doctest_map')
+        Table('table_doctest_map')
 
         """
         return "Table(%r)" % (self.name)
@@ -1077,10 +1077,10 @@
         >>> tab_sqlite = Table(name=test_vector_name,
         ...                    connection=sqlite3.connect(get_path(path)))
         >>> tab_sqlite.filters.select('cat', 'name').order_by('value')
-        Filters(u'SELECT cat, name FROM table_doctest_map ORDER BY value;')
+        Filters('SELECT cat, name FROM table_doctest_map ORDER BY value;')
         >>> cur = tab_sqlite.execute()
         >>> cur.fetchone()     #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-         (1, u'point')
+         (1, 'point')
 
         """
         try:



More information about the grass-commit mailing list