emorice / gemz

Gene expression model zoo
0 stars 0 forks source link

Fix inheritance patterns #12

Closed emorice closed 2 years ago

emorice commented 2 years ago

The inheritance between models sometimes makes no sense as a class may implement a fit method that is completely incompatible with the parent's.

Since the inheritance was meant to allow delegating predict_loo methods mostly, these should be factored away in abstract classes that lack a concrete fit.

emorice commented 2 years ago

However, the obtained class has only one method, so you simply keep it as a function and assign it to the "children" classes instead of inheriting.

In that case, we don't have inheritance at all in the end. However, we still bundle fit/predict in classes. It's still a bit weird, but that's a rather well-accepted pattern it seems.

emorice commented 2 years ago

Also we end up with classes with only static methods. In that case you may just as well register the module itself, add_module has been added to the new models.methods for this.

There are still useless classes for now, to be eliminated over time, but I think we have a mix of two valid patters now anyway.