X Tutup
Skip to content

BUG: Parachute Pressures not being Set before All Info.#534

Merged
phmbressan merged 3 commits intomasterfrom
bug/export-flight-pressure
Jan 21, 2024
Merged

BUG: Parachute Pressures not being Set before All Info.#534
phmbressan merged 3 commits intomasterfrom
bug/export-flight-pressure

Conversation

@phmbressan
Copy link
Collaborator

@phmbressan phmbressan commented Jan 18, 2024

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

The method export_pressure incorrectly calls the lists: parachute.clean_pressure_signal and noisy_pressure_signal as if they were functions. Furthermore, this data is not set before the call of the all_info, which could lead to invalid exports if it was working.

The issue when trying to export the pressure was:

   3091 for parachute in self.rocket.parachutes:
   3092     for t in time_points:
-> 3093         p_cl = parachute.clean_pressure_signal(t)
   3094         p_ns = parachute.noisy_pressure_signal(t)
   3095         file.write(f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n")

TypeError: 'list' object is not callable

New behavior

The employed fix was to call the method that set these values not in the all_info, but after Flight computations. On top of that, the incorrect list calls were substituted by their _function counterparts.

Now the data is being exported correctly:

0.000000, 85639.55296, 85652.28657
1.000000, 85228.90121, 85223.88463
...

Breaking change

  • No

@phmbressan phmbressan added the Bug Something isn't working label Jan 18, 2024
@phmbressan phmbressan added this to the Release v1.X.0 milestone Jan 18, 2024
@phmbressan phmbressan requested a review from a team January 18, 2024 23:51
@phmbressan phmbressan self-assigned this Jan 18, 2024
@codecov
Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (223d598) 71.15% compared to head (a3e49a2) 71.23%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #534      +/-   ##
==========================================
+ Coverage   71.15%   71.23%   +0.08%     
==========================================
  Files          55       55              
  Lines        9259     9259              
==========================================
+ Hits         6588     6596       +8     
+ Misses       2671     2663       -8     
Flag Coverage Δ
unittests 71.23% <100.00%> (+0.08%) ⬆️

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.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

I think we should adopt the Function.savetxt to do the same job once we finish its PR.

Nevertheless, for this hotfix I think we are fine with the solution, thanks.

@giovaniceotto
Copy link
Member

Should we expect any significant increase in simulation execution speed since we are adding a new call inside Flight.__init__?

@phmbressan
Copy link
Collaborator Author

Should we expect any significant increase in simulation execution speed since we are adding a new call inside Flight.__init__?

That could be tested, of course, but I don't think so. The method basically makes two Function instances per parachute if I recall correctly.

Unless the simulation has unusualy too many points or a lot of parachutes, the time spend should be in the ms range.

Again, that could be easily tested later. This solution is not the best one, but I do think it involves the least amount of changes for a Hotfix.

I am open to other suggestions.

@Gui-FernandesBR
Copy link
Member

Should we expect any significant increase in simulation execution speed since we are adding a new call inside Flight.__init__?

That could be tested, of course, but I don't think so. The method basically makes two Function instances per parachute if I recall correctly.

Unless the simulation has unusualy too many points or a lot of parachutes, the time spend should be in the ms range.

Again, that could be easily tested later. This solution is not the best one, but I do think it involves the least amount of changes for a Hotfix.

I am open to other suggestions.

I reviewed it again and I don't think it's a problem. The new behavior is not prejudicial in terms of code performance.

@Gui-FernandesBR
Copy link
Member

In order to prevent future errors, we ideally should implement unit test for the methods we fix in hotfixes.
I did that in my last commit a3e49a2.

@phmbressan please review the commit and feel free to proceed and merge.

@phmbressan
Copy link
Collaborator Author

In order to prevent future errors, we ideally should implement unit test for the methods we fix in hotfixes.
I did that in my last commit a3e49a2.

@phmbressan please review the commit and feel free to proceed and merge.

Since I opened the PR GitHub does not allow me to submit an approval.

@Gui-FernandesBR Gui-FernandesBR self-requested a review January 21, 2024 16:21
Copy link
Member

@MateusStano MateusStano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! The export pressure function has broken a million times before. Its good that we finally have a test for it!

@phmbressan phmbressan merged commit 08004ef into master Jan 21, 2024
@phmbressan phmbressan deleted the bug/export-flight-pressure branch January 21, 2024 18:42
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

No open projects
Status: Closed

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup