Good day coders and codereses,
I am writing a piece of code that goes through a pile of statistical data and returns what I ask from it. To complete its task the method reads from one multidimensional array and writes into another one. The piece of code giving me problems is:
writer.variables[variable][:, :, :, :] = reader.variables[variable][offset:, 0, 0:5, 3]
The size of both slices is 27:1:6:1 but it throws up an exception:
ValueError: total size of new array must be unchanged
I am flabbergasted.
Thank you.
The size of a slice with
0:5is not 6 as you say: it’s 5. The upper limit is excluded in slicing (as it most always is, in Python). Don’t know whether that’s your actual problem or just a typo in your question…