Skip to content

BUG: N-D Function with linear interpolation sometimes returns NaN or raises errors for valid-looking queries #926

@MateusStano

Description

@MateusStano

Describe the bug

When using Function(..., interpolation="linear") with N-D input data, nan values or error can be raised depending on the data set:

  • One query returns nan silently.
  • Another query raises an exception.

This happens in in this example:

from rocketpy import Function

data = [
    [0.0, 0.0, 0.000],
    [0.0, 0.1, 0.1],
    [0.0, 0.4, 0.4],
    [0.3, 0.2, 0.15],
]
f = Function(data, interpolation="linear")
print(f(0.3, 0.3))   # returns nan

aa = Function([[1, 1, 10], [2, 2, 20], [3, 3, 30]], interpolation="linear")
print(aa(4, 4))       # raises error
  • bb(0.3, 0.3) returns nan without explicit warning/error.
  • aa(4, 4) raises an exception.

This appears to happen only with very specific point configurations/datasets.
Please investigate the underlying cause and clarify intended behavior for these edge cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingFunctionEverything related to the Function class

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions