2

I cannot load an array from a binary file. What am I doing wrong?

pic = imread('headey-640.bmp')
save('test.in.npy', pic)
f = open('test.in.npy','r')
A = load(f)

---------------------------------------------------------------------------
ValueError: total size of new array must be unchanged
1
  • Please do not use images to show us your code. This way it is much harder for others to find you question. Use the code blocks from the editor to nicely format your code and error messages. Commented Jan 25, 2015 at 22:00

1 Answer 1

5

You have to open your file in binary mode:

import numpy as np

x = np.array([1,2,3])
np.save("test.npy", x)

with open("test.npy", "rb") as npy:
    a = np.load(npy)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.