Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy pre-release breaks setting some arrays writable #697

Closed
effigies opened this issue Dec 3, 2018 · 8 comments · Fixed by #700
Closed

Numpy pre-release breaks setting some arrays writable #697

effigies opened this issue Dec 3, 2018 · 8 comments · Fixed by #700

Comments

@effigies
Copy link
Member

effigies commented Dec 3, 2018

Most likely culprit is numpy/numpy#11739, which was merged 7 days ago.

Example failures:

ERROR: test_load_simple_file (nibabel.streamlines.tests.test_streamlines.TestLoadSave)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/tests/test_streamlines.py", line 152, in test_load_simple_file
    lazy_load=lazy_load)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/__init__.py", line 96, in load
    return tractogram_file.load(fileobj, lazy_load=lazy_load)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/tck.py", line 154, in load
    streamlines = ArraySequence(tck_reader)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/array_sequence.py", line 93, in __init__
    self.extend(iterable)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/array_sequence.py", line 239, in extend
    for e in elements:
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/tck.py", line 436, in _read
    pts.flags.writeable = True
ValueError: cannot set WRITEABLE flag to True of this array
ERROR: test_load_complex_file_in_big_endian (nibabel.streamlines.tests.test_trk.TestTRK)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/tests/test_trk.py", line 194, in test_load_complex_file_in_big_endian
    'complex_trk_big_endian_fname', endian='>')
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/streamlines/tests/test_trk.py", line 109, in trk_with_bytes
    trk_struct.flags.writeable = True
ValueError: cannot set WRITEABLE flag to True of this array
ERROR: test_big_offset_exts (nibabel.tests.test_analyze.TestAnalyzeImage)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/tests/test_analyze.py", line 809, in test_big_offset_exts
    assert_array_equal(arr, img_back.dataobj)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/numpy/testing/_private/utils.py", line 873, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/numpy/testing/_private/utils.py", line 693, in assert_array_compare
    y = array(y, copy=False, subok=True)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/arrayproxy.py", line 356, in __array__
    raw_data = self.get_unscaled()
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/arrayproxy.py", line 351, in get_unscaled
    mmap=self._mmap)
  File "/home/travis/build/nipy/nibabel/venv/lib/python2.7/site-packages/nibabel/volumeutils.py", line 543, in array_from_file
    arr.flags.writeable = True
ValueError: cannot set WRITEABLE flag to True of this array
@skoudoro
Copy link
Member

skoudoro commented Dec 8, 2018

We got the same error on DIPY project as you can see here

@eric-wieser
Copy link

Why doesn't the readinto path get reached here that bypasses the readonly buffer?

@effigies
Copy link
Member Author

@eric-wieser That error is only hit in the Python 2.7 tests, so it's due to readinto not existing in Py2.

@eric-wieser
Copy link

eric-wieser commented Dec 11, 2018

I see readinto here, so it looks like it at least exists in python 2. What object are you passing that's missing that attribute?

@matthew-brett
Copy link
Member

@eric-wieser - Python 2.7 hits this path with Bzip2 files.

@eric-wieser
Copy link

eric-wieser commented Dec 11, 2018

Can you take a dependency on the bz2file backport, @effigies?

@yarikoptic
Copy link
Member

FWIW, this issue hit Debian now as well https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917680

@effigies
Copy link
Member Author

Okay. I guess we should go ahead and merge #700 and cut a bug-fix release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants