pmrf.wrap
- pmrf.wrap(func, *args, as_numpy=False)[source]
Wrap a function/method taking
(model, frequency, *args, **kwargs)into one that accepts flat arrays.The wrapper accepts
(theta, [f], *args, **kwargs)wherethetais a flat parameter array, and optionallyfis a frequency array with a provided unit.Supported calls
wrap(userfunc, model, "MHz")wrap(userfunc, model, freq)wrap(model.userfunc, "MHz")wrap(model.userfunc, freq)
If a
Frequencyobject is passed, it is closed over and the wrapped function only acceptstheta.- param func:
Function or bound method taking
(model, frequency, ...).- type func:
Callable
- param *args:
Either
(model, Frequency|unit)or just(Frequency|unit)iffuncis bound.- type *args:
tuple
- param as_numpy:
If
True, JIT the wrapper and convert inputs/outputs to NumPy arrays.- type as_numpy:
bool, default=False
- returns:
Wrapped function accepting
(theta_array, [f_array], *args, **kwargs).- rtype:
Callable
- raises TypeError:
If the frequency argument is neither a unit string nor
Frequency.
- Parameters:
func (Callable)
as_numpy (bool)
- Return type:
Callable