Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Apparent is/equality failures in Python 3.4, 3.5 on Windows #12096

Closed
@effigies

Description

@effigies

Over in nipy/nibabel, we're encountering an intermittent bug in AppVeyor tests, specifically for Python 3.4 and 3.5. All of the failures seem to involve numpy objects, so there's some chance that it is a numpy problem.

The issue seems to be that an object is not recognized as itself, which leads me to think that it's a failing is check. I will walk through the exceptions below.

This has been happening with low frequency since June 8, with markedly greater frequency in the last month or two. (We have four jobs that hit this issue: C:\Python3{4,5}{,-x64}. Any given one may pass or fail in any given build, but the odds of all four passing seem to have dropped significantly.)

Here is the first known failure: https://ci.appveyor.com/project/nipy/nibabel/build/1.0.379/job/7ftediiuui4ofvep
And a recent failure: https://ci.appveyor.com/project/nipy/nibabel/build/1.0.506/job/wnxtbgrvcr7lr2y7

cc @matthew-brett @yarikoptic @chrispycheng

Reproducing code example:

We've been unable to reproduce in any other environment, so a minimal example is impossible.

Error message:

======================================================================
ERROR: autogenerated test from validate_data_deprecated
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_api_validators.py", line 23, in meth
    validator(self, imaker, params)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_image_api.py", line 380, in validate_data_deprecated
    assert_data_similar(img._data, params)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_helpers.py", line 80, in assert_data_similar
    real_arr = np.asarray(arr)
  File "c:\python34-x64\lib\site-packages\numpy\core\numeric.py", line 501, in asarray
    return array(a, dtype, copy=False, order=order)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 261, in __array__
    return self.minc_file.get_scaled_data()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 139, in get_scaled_data
    return self._normalize(raw_data, sliceobj)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 189, in _normalize
    dmin, dmax = self._get_valid_range()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 98, in _get_valid_range
    info = np.iinfo(ddt.type)
  File "c:\python34-x64\lib\site-packages\numpy\core\getlimits.py", line 516, in __init__
    raise ValueError("Invalid integer data type.")
ValueError: Invalid integer data type.
======================================================================
ERROR: nibabel.tests.test_minc2.TestMinc2File.test_array_proxy_slicing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_minc1.py", line 200, in test_array_proxy_slicing
    arr = img.get_data()
  File "c:\python34-x64\lib\site-packages\nibabel\dataobj_images.py", line 202, in get_data
    data = np.asanyarray(self._dataobj)
  File "c:\python34-x64\lib\site-packages\numpy\core\numeric.py", line 553, in asanyarray
    return array(a, dtype, copy=False, order=order, subok=True)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 261, in __array__
    return self.minc_file.get_scaled_data()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 139, in get_scaled_data
    return self._normalize(raw_data, sliceobj)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 189, in _normalize
    dmin, dmax = self._get_valid_range()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 98, in _get_valid_range
    info = np.iinfo(ddt.type)
  File "c:\python34-x64\lib\site-packages\numpy\core\getlimits.py", line 516, in __init__
    raise ValueError("Invalid integer data type.")
ValueError: Invalid integer data type.
======================================================================
ERROR: nibabel.tests.test_minc2.TestMinc2File.test_load
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_minc1.py", line 187, in test_load
    data = img.get_data()
  File "c:\python34-x64\lib\site-packages\nibabel\dataobj_images.py", line 202, in get_data
    data = np.asanyarray(self._dataobj)
  File "c:\python34-x64\lib\site-packages\numpy\core\numeric.py", line 553, in asanyarray
    return array(a, dtype, copy=False, order=order, subok=True)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 261, in __array__
    return self.minc_file.get_scaled_data()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 139, in get_scaled_data
    return self._normalize(raw_data, sliceobj)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 189, in _normalize
    dmin, dmax = self._get_valid_range()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 98, in _get_valid_range
    info = np.iinfo(ddt.type)
  File "c:\python34-x64\lib\site-packages\numpy\core\getlimits.py", line 516, in __init__
    raise ValueError("Invalid integer data type.")
ValueError: Invalid integer data type.
======================================================================
ERROR: nibabel.tests.test_minc2.TestMinc2File.test_mincfile_slicing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_minc1.py", line 171, in test_mincfile_slicing
    data = mnc.get_scaled_data()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 139, in get_scaled_data
    return self._normalize(raw_data, sliceobj)
  File "c:\python34-x64\lib\site-packages\nibabel\minc1.py", line 189, in _normalize
    dmin, dmax = self._get_valid_range()
  File "c:\python34-x64\lib\site-packages\nibabel\minc2.py", line 98, in _get_valid_range
    info = np.iinfo(ddt.type)
  File "c:\python34-x64\lib\site-packages\numpy\core\getlimits.py", line 516, in __init__
    raise ValueError("Invalid integer data type.")
ValueError: Invalid integer data type.

These first few are related to #12093. If we can get that data, it will be easier to debug, but we will also be trying to catch the error on our end. I'm including these because when they always co-occur with other failures.

======================================================================
ERROR: nibabel.tests.test_processing.test_spatial_axes_check
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\numpy\testing\_private\decorators.py", line 155, in skipper_func
    return f(*args, **kwargs)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_processing.py", line 366, in test_spatial_axes_check
    out = resample_from_to(img, img, mode='nearest')
  File "c:\python34-x64\lib\site-packages\nibabel\processing.py", line 180, in resample_from_to
    cval=cval)
  File "c:\python34-x64\lib\site-packages\scipy\ndimage\interpolation.py", line 416, in affine_transform
    filtered = spline_filter(input, order, output=numpy.float64)
  File "c:\python34-x64\lib\site-packages\scipy\ndimage\interpolation.py", line 113, in spline_filter
    spline_filter1d(input, order, axis, output=output)
  File "c:\python34-x64\lib\site-packages\scipy\ndimage\interpolation.py", line 82, in spline_filter1d
    _nd_image.spline_filter1d(input, order, axis, output)
RuntimeError: array type dtype('float64') not supported
======================================================================
FAIL: autogenerated test from validate_data_interface
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_api_validators.py", line 23, in meth
    validator(self, imaker, params)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_image_api.py", line 208, in validate_data_interface
    self._check_proxy_interface(imaker, meth_name)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_image_api.py", line 253, in _check_proxy_interface
    assert_true(data is data_again)
AssertionError: False is not true

Although a caching object failing to return the identical object seems a reasonable bug, this is what led me to start thinking that it might be a bug in the is check. The cached object is an ndarray.

======================================================================
FAIL: autogenerated test from validate_dtype
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_api_validators.py", line 23, in meth
    validator(self, imaker, params)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_image_api.py", line 178, in validate_dtype
    assert_equal(img.get_data_dtype().type, params['dtype'])
AssertionError: <class 'numpy.float64'> != <class 'numpy.float64'>
======================================================================
FAIL: nibabel.tests.test_minc2.TestMinc2File.test_mincfile
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python34-x64\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "c:\python34-x64\lib\site-packages\nibabel\tests\test_minc1.py", line 159, in test_mincfile
    assert_equal(mnc.get_data_dtype().type, tp['dtype'])
AssertionError: <class 'numpy.float64'> != <class 'numpy.float64'>
----------------------------------------------------------------------

And these two amount to numpy.float64 is numpy.float64 failing.

Numpy/Python version information:

One example:

1.15.2 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:07:06) ...

screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions