ccpem/mrcfile

ValueError: cannot set WRITEABLE flag to True of this array

ssscj opened this issue · 4 comments

ssscj commented

Hi,
When I use mrc.open(file,'r') to open a mrcfile, sometimes the it raises ValueError: cannot set WRITEABLE flag to True of this array.
I don't know how to fix it by change parameters. I add # in mrcfile/mrcfileinterpreter.py 141 line header.flags.writeable = True, and make it run. How could I fix it in a better way?
Thanks.

Thanks for raising this. Could you let me know what operating system, Python version and numpy version you're using?

I'm curious that you say this error only happens sometimes. Do you have any idea why it might behave differently in different cases? Does it consistently work correctly for some files and fail for others, or does it sometimes work and fail with the same file?

ssscj commented

CentOS Linux release 7.5.1804 (core)
Python 3.7.4
numpy 1.18.5
My scripts worked correctly before, and a month ago it raised this error. The only change I could recall is that I updated numpy from 1.17 to 1.18, but I don't know if anyone else did something to the system.
Sorry for late reply.
Thanks for your help.

Thanks for the details, and sorry it's taken me a while to respond. I still can't reproduce this error myself, and I've now verified that mrcfile works fine for me with numpy 1.18 and 1.19. Do you have any examples of files that cause the problem?

I've just made a new release of mrcfile (v1.2.0) that removes the header.flags.writeable = True line that you mentioned. (I realised that after some more recent changes to fix a related issue, that line wasn't needed any more.)

I'll close this issue for now, but I am a bit concerned that we never figured out exactly what the root cause was. If you can, it'd be great if you could check what version of mrcfile you were using when you saw these errors. The fix for that other bug was made in mrcfile v1.1.2, so if you were using an older version that might explain it. With the code from v1.1.2 or later, though, I can't see how this error would occur. If you do find any similar problems in future, please do re-open this issue or raise a new one.