[GRASS-SVN] r65119 - in grass/trunk/lib/python: docs/src pygrass/tests

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 21 15:24:43 PDT 2015


Author: lucadelu
Date: 2015-04-21 15:24:43 -0700 (Tue, 21 Apr 2015)
New Revision: 65119

Modified:
   grass/trunk/lib/python/docs/src/pygrass_raster.rst
   grass/trunk/lib/python/pygrass/tests/benchmark.py
Log:
pygrass: removed references to RasterNumpy

Modified: grass/trunk/lib/python/docs/src/pygrass_raster.rst
===================================================================
--- grass/trunk/lib/python/docs/src/pygrass_raster.rst	2015-04-21 16:36:21 UTC (rev 65118)
+++ grass/trunk/lib/python/docs/src/pygrass_raster.rst	2015-04-21 22:24:43 UTC (rev 65119)
@@ -6,16 +6,16 @@
 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>`_
 
-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
 consistent between them. The read access is row wise for :ref:`RasterRow-label`
 and :ref:`RasterRowIO-label` and additionally
 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)
 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 @@
 :ref:`RasterRow-label`      `Raster library`_        randomly  sequentially
 :ref:`RasterRowIO-label`    `RowIO library`_         cached    no
 :ref:`RasterSegment-label`  `Segmentation library`_  cached    randomly
-:ref:`RasterNumpy-label`    `numpy.memmap`_          cached    randomly
 ==========================  =======================  ========  ============
 
 
@@ -68,7 +67,7 @@
 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
 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
 only be written in sequential order. Therefore, each now row written to a map is
 added to the file as the last row. ::
@@ -211,49 +210,6 @@
     >>> 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
 .. _RowIO library: http://grass.osgeo.org/programming7/rowiolib.html
 .. _Segmentation library: http://grass.osgeo.org/programming7/segmentlib.html
-.. _numpy.memmap: http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html

Modified: grass/trunk/lib/python/pygrass/tests/benchmark.py
===================================================================
--- grass/trunk/lib/python/pygrass/tests/benchmark.py	2015-04-21 16:36:21 UTC (rev 65118)
+++ grass/trunk/lib/python/pygrass/tests/benchmark.py	2015-04-21 22:24:43 UTC (rev 65119)
@@ -24,96 +24,7 @@
 import pygrass
 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():
     test_a = pygrass.RasterSegment(name="test_a")
     test_a.open(mode="r")
@@ -524,4 +435,4 @@
 
     #import pdb; pdb.set_trace()
 
-    main(testdict)
\ No newline at end of file
+    main(testdict)



More information about the grass-commit mailing list