Opened 5 years ago

Closed 4 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)

comment:1 in reply to:  description Changed 5 years ago by glynn

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 Changed 4 years ago by neteler

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

Issue solved?

comment:3 in reply to:  2 Changed 4 years ago by annakrat

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.