Skip to content

Commit

Permalink
Add abc inheritance/decorators for propper polymorphism.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaminow committed Oct 18, 2023
1 parent 08903e3 commit 2288017
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion mtenn/combination.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import abc
import torch


class Combination(torch.nn.Module):
class Combination(torch.nn.Module, abc.ABC):
@abc.abstractmethod
def forward(self, pred_list, grad_dict, param_names, *model_params):
"""
This function signature should be the same for any Combination subclass
Expand Down
3 changes: 2 additions & 1 deletion mtenn/readout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import abc
import torch
from typing import Optional


class Readout(torch.nn.Module):
class Readout(torch.nn.Module, abc.ABC):
pass


Expand Down
3 changes: 2 additions & 1 deletion mtenn/representation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import abc
import torch


class Representation(torch.nn.Module):
class Representation(torch.nn.Module, abc.ABC):
pass
3 changes: 2 additions & 1 deletion mtenn/strategy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import abc
from itertools import permutations
import torch


class Strategy(torch.nn.Module):
class Strategy(torch.nn.Module, abc.ABC):
pass


Expand Down

0 comments on commit 2288017

Please sign in to comment.