Skip to content

TriAnalyzer.scale_factors() has mismatched boolean indexes #4999

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

Closed
WeatherGod opened this issue Aug 27, 2015 · 4 comments
Closed

TriAnalyzer.scale_factors() has mismatched boolean indexes #4999

WeatherGod opened this issue Aug 27, 2015 · 4 comments

Comments

@WeatherGod
Copy link
Member

Testing matplotlib master with numpy 1.10rc1 revealed some possible bugs in matplotlib through deprecation warnings. One set of warnings comes from the triangulation library:

/nas/home/broot/centos6/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-linux-x86_64.egg/matplotlib/tri/tritools.py:52: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 5 but corresponding boolean dimension is 4
  x = self._triangulation.x[node_used]
/nas/home/broot/centos6/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-linux-x86_64.egg/matplotlib/tri/tritools.py:53: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 5 but corresponding boolean dimension is 4
  y = self._triangulation.y[node_used]

Indeed, adding a check in scale_factors() and running the triangulation test suite reveals:

======================================================================
ERROR: __main__.test_tritools
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nas/home/broot/centos6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "lib/matplotlib/tests/test_triangulation.py", line 834, in test_tritools
    assert_array_almost_equal(analyser.scale_factors,
  File "/nas/home/broot/centos6/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-linux-x86_64.egg/matplotlib/tri/tritools.py", line 55, in scale_factors
    len(node_used)))
ValueError: len of nodes does not match node_used. 5 vs. 4

The test in question:

def test_tritools():
    # Tests TriAnalyzer.scale_factors on masked triangulation
    # Tests circle_ratios on equilateral and right-angled triangle.
    x = np.array([0., 1., 0.5, 0., 2.])
    y = np.array([0., 0., 0.5*np.sqrt(3.), -1., 1.])
    triangles = np.array([[0, 1, 2], [0, 1, 3], [1, 2, 4]], dtype=np.int32)
    mask = np.array([False, False, True], dtype=np.bool)
    triang = mtri.Triangulation(x, y, triangles, mask=mask)
    analyser = mtri.TriAnalyzer(triang)
    assert_array_almost_equal(analyser.scale_factors,
                              np.array([1., 1./(1.+0.5*np.sqrt(3.))]))
   <snip>

@ianthomas23 , git blame tells me that you didn't write tritools.py, but perhaps you have some insights? Looks like it was introduced in cd45a80

@WeatherGod
Copy link
Member Author

attn: @GBillotey

@ianthomas23
Copy link
Member

@WeatherGod: Thanks for reporting this. Bug confirmed using numpy 1.10.0b1; trivial fix on its way.

@jenshnielsen
Copy link
Member

@ianthomas23 @WeatherGod Is this fully fixed?

@WeatherGod
Copy link
Member Author

Should be, now that the two PRs are in. If there are other sources of this bug in the tri module, I wouldn't know and the tests aren't picking up on it using numpy 1.10.

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

No branches or pull requests

3 participants