question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

test_interpolator fails with quite a swing: -3.4 vs 3

See original GitHub issue
smaug:/tmp/buildd/nipy-0.4.3~rc1# python3 -m nose .pybuild/cpython3_3.9_nipy/build/nipy/algorithms/tests/test_interpolator.py:test_interpolator
nipy.algorithms.tests.test_interpolator.test_interpolator ... FAIL

======================================================================
FAIL: nipy.algorithms.tests.test_interpolator.test_interpolator
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/build/nipy-0.4.3~rc1/.pybuild/cpython3_3.9_nipy/build/nipy/algorithms/tests/test_interpolator.py", line 23, in test_interpolator
    assert_almost_equal(interp.evaluate([0, 0, 4]), arr[0, 0, -1])
  File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 579, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 1042, in assert_array_almost_equal
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
  File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 7 decimals

Mismatched elements: 1 / 1 (100%)
Max absolute difference: 6.4
Max relative difference: 2.13333333
 x: array(-3.4)
 y: array(3)
>>  raise AssertionError('\nArrays are not almost equal to 7 decimals\n\nMismatched elements: 1 / 1 (100%)\nMax absolute difference: 6.4\nMax relative difference: 2.13333333\n x: array(-3.4)\n y: array(3)')

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
matthew-brettcommented, Feb 22, 2021

The key difference is here:

# Test 2D interpolation for Scipy
import numpy as np

import scipy.ndimage as spnd

arr = np.arange(6).reshape((2, 3))

coord = np.array([[0, 3]]).T
v1 = spnd.map_coordinates(arr,
                          coord,
                          order=3,
                          mode='nearest',
                         )
print('Calculate filter with interpolation', v1)

filtered = spnd.spline_filter(arr, order=3, mode='nearest')
v2 =  spnd.map_coordinates(filtered,
                           coord,
                           order=3,
                           mode='nearest',
                           prefilter=False)
print('Calculate filter followed by interpolation', v2)

On Scipy 1.2 this gives [2.] and [2.]. On Scipy 1.6.6 this gives [2.] and [2.20261874]. So it’s the difference between using precalculated knots via spline_filter, or calculating the knots afresh within map_coordinates.

I’ll file an issue with Scipy, and see what they say.

0reactions
matthew-brettcommented, Mar 29, 2021

I think this is fixed by #478 and #481 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic Tools, Specific Languages
tool to adapting the underlying languages to solve the problem of tool adapta- tion. It relies on language workbenches (the generic tool) and...
Read more >
Computer Graphics Using Java 2D and 3D - PDF Free Download
Appendix B, "GUI Programming with AWT and Swing," illustrates the differences ... of problems involved in 2D and 3D graphics systems may be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found