[GRASS-dev] [GRASS GIS] #2616: grass.script.array cannot write raster

#2616: grass.script.array cannot write raster
-------------------------+--------------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.1
Component: Python | Version: svn-trunk
Keywords: array | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
It seems the r64426 (backported in r64614) broke writing the array.
Tested [http://grass.osgeo.org/grass70/manuals/libpython/script.html
example] with 1.8.2 !NumPy, the temporary file disappears once calling
this line:

{{{

map2d_1[y] = y + x
# and then this fails
map2d_1.write(mapname="map2d_1", overwrite=True)

ERROR: Unable to open
        </home/anna/grassdata/xyLocation/anna/.tmp/anna-laptop/12383.0>

}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2616&gt;
GRASS GIS <http://grass.osgeo.org>

#2616: grass.script.array cannot write raster
-------------------------+--------------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.1
Component: Python | Version: svn-trunk
Keywords: array | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [ticket:2616 annakrat]:
> It seems the r64426 (backported in r64614) broke writing the array.
> Tested [http://grass.osgeo.org/grass70/manuals/libpython/script.html
example] with 1.8.2 !NumPy, the temporary file disappears once calling
this line:

It appears that __del__ gets called on the original array instance for
every slice. Note that changing `map2d_1[y]=` to `map2d_1[y,x]=` (which
is to be preferred) avoids the issue, but there are situations where
slicing will be appropriate, so this needs to be dealt with.

The docstring for numpy.memmap says:

{{{
     This subclass of ndarray has some unpleasant interactions with
     some operations, because it doesn't quite fit properly as a subclass.
}}}

r64819 wraps the temporary file in an object, avoiding the need for a
__del__ method in the array/array3d class. This appears to solve the
issue.

r64820 fixes the examples to use multi-dimensional indexing rather than
slicing.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2616#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2616: grass.script.array cannot write raster
--------------------------+-------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: critical | Milestone: 7.0.1
Component: Python | Version: svn-trunk
Resolution: | Keywords: array
       CPU: Unspecified | Platform: All
--------------------------+-------------------------

Comment (by neteler):

What is the state here? It appears that the aforementioned changes got
backported.

Issue solved?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2616#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2616: grass.script.array cannot write raster
--------------------------+-------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: critical | Milestone: 7.0.1
Component: Python | Version: svn-trunk
Resolution: fixed | Keywords: array
       CPU: Unspecified | Platform: All
--------------------------+-------------------------
Changes (by annakrat):

* status: new => closed
* resolution: => fixed

Comment:

Replying to [comment:2 neteler]:
> What is the state here? It appears that the aforementioned changes got
backported.
>
> Issue solved?
I believe so.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2616#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>