Skip to content

Strange use of Python inheritance

Looking at /src/distil-primitives/distil/primitives/image_transfer.py. You do things like:

PrimitiveBase.__init__(self, hyperparams=hyperparams, random_seed=random_seed, volumes=volumes)

This is some strange Python. :-) You should be doing:

super().__init__(self, hyperparams=hyperparams, random_seed=random_seed, volumes=volumes)

This assures that parents are traversed correctly. Not using super() should be done only in extreme cases where you want to override default traversal.

Because you are not using super(), you in fact have a bug. This primitive has parent class:

class ImageTransferPrimitive(unsupervised_learning.UnsupervisedLearnerPrimitiveBase[container.DataFrame, container.DataFrame, Params, Hyperparams]):

But your import is:

from d3m.primitive_interfaces.supervised_learning import PrimitiveBase

So, you are importing from supervised_learning and in fact you are importing a value not even defined in that file but in the base primitive interface file. You should be calling unsupervised_learning.UnsupervisedLearnerPrimitiveBase.__init__ there, if anything.

Conclusion: just use super(). :-)