Opened 9 years ago

Closed 9 years ago

#2616 closed defect (fixed)

grass.script.array cannot write raster

Reported by: annakrat Owned by: grass-dev@…
Priority: critical Milestone: 7.0.1
Component: Python Version: svn-trunk
Keywords: array Cc:
CPU: Unspecified Platform: All

Description

It seems the r64426 (backported in r64614) broke writing the array. Tested example with 1.8.2 NumPy, the temporary file disappears once calling this line:

map2d_1[y][x] = 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>

Change History (3)

in reply to:  description comment:1 by glynn, 9 years ago

Replying to annakrat:

It seems the r64426 (backported in r64614) broke writing the array. Tested 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][x]= 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.

comment:2 by neteler, 9 years ago

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

Issue solved?

in reply to:  2 comment:3 by annakrat, 9 years ago

Resolution: fixed
Status: newclosed

Replying to neteler:

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

Issue solved?

I believe so.

Note: See TracTickets for help on using tickets.