NeuroDiffGym / neurodiffeq

A library for solving differential equations using neural networks based on PyTorch, used by multiple research groups around the world, including at Harvard IACS.
http://pypi.org/project/neurodiffeq/
MIT License
687 stars 90 forks source link

Save Load Custom Classes inheriting solvers #195

Closed sathvikbhagavan closed 1 year ago

shuheng-liu commented 1 year ago

A possible concern is what if someone write their own subclass with multiple inheritance

class MySolver(SomeOtherClass, Solver1D):
    pass

where SomeOtherClass precedes Solver1D

In this case, we need to check self.__class__.__bases__[1] instead of self.__class__.__bases__[0]

sathvikbhagavan commented 1 year ago

isinstance(self, neurodiffeq.solvers.Sovler1D)

Yes, there was no particular reason to use strings. We should definitely use isinstance in the future

A possible concern is what if someone write their own subclass with multiple inheritance

Yes, I have assumed no multiple inheritance where the common case is to inherit neurodiffeq solvers for additional loss. We should tackle that for saving and loading in the future