Commit d7693e87 authored by Ivan Tyagov's avatar Ivan Tyagov

Implement array slicing in its most simple list alike form + test of it.

parent 81c688e0
......@@ -74,3 +74,11 @@ class DataArray(BigFile):
# .zfile) have to be made explicitly known to connection or current
# transaction committed (XXX: impossible to use as raises ConflictErrors)
transaction.commit()
def getArraySlice(self, start, end):
"""
Implement array slicing in its most simple list alike form.
Any other advanced slicing techniques currently possible by getting
array reference directly.
"""
return self.getArray()[start:end]
\ No newline at end of file
......@@ -259,3 +259,24 @@ context.activate().DataStream_readChunkListAndTransform( \
# resize Zbig Array
persistent_zbig_array = np.resize(persistent_zbig_array, (100,100))
self.assertNotEquals(pure_numpy_array.shape, persistent_zbig_array.shape)
# get array slice (fails)
data_array = self.portal.data_array_module.newContent( \
portal_type = 'Data Array')
shape = (1000,)
data_array.initArray(shape, np.uint8)
self.tic()
persistent_zbig_array = data_array.getArray()
new_array = np.arange(1000)
new_array.resize(shape)
self.assertEquals(new_array.shape, persistent_zbig_array.shape)
persistent_zbig_array[:,] = new_array
self.tic()
self.assertTrue(
np.array_equal(data_array.getArraySlice(0,100), \
new_array[:100]))
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment