All the different methods initializers are calling the initializer of the parent class. For example, here:
nmf_std.Nmf_std.__init__(self, vars())
This is done in all the different NMF flavors, each calling the corresponding initializer.
I have two comments about this way of initializing things:
-
Wouldn't it be more pythonic to use super instead? It would also reduce the possibility of calling the wrong initializer by mistake.
-
vars() contains a reference to self, so in practice every instance contains a self-reference (self.self) after initialization. Although it does not hurt, I believe that this reference should be eliminated from the vars dictionary. This can be done in each subclass, e.g.,
params = vars()
del params['self']
nmf_std.Nmf_std.__init__(self, params)
It can also be done in the base class itself (Nmf_std in this case) to avoid code repetition.
I believe that making these simple and quick changes would improve object initialization in the library.
All the different methods initializers are calling the initializer of the parent class. For example, here:
nmf_std.Nmf_std.__init__(self, vars())This is done in all the different NMF flavors, each calling the corresponding initializer.
I have two comments about this way of initializing things:
Wouldn't it be more pythonic to use super instead? It would also reduce the possibility of calling the wrong initializer by mistake.
vars() contains a reference to self, so in practice every instance contains a self-reference (self.self) after initialization. Although it does not hurt, I believe that this reference should be eliminated from the vars dictionary. This can be done in each subclass, e.g.,
It can also be done in the base class itself (Nmf_std in this case) to avoid code repetition.
I believe that making these simple and quick changes would improve object initialization in the library.