-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I'm having second thoughts about how we are using __init__ and __call__ in the zgr child classes.
The parent Zgr knows about jpk, but it doesn't do any computationally expensive stuff when it is initialized.
I.e., I don't think there's any advantage in initializing the class only once. I also think it is easier to do:
ds.domcfg.sco(jpk=31, **kwargs)rather than
ds.domcfg.jpk = 31
ds.domcfg.sco(**kwargs)I suggest we move __call__ in Zgr, where call does not have any argument and returns the final object with all z3 and e3.
The parent __init__ can stay as it is: __init__(obj, jpk).
Childs' __init__ would just add arguments to the parent __init__.
Finally, compute_z3 should be an abstract method in the parent class (Zgr), and that abstract method should be used by the parent class to generate z3 needed to compute e3.
Recap:
- Child classes should look like this:
Zco(obj, jpk, ...). Child classes initialize additional arguments and their__init__end withsuper().__init__(obj, jpk) - The only constraint for child classes is that they have a method that computes and return
z3. How they do it, it's notZgrbusiness. - Direct call of classes looks like this
ds_out = Zco(ds_in, jpk, **kwargs)() - The public API looks like this:
ds_out = ds_in.domcfg.zco(jpk, **kwargs)