DESC
DESC copied to clipboard
Add ability to define a function parameteriztaion for a subclass of an already existing function parameterization
If we want to add a new compute function for a parameterization which is a subclass of a parametrization with an existing function (for example, if we had length
use the Curve
as its paramaterization then have a separate function for length
with SplineXYZCurve
as its parameterization), we can't simply just make one function with the superclass as a parameterization then one function with the one subclass as its parameterization.
This PR changes the logic to allow this, with the caveat that the subclass function must appear AFTER the superclass function (so if in the same file, it must appear after, and if they are in different files, the file where the superclass function is defined should be imported in compute/__init__.py
before the file where the subclass function is defined)
I would like this change for a couple reasons
- it is intuitive and follows the superclass/subclass method behavior we are used to for Python classes
- It can reduce the amount of function definitions needed in
compute
, and allow us to subclass a class and make a new compute parameterization for it without needing to re-define every compute function or needing to make a subclass for the original class. (as an example, if I subclassedEquilibrium
with some thing else which requires a different kind of basis vector but otherwise can use all the downstream function definitions for the metrics etc, I would not be able to just add it currently, but with this change we can do so with minimal changes)
This is related to Xu trying to have a branch of DESC where both straight and toroidal equilibria can be computed, this would make that change easier