浏览代码

pygrass: removed references to RasterNumpy

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65119 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 10 年之前
父节点
当前提交
39bee4f65b
共有 2 个文件被更改,包括 6 次插入139 次删除
  1. 5 49
      lib/python/docs/src/pygrass_raster.rst
  2. 1 90
      lib/python/pygrass/tests/benchmark.py

+ 5 - 49
lib/python/docs/src/pygrass_raster.rst

@@ -6,16 +6,16 @@ Introduction to Raster classes
 Details about the GRASS GIS raster architecture can be found in the
 Details about the GRASS GIS raster architecture can be found in the
 `GRASS GIS 7 Programmer's Manual: GRASS Raster Library <http://grass.osgeo.org/programming7/rasterlib.html>`_
 `GRASS GIS 7 Programmer's Manual: GRASS Raster Library <http://grass.osgeo.org/programming7/rasterlib.html>`_
 
 
-PyGRASS uses 4 different Raster classes, that respect the 4 different approaches
+PyGRASS uses 3 different Raster classes, that respect the 3 different approaches
 of GRASS-C API. The classes use a standardized interface to keep methods
 of GRASS-C API. The classes use a standardized interface to keep methods
 consistent between them. The read access is row wise for :ref:`RasterRow-label`
 consistent between them. The read access is row wise for :ref:`RasterRow-label`
 and :ref:`RasterRowIO-label` and additionally
 and :ref:`RasterRowIO-label` and additionally
 cached in the RowIO class. Both classes write sequentially.
 cached in the RowIO class. Both classes write sequentially.
-RowIO is row cached, :ref:`RasterSegment-label` and :ref:`RasterNumpy-label`
-are tile cached for reading and writing; therefore, random access is possible.
+RowIO is row cached, :ref:`RasterSegment-label` 
+is tile cached for reading and writing; therefore, random access is possible.
 Hence RasterRow and RasterRowIO should be used for fast (cached)
 Hence RasterRow and RasterRowIO should be used for fast (cached)
 row read access and RasterRow for fast sequential writing.
 row read access and RasterRow for fast sequential writing.
-RasterSegment and RasterNumpy should be used for random access.
+RasterSegment should be used for random access.
 
 
 
 
 ==========================  =======================  ========  ============
 ==========================  =======================  ========  ============
@@ -24,7 +24,6 @@ Class Name                  C library                Read      Write
 :ref:`RasterRow-label`      `Raster library`_        randomly  sequentially
 :ref:`RasterRow-label`      `Raster library`_        randomly  sequentially
 :ref:`RasterRowIO-label`    `RowIO library`_         cached    no
 :ref:`RasterRowIO-label`    `RowIO library`_         cached    no
 :ref:`RasterSegment-label`  `Segmentation library`_  cached    randomly
 :ref:`RasterSegment-label`  `Segmentation library`_  cached    randomly
-:ref:`RasterNumpy-label`    `numpy.memmap`_          cached    randomly
 ==========================  =======================  ========  ============
 ==========================  =======================  ========  ============
 
 
 
 
@@ -68,7 +67,7 @@ RasterRow
 The PyGrass :class:`~pygrass.raster.RasterRow` class allow user to open maps row
 The PyGrass :class:`~pygrass.raster.RasterRow` class allow user to open maps row
 by row in either read or write mode using the `Raster library`_. Reading and writing
 by row in either read or write mode using the `Raster library`_. Reading and writing
 to the same map at the same time is not supported. For this functionality,
 to the same map at the same time is not supported. For this functionality,
-please see the :ref:`RasterSegment-label` and :ref:`RasterNumpy-label` classes.
+please see the :ref:`RasterSegment-label` class.
 The RasterRow class allows map rows to be read in any order, but map rows can
 The RasterRow class allows map rows to be read in any order, but map rows can
 only be written in sequential order. Therefore, each now row written to a map is
 only be written in sequential order. Therefore, each now row written to a map is
 added to the file as the last row. ::
 added to the file as the last row. ::
@@ -211,49 +210,6 @@ Similarly, writing to a map uses two methods: ``put_row`` to write a row and
     >>> elev.remove()
     >>> elev.remove()
 
 
 
 
-.. _RasterNumpy-label:
-
-RasterNumpy
------------
-
-The :class:`~pygrass.raster.RasterNumpy` class, is based on the `numpy.memmap`_ class
-(refer to the linked documentation for details). If an existing map is opened,
-small sections will be loaded into memory as accessed, but GRASS does not need to
-load the whole file into memory. Memmap is a subclass of the `numpy.ndarray`
-class, so RasterNumpy will behave like a numpy array and can be used with numpy
-array operations. ::
-
-    >>> raster = reload(raster)
-    >>> elev = raster.RasterNumpy('elevation', 'PERMANENT')
-    >>> elev.open('r')
-    >>> # in this case RasterNumpy is an extension of the numpy class
-    >>> # therefore you may use all the fancy things of numpy.
-    >>> elev[:5, :3]
-    RasterNumpy([[ 141.99613953,  141.27848816,  141.37904358],
-           [ 142.90461731,  142.39450073,  142.68611145],
-           [ 143.81854248,  143.54707336,  143.83972168],
-           [ 144.56524658,  144.58493042,  144.86477661],
-           [ 144.99488831,  145.22894287,  145.57142639]], dtype=float32)
-    >>> el = elev < 144
-    >>> el[:5, :3]
-    RasterNumpy([[1, 1, 1],
-           [1, 1, 1],
-           [1, 1, 1],
-           [0, 0, 0],
-           [0, 0, 0]], dtype=int32)
-    >>> el.name == None
-    True
-    >>> # give a name to the new map
-    >>> el.name = 'new'
-    >>> el.exist()
-    False
-    >>> el.close()
-    >>> el.exist()
-    True
-    >>> el.remove()
-
-
 .. _Raster library: http://grass.osgeo.org/programming7/rasterlib.html
 .. _Raster library: http://grass.osgeo.org/programming7/rasterlib.html
 .. _RowIO library: http://grass.osgeo.org/programming7/rowiolib.html
 .. _RowIO library: http://grass.osgeo.org/programming7/rowiolib.html
 .. _Segmentation library: http://grass.osgeo.org/programming7/segmentlib.html
 .. _Segmentation library: http://grass.osgeo.org/programming7/segmentlib.html
-.. _numpy.memmap: http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html

+ 1 - 90
lib/python/pygrass/tests/benchmark.py

@@ -24,95 +24,6 @@ import grass.script as core
 import pygrass
 import pygrass
 import ctypes
 import ctypes
 
 
-def test__RasterNumpy_value_access__if():
-    test_a = pygrass.RasterNumpy(name="test_a", mtype="CELL", mode="r+")
-    test_a.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="CELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    for row in range(test_a.rows):
-        for col in range(test_a.cols):
-            test_c[row, col] = test_a[row, col] > 50
-
-    test_a.close()
-    test_c.close()
-
-def test__RasterNumpy_value_access__add():
-    test_a = pygrass.RasterNumpy(name="test_a", mode="r+")
-    test_a.open()
-
-    test_b = pygrass.RasterNumpy(name="test_b", mode="r+")
-    test_b.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="DCELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    for row in range(test_a.rows):
-        for col in range(test_a.cols):
-            test_c[row, col] = test_a[row, col] + test_b[row, col]
-
-    test_a.close()
-    test_b.close()
-    test_c.close()
-
-def test__RasterNumpy_row_access__if():
-    test_a = pygrass.RasterNumpy(name="test_a", mtype="CELL", mode="r+")
-    test_a.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="CELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    for row in range(test_a.rows):
-        test_c[row] = test_a[row] > 50
-
-    test_a.close()
-    test_c.close()
-
-def test__RasterNumpy_row_access__add():
-    test_a = pygrass.RasterNumpy(name="test_a", mode="r+")
-    test_a.open()
-
-    test_b = pygrass.RasterNumpy(name="test_b", mode="r+")
-    test_b.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="DCELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    for row in range(test_a.rows):
-        test_c[row] = test_a[row] + test_b[row]
-
-    test_a.close()
-    test_b.close()
-    test_c.close()
-
-def test__RasterNumpy_map_access__if():
-    test_a = pygrass.RasterNumpy(name="test_a", mtype="CELL", mode="r+")
-    test_a.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="CELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    test_c = test_a > 50
-
-    test_a.close()
-    test_c.close()
-
-def test__RasterNumpy_map_access__add():
-    test_a = pygrass.RasterNumpy(name="test_a", mode="r+")
-    test_a.open()
-
-    test_b = pygrass.RasterNumpy(name="test_b", mode="r+")
-    test_b.open()
-
-    test_c = pygrass.RasterNumpy(name="test_c", mtype="DCELL", mode="w+", overwrite=True)
-    test_c.open()
-
-    test_c = test_a + test_b
-
-    test_a.close()
-    test_b.close()
-    test_c.close()
 
 
 def test__RasterSegment_value_access__if():
 def test__RasterSegment_value_access__if():
     test_a = pygrass.RasterSegment(name="test_a")
     test_a = pygrass.RasterSegment(name="test_a")
@@ -524,4 +435,4 @@ if __name__ == "__main__":
 
 
     #import pdb; pdb.set_trace()
     #import pdb; pdb.set_trace()
 
 
-    main(testdict)
+    main(testdict)