浏览代码

grass.script.array: remove deprecated read function (#1926)

Anna Petrasova 3 年之前
父节点
当前提交
73f2f46617
共有 2 个文件被更改,包括 5 次插入111 次删除
  1. 1 101
      python/grass/script/array.py
  2. 4 10
      python/grass/temporal/space_time_datasets.py

+ 1 - 101
python/grass/script/array.py

@@ -3,7 +3,6 @@ Functions to use GRASS 2D and 3D rasters with NumPy.
 
 Usage:
 
->>> from __future__ import print_function
 >>> import grass.script as gs
 >>> from grass.script import array as garray
 >>>
@@ -102,7 +101,7 @@ Usage:
 ... map3d_2.write(mapname="map3d_2", overwrite=True)
 0
 
-(C) 2010-2012 by Glynn Clements and the GRASS Development Team
+(C) 2010-2021 by Glynn Clements and the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
@@ -111,7 +110,6 @@ for details.
 """
 
 from __future__ import absolute_import
-import sys
 
 import numpy
 
@@ -183,55 +181,6 @@ class array(numpy.memmap):
         self._env = env
         return self
 
-    def read(self, mapname, null=None):
-        """Read raster map into array
-
-        :param str mapname: name of raster map to be read
-        :param null: null value
-
-        :return: 0 on success
-        :return: non-zero code on failure
-
-        .. deprecated:: 7.1
-        Instead reading the map after creating the array,
-        pass the map name in the array constructor.
-        """
-        if sys.platform == "win32":
-            gcore.warning(
-                _(
-                    "grass.script.array.read is deprecated and does not"
-                    " work on MS Windows, pass raster name in the constructor"
-                )
-            )
-        kind = self.dtype.kind
-        size = self.dtype.itemsize
-
-        if kind == "f":
-            flags = "f"
-        elif kind in "biu":
-            flags = "i"
-        else:
-            raise ValueError(_("Invalid kind <%s>") % kind)
-
-        if size not in [1, 2, 4, 8]:
-            raise ValueError(_("Invalid size <%d>") % size)
-
-        try:
-            gcore.run_command(
-                "r.out.bin",
-                flags=flags,
-                input=mapname,
-                output=self.filename,
-                bytes=size,
-                null=null,
-                quiet=True,
-                overwrite=True,
-            )
-        except CalledModuleError:
-            return 1
-        else:
-            return 0
-
     def write(self, mapname, title=None, null=None, overwrite=None, quiet=None):
         """Write array into raster map
 
@@ -342,55 +291,6 @@ class array3d(numpy.memmap):
 
         return self
 
-    def read(self, mapname, null=None):
-        """Read 3D raster map into array
-
-        :param str mapname: name of 3D raster map to be read
-        :param null: null value
-
-        :return: 0 on success
-        :return: non-zero code on failure
-
-        .. deprecated:: 7.1
-        Instead reading the map after creating the array,
-        pass the map name in the array constructor.
-        """
-        if sys.platform == "win32":
-            gcore.warning(
-                _(
-                    "grass.script.array3d.read is deprecated and does not"
-                    " work on MS Windows, pass 3D raster name in the constructor"
-                )
-            )
-        kind = self.dtype.kind
-        size = self.dtype.itemsize
-
-        if kind == "f":
-            flags = None  # default is double
-        elif kind in "biu":
-            flags = "i"
-        else:
-            raise ValueError(_("Invalid kind <%s>") % kind)
-
-        if size not in [1, 2, 4, 8]:
-            raise ValueError(_("Invalid size <%d>") % size)
-
-        try:
-            gcore.run_command(
-                "r3.out.bin",
-                flags=flags,
-                input=mapname,
-                output=self.filename,
-                bytes=size,
-                null=null,
-                quiet=True,
-                overwrite=True,
-            )
-        except CalledModuleError:
-            return 1
-        else:
-            return 0
-
     def write(self, mapname, null=None, overwrite=None, quiet=None):
         """Write array into 3D raster map
 

+ 4 - 10
python/grass/temporal/space_time_datasets.py

@@ -236,12 +236,9 @@ class RasterDataset(AbstractMapDataset):
         array back into grass.
         """
 
-        a = garray.array()
-
         if self.map_exists():
-            a.read(self.get_map_id())
-
-        return a
+            return garray.array(self.get_map_id())
+        return garray.array()
 
     def reset(self, ident):
         """Reset the internal structure and set the identifier"""
@@ -662,12 +659,9 @@ class Raster3DDataset(AbstractMapDataset):
         array back into grass.
         """
 
-        a = garray.array3d()
-
         if self.map_exists():
-            a.read(self.get_map_id())
-
-        return a
+            return garray.array3d(self.get_map_id())
+        return garray.array3d()
 
     def reset(self, ident):
         """Reset the internal structure and set the identifier"""