multiple inheritance in VTK 9.4.1 for Python?

Hello, I’m getting an unexpected error in a VTK Python project.

Basically I have a class that is derived from vtkPolyData and another custom-built class with multiple inheritance.

It was working flawlessly up to VTK 9.3.1, but updating to 9.4.1 it throws an “Unexpected keyword argument” error, referring to an argument of the custom class.

I interpret it as vtkPolyData refusing to exchange kwargs with the other base class, or refusing to accept multiple inheritance in general.

Is this some new feature of 9.4.1? Because it was working with 9.3.1 and I did not change anything in my code, except upgrading from 9.3.1 to 9.4.1…

Thanks!

One of the changes in VTK 4.1 is that several data classes, including vtkPolyData, are automatically replaced by customizations from vtkmodules.util.data_model.

So in your own code, when you try to instantiate a vtkPolyData, you’re actually getting an instance of vtkmodules.util.data_model.PolyData. This is probably what is messing up the multiple inheritance.

To check if this is the case, try adding the following to your program before any VTK modules are loaded:

import vtkmodules
vtkmodules.MODULE_MAPPER = {}

This will disable the VTK 4.1 mechanism for auto-loading util/data_model.py.

I presume you mean 9.4.1 here.

@berk.geveci FYI. Not sure if this is something to consider as use case or not.

Thanks, yes, I meant VTK 9.4.1.

It isn’t yet certain whether the data_model overrides are the cause of the issues with the OP’s code.

Thanks!

However, if I’m not mistaken, turning off the new data_model implies loosing the Numpy access to arrays, which is the main reason to upgrade to 9.4.1 for me.

Correct?

Yes, but please try turning it off to check whether it’s the reason that your multiple-inherited subclass is failing.

Hello, I cannot use your solution because I’m not importing the whole module but specific classes individually, and I cannot test in detail since I’m out of office, but it makes sense that multiple inheritance is the problem. I tried to use composition instead and, even if I did not manage to complete the reviewed code, I get new and more reasonable errors.

I’ll add more details ASAP.

Thanks!

You can still import vtkpython if you’re importing classes individually. All this does is import the package-level __init__.py, it doesn’t import the package contents.