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
Fix "_p_void" values in TVTK with VTK 6.x #370
Fix "_p_void" values in TVTK with VTK 6.x #370
Conversation
Current coverage is 45.53%@@ master #370 diff @@
==========================================
Files 258 258
Lines 22909 23011 +102
Methods 0 0
Messages 0 0
Branches 3030 3036 +6
==========================================
+ Hits 10451 10476 +25
- Misses 11729 11805 +76
- Partials 729 730 +1
|
@@ -272,6 +274,11 @@ class TVTKBase(traits.HasStrictTraits): | |||
# The wrapped VTK object. | |||
_vtk_obj = traits.Trait(None, None, vtk.vtkObjectBase()) | |||
|
|||
# Stores the names of the traits whose VTK Get methods may return | |||
# invalid values (e.g. reference to a point) or uninitialised values | |||
# We would try to update but allow it to failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"allow it to fail" :)
This is too much code to review without being told more. |
If you try to run the new tvtk test case with the master branch + VTK 6.3, you should see a bunch of failures: https://gist.github.com/kitchoi/8e92ad08e44334133360536ce3d5bdff |
The problem now is that it's very hard to differentiate between what you changed for the fix and what you refactored. |
I think it's time we ditch codecov until they fix this unexpected changes problem. |
If you want less of the refactoring changes, try git diff the master and this commit: 7a30bdd |
Try pushing a dummy change. I disabled codecov |
if klass.__name__ == 'vtkCubeAxesActor2D' and \ | ||
name == 'inertia': | ||
# VTK bug. Inconsistent API! | ||
rng = (float(rng[0]), float(rng[1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the special handling of 'vtkCubeAxesActor2D.inertia' here because from what I have researched on the VTK API, inertia
is indeed an int
and there is no inconsistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quite possible this was a bug with VTK 4.x or so which is not relevant anymore so this is fine.
apparently the codecov yaml file did not solve for this branch |
I think the "codecov/project" captures the increase in coverage after we added VTK 6.3 and VTK 7 in the test matrix, it raises a red flag because it did not expect those changes (who knows how they decide what they should expect). |
@@ -295,7 +294,8 @@ def get_other_methods(self): | |||
""" | |||
return self.other_meths | |||
|
|||
def get_method_signature(self, method): | |||
@staticmethod | |||
def get_method_signature(method): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many occurrence of parser = VTKMethodParser(); parser.get_method_signature(...)
in wrapper_gen and in tests (and possibly some other places I have not touched), could do with a separately cleanup PR in order to move this function out of the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave it as is. not top priority. If you want, open a issue tagged refactoring.
self._write_trait(out, name, t_def, vtk_set_meth, mapped=False) | ||
|
||
def _write_hardware_selector_prop_color_value(self, klass, out, | ||
vtk_attr_name='PropColorValue'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that you have to pass a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have to. But I think it acts as a form of documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the intent, but it's deceiving. When I see that, I don't expect it to be documentation.
You already enforce the value in the content. When I see that I assume that the method can be called without any passed vtk_attr_name for some reason, and you are "fixing" that behavior with the only acceptable value, but the vtk_attr_name is always passed, only in this routine must be one and only one value, otherwise there's a programming error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the default value now. Unfortunately I have to keep the signature consistent, so vtk_attr_name
is kept there.
Review ready. Merge when done (they are mostly minor). |
How is this related to issue #385 ? did you skip the test? |
What is issue #907? |
Fixed. I pasted the wrong content. |
# e.g. x = numpy.empty(9); ImageConvolve.GetKernel3x3(x) | ||
# FIXME: we could try harder in retrieving these values | ||
# in TVTKBase.update_traits | ||
del updateable_traits[name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change del updateable_traits[name]
to allow_update_failure.add(name)
, the difference in behaviour is not only that TVTKBase.update_traits will have more updating to do while those updating will almost certainly fail with TraitError, but I will also get these traits visible on the UI.
E.g. with del updateable_traits[name]
obj = tvtk.ImageConvolve(); obj.configure_traits()
E.g. replace with allow_update_failure.add(name)
Question is, which one do we want. The bahaviour on the interactive interpreter is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corran suggested using TextEditor for these arrays. Unfortunately I am preoccupied at the moment. I think I would attack this problem in a separate PR if and after this one is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Maybe adding an issue for that would be good so we don't forget.
I did not do anything about #385, the error is still there (look at VTK 6.3 and VTK 7) |
…ove error message
def test_spider_plot_actor(self): | ||
""" Test SpiderPlotActor Get/SetAxisLabel works | ||
""" | ||
actor = tvtk.SpiderPlotActor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if there were a comment as to why this object is tested that would be helpful.
Note to self
|
return 'traits.Array', '', kwargs | ||
|
||
elif type_ is bool: | ||
return 'traits.Bool', '', kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, return 'traits.Bool', str(value), kwargs
|
||
if vtk_attr_name != 'PropColorValue': | ||
raise RuntimeError("Not sure why you ask for me! " | ||
"I only deal with PropColorValue. Panicking.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa, why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to prevent this method being used with vtk_attr_name
other than PropColorValue
. This may be unnecessary given the method is private and is used internally.
Thanks for this, it looks nice and the code looks a lot cleaner than before! I will merge this for now. |
I have tested this with VTK 6.2 and 6.3 on Ubuntu 12, and VTK 6.3 on OSX 10.11
Things seem to work but since this is a fundamental change, I would prefer sitting on it for a bit longer. Review and comments are very much appreciated.
Most of these changes are tested by the existing TVTK test for initialising all classes, but I think I could also add more tests to make it more robust.
To compare the bahaviour, try the following with the master branch and with this one: