-
I was exploiting the behavior in Lines 516 to 520 in cf2626b argnames and kwargs properties.For a minimal example, I could make a polynomial function with an arbitrary degree with the following code: import lmfit
import numpy as np
class PolynomialFunction:
def __init__(self, degree: int = 1):
self.degree = degree
@property
def __name__(self) -> str:
return self.__class__.__name__
@property
def argnames(self) -> list[str]:
return ["x"] + [f"c{i}" for i in range(self.degree + 1)]
@property
def kwargs(self):
return {}
def __call__(self, x, *coeffs, **params):
if len(coeffs) != self.degree + 1:
coeffs = [params[f"c{d}"] for d in range(self.degree + 1)]
return np.polynomial.polynomial.polyval(x, coeffs)
model = lmfit.Model(PolynomialFunction(degree=2))
model.make_params() This broke with 1.3.0 due to changes made in #941 because |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@kmnhan Ah, sorry for the trouble. Well, I would say both that As you noticed, the changes for 1.3.0 from #941 were a fairly large change to the internals of parsing and converting function arguments to parameters and independent variables. I do not expect this to be something we change very often, but we may have to make some tweaks from those changes to fix bugs. See #950, for example. I think we could (and should) probably fix the code so your use case works too. I guess we weren't testing that portion of the code (or at least not very thoroughly!). We should be able to fold fixes for this into #950, and then push that out as 1.3.1 fairly soon. But also: we do have a |
Beta Was this translation helpful? Give feedback.
@kmnhan Ah, sorry for the trouble. Well, I would say both that
a) we never really promised this was part of a supported API that would never change ;)
b) but also: variadic functions are an important-if-maybe-challenging use case, and we want them to work!
As you noticed, the changes for 1.3.0 from #941 were a fairly large change to the internals of parsing and converting function arguments to parameters and independent variables. I do not expect this to be something we change very often, but we may have to make some tweaks from those changes to fix bugs. See #950, for example.
I think we could (and should) probably fix the code so your use case works too. I guess we weren't testing that …