Hi everyone, I am updating a code of mine and on it I need to be able to interpolate a table. Mind that there a steps on the table (where the same value of X, has 2 values of Y1) and I used to have this lines:
ivp = LinearInterpolation(model[:,1], model[:,2]);
iivp = zeros(Float64, kmax); # inverse of ivp
for k=1:kmax
iivp[k] = 1/ivp(vz[k]);
end
model is a table (see bellow) where the firsts columns had repeated values. It never gave me a problem before, but now I get:
ERROR: knot-vectors must be unique and sorted in increasing order
As the error says, your knot vector canβt have repeated values. Itβs ill-determined: do you pick one of the values at random? Take the mean? Youβll need to decide how you want the interpolation to behave, and clean your data appropriately to remove repeated values.
This change was introduced in this commit, so in the short term, you can just pin the version to the prior release (v0.13.1).
This is very inconvinient β¦ most of the data I work with looks like this.
Is there a way for me to βgrabβ a copy of the old interpolation so I can keep it and not be bound to the Interpolations package?
Or maybe it could become an option in the package.
[β¦] the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. [β¦]
So yeah, if you feel the need to copy the state of Interpolations pre v0.13.1 you can do so. You can even fork it I believe and install from your own repository. Just donβt try to register it in General
If you want to use version 0.13.1 you can just pin it at that version, no need to fork?
In terms of changing the model, I guess the first step would be to see what Interpolations 0.13 does when there are duplicates in the knot vector, and whether this is actually what you expect (the question above is quite relevant I think, itβs not clearly to me what should be happening when you present Interpolations with such data).
But Interpolations already made a choice for you in past versions (afaict it just takes the first value). So now youβll just need to do the same manually, with the bonus that you actually know whatβs going on.
In fairness, the underlying PR is (arguably) a breaking change, and should have coincided with a version bump, but it wasnβt even mentioned in any of the release notes (afaict).The old behavior was ambiguous, but it wasnβt incorrect, per se, and this change should have been more clearly publicized.
Definitely.
Also, in the spirit of making the package as flexible as possible I think keeping it as a option is a good idea. Maybe a little function can be added to preprocess the data for this kind of case.