-
- import numy as np
-
- a = np.arange(24, dtype='f8').reshape(2, 3, 4).T
- it = np.nditer(a, [],[['readwrite', 'updateifcopy']],casting='same_kind',op_dtypes=[np.dtype('f4')])
- op = it.operands[0]
- x = op[1:-1] # x is a view into op
- x[...] = 14
- assert x.base.flags.writebackifcopy is True
- assert (x.base.base is a) is True
-
- it.resolve_writeback() # new method to resolve writebacks
-
- it.operands[0][0] #segfaults
- assert op.ctypes.data == 0 # writeback has finished, op is no longer a valid ndarray
- x.base # segfault
-