You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Another problem with the initializers is the following one. Sub-classes must define the member variables 'name' and 'aseeds' BEFORE calling the super-initializer, because these are needed during the execution of the latter.
For example: https://github.com/scicubator/nimfa/blob/master/nimfa/methods/factorization/nmf.py#L160
This creates a weird mutual dependency between the parent and its sub-classes.
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.
The text was updated successfully, but these errors were encountered: