I have 2 large arrays stored using h5py. I want to make some basic numpy operations like addition, subtraction, etc. What is the most elegant way to do so?
f = h5py.File('x', 'w')
d1 = f.create_dataset('1', (100000, 10000), 'i')
d2 = f.create_dataset('2', (100000, 10000), 'i')
d2[:] = 1
np.add(d2, d2, out=d1)
np.add() has problem with the output argument because its not ArrayType. I'm assuming that I need to implement addition function by my self loading the whole file only block-wise and so don't "eat" all the memory, right? Something like this:
for block_index in range(d2.shape[0]):
d1[block_index:] = d2[block_index:] + d2[block_index:]
Or is there any nicer solution?
Thanks