Skip to content

Add power exponent to the interpolation distance #10113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

GieziJo
Copy link

@GieziJo GieziJo commented Mar 12, 2025

knn_interpolate assumes inverse square distance as contributing weights for the interpolation.
In certain cases, you might need linear interpolation, or another power.

I added the parameter alpha to the function with the default value set to 2.0.
The default behavior thus stays the same, but gives you the option to change the power.

To keep the performance the same, added a couple of checks:

        if alpha != 2.0:
            distance = distance.sqrt()
        if (alpha != 2.0) and (alpha != 1.0):
            distance = distance.pow(alpha)

Hope this can be useful!

@GieziJo GieziJo requested a review from EdisonLeeeee as a code owner March 12, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant