Skip to content

FIX: Fix for VTKNoneArray#729

Merged
prabhuramachandran merged 1 commit into
enthought:masterfrom
larsoner:VTKNoneArray
Nov 15, 2018
Merged

FIX: Fix for VTKNoneArray#729
prabhuramachandran merged 1 commit into
enthought:masterfrom
larsoner:VTKNoneArray

Conversation

@larsoner
Copy link
Copy Markdown
Collaborator

This fixes a bug I've hit because the check for VTKNoneArray is in the wrong spot, so you can get an error on line 83:

has_nan = np.isnan(x).any()

That looks like:

>>> np.isnan(None)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 25, 2018

Codecov Report

Merging #729 into master will decrease coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #729     +/-   ##
=========================================
- Coverage   51.77%   51.57%   -0.2%     
=========================================
  Files         259      259             
  Lines       23424    23424             
  Branches     3200     3200             
=========================================
- Hits        12127    12081     -46     
- Misses      10509    10558     +49     
+ Partials      788      785      -3
Impacted Files Coverage Δ
mayavi/core/utils.py 95.28% <100%> (+1.88%) ⬆️
mayavi/filters/extract_grid.py 64.61% <0%> (-9.24%) ⬇️
tvtk/pyface/ui/qt4/scene.py 37.15% <0%> (-5.97%) ⬇️
mayavi/sources/array_source.py 74.85% <0%> (-4.2%) ⬇️
mayavi/components/grid_plane.py 81.31% <0%> (-3.3%) ⬇️
mayavi/modules/grid_plane.py 84.21% <0%> (-2.64%) ⬇️
tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py 38% <0%> (-1.34%) ⬇️
tvtk/pyface/tvtk_scene.py 34.79% <0%> (-1.05%) ⬇️
tvtk/vtk_parser.py 89.18% <0%> (-0.88%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3fc352...e656732. Read the comment docs.

Copy link
Copy Markdown
Member

@prabhuramachandran prabhuramachandran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks but I would appreciate a tiny test case for this, I am not sure it should be too hard to make one. You could put the test in the test_mlab_integration.py or any suitable file.

@larsoner
Copy link
Copy Markdown
Collaborator Author

larsoner commented Oct 26, 2018

I've spent about half an hour trying to figure out how to get it to the state where there is a VTKNoneArray in there from the Mayavi tests and source with no luck. I'll take some more time trying to remember which use case elicited the error in the first place and try to do some debugging there (but IIRC, it's a pain because it's in a complex interactive Traits-based GUI).

@prabhuramachandran
Copy link
Copy Markdown
Member

Ahh, sorry to hear that. This is why it is useful to have the test case. :) You can create a VTK dataset perhaps to trigger it without having to go through mlab/mayavi if that helps. I will wait a bit in case the light bulb goes on but if it doesn't, and it seems too hard, I'll see if I can think of a test and add it. Thanks!

@larsoner
Copy link
Copy Markdown
Collaborator Author

You can create a VTK dataset perhaps to trigger it without having to go through mlab/mayavi if that helps.

I've spent another half an hour trying to do this with something like the following in test_core_utils.py:

    def test_get_range_works_for_VTKNoneArray(self):
        id_ = tvtk.ImageData(dimensions=(2, 2, 1), origin=(0, 0, 0),
                             spacing=(1, 1, 1))
        id_.point_data.scalars = dsa.VTKNoneArray()
        dsh = DataSetHelper(id_)
        self.assertEqual(dsh.get_range(), (None, [0, 1]))

But this gives:

E           TypeError: SetScalars argument 1: method requires a VTK object

I cannot figure out how to get the scalars property to be a VTKNoneArray object.

@larsoner
Copy link
Copy Markdown
Collaborator Author

Okay I finally found a test that passes on my system. But it also exposes that there is some updating wackiness in that calling get_range() twice can yield different results. No idea how to fix that one, but at least this does not crash with the ufunc 'isnan' not supported error anymore.

@prabhuramachandran
Copy link
Copy Markdown
Member

Sorry for the delay, looks good, will merge this and look at your other PR.

@prabhuramachandran prabhuramachandran merged commit 7253446 into enthought:master Nov 15, 2018
@prabhuramachandran
Copy link
Copy Markdown
Member

Thanks!

@larsoner larsoner deleted the VTKNoneArray branch November 15, 2018 13:18
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 this pull request may close these issues.

3 participants