It is probably a question more of fastcore
, but it is on the nbdev
dev environment that I need it.
I have a class with many constructors as @classmethod
of the style from_csv
, from_file
, etc…
They are long and complex, so I wanted to split the cells and test them separately. Can I do so with patch
or patch_to
?
Something like:
class foo():
def __init__(self, params): pass
@classmethod
def from_csv(cls, csv_file):
params = read_csv(csv_file)
return cls(params)
Do some doc, examples and tests, and add a new class method later:
@patch(foo)
@classmethod
def from_file(cls, file)
params = get_params_from_file(file)
return cls(params)
This does not work, but probably I am not that far away…