Skip to content
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

FIX: Broken Function.get_value_opt for N-Dimensional Functions #492

Merged
merged 4 commits into from
Nov 29, 2023

Conversation

giovaniceotto
Copy link
Member

@giovaniceotto giovaniceotto commented Nov 28, 2023

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

As reported by @styris00, the following code shows an error with Function.get_value_opt when used with 2D functions.

import numpy as np
from rocketpy import Function

arr = np.array([(1, 1, 2), (3, 6, 8),
            (8, 8, 9)])

myFun = Function(
    arr,
    interpolation="shepard",
    extrapolation="natural",
    title="myFun"
)

myFun.set_get_value_opt()

print(myFun.get_value(1, 1)
print(myFun.get_value_opt(1, 1))

Output is:

2.0
1.0

New behavior

The bug was fixed.

Breaking change

  • No

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0ef9849) 70.91% compared to head (8d6f244) 70.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #492      +/-   ##
==========================================
+ Coverage   70.91%   70.95%   +0.04%     
==========================================
  Files          55       55              
  Lines        9261     9262       +1     
==========================================
+ Hits         6567     6572       +5     
+ Misses       2694     2690       -4     
Flag Coverage Δ
unittests 70.95% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gui-FernandesBR
Copy link
Member

I wonder when this bug was introduced. The tests haven't been modified recently.

styris00
styris00 previously approved these changes Nov 28, 2023
@giovaniceotto
Copy link
Member Author

I wonder when this bug was introduced. The tests haven't been modified recently.

I didn't have enough time to track it down (the snake case commit makes things harder). However, the old test was never going to catch the bug.

What was going on is that, considering x, y, z, get_value_opt was returning y instead of z. And, in the test, y was equal to z, so it passed.

@giovaniceotto
Copy link
Member Author

Are we going to make this into a hotfix?
@MateusStano

@styris00 styris00 removed the request for review from Gui-FernandesBR November 29, 2023 07:52
@MateusStano MateusStano dismissed stale reviews from styris00 and Gui-FernandesBR via caf2715 November 29, 2023 22:27
@MateusStano
Copy link
Member

Are we going to make this into a hotfix?
@MateusStano

Yes we are!

@MateusStano MateusStano merged commit 22bb07b into master Nov 29, 2023
13 checks passed
@MateusStano MateusStano deleted the bug/fix-N-dimensional-get-value-opt branch November 29, 2023 23:06
@Gui-FernandesBR Gui-FernandesBR added the Bug Something isn't working label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

4 participants