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

Modify the way settings are passed to the _spectral_density_model function #2623

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

pheuer
Copy link
Member

@pheuer pheuer commented Apr 5, 2024

Addresses #2620 without capping the version of lmfit

Supercedes #2621

Instead of passing settings to Model and relying on lmfit to pass that to _spectral_density_model, this PR uses a lambda function to freeze in the settings (which are constant) prior to giving the function to lmfit.

def _spectral_density_model_lambda(wavelengths, **params):
        return _spectral_density_model(wavelengths, settings=settings, **params)

    # Create and return the lmfit.Model
    return Model(
        _spectral_density_model_lambda,
        independent_vars=["wavelengths"],
        nan_policy="omit",
    )

@pheuer pheuer self-assigned this Apr 5, 2024
Copy link

github-actions bot commented Apr 5, 2024

Thank you for submitting a pull request (PR) to PlasmaPy! ✨ The future of the project depends on contributors like you, so we deeply appreciate it! 🌱

Our contributor guide has information on:

The bottom of this page shows several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. 😺 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well. 🌸 You can find us in our chat room or weekly community meeting & office hours. Here are some tips:

  • Try fixing CI / Python 3.12 test failures first.
  • Most pre-commit.ci - pr failures can be automagically fixed by commenting pre-commit.ci autofix below, followed by a git pull to bring the changes back to your computer. Please also see our pre-commit troubleshooting guide.
  • If pre-commit.ci - pr says that a function is too long or complex, try breaking up that function into multiple short functions that each do one thing. See also these tips on writing clean scientific software.
  • If the CI / Documentation check ends with a cryptic error message, check out our documentation troubleshooting guide.
  • For a documentation preview, click on Details next to docs/readthedocs.org:plasmapy.

If this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. ✅ If you don't get a review within a few days, please feel free to send us a reminder.

Please also use SI units within PlasmaPy, except when there is strong justification otherwise or in some examples.

We thank you once again!

@github-actions github-actions bot added the plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage label Apr 5, 2024
@pheuer pheuer requested a review from namurphy April 5, 2024 19:24
@pheuer pheuer requested a review from a team as a code owner April 5, 2024 19:28
@github-actions github-actions bot added the bug Issues describing unexpected behavior or defects. Remember: a bug is a sign of a missing test! label Apr 5, 2024
@pheuer
Copy link
Member Author

pheuer commented Apr 5, 2024

@namurphy This should be good to go, so merge when ready!

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.17%. Comparing base (4c7c0d9) to head (9c296f6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2623   +/-   ##
=======================================
  Coverage   95.17%   95.17%           
=======================================
  Files         104      104           
  Lines        9415     9417    +2     
  Branches     2154     2154           
=======================================
+ Hits         8961     8963    +2     
  Misses        276      276           
  Partials      178      178           

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

Copy link
Member

@namurphy namurphy left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏻 Thank you again for doing this! 🚀

One small optional suggestion, and feel free to merge whenever you're ready!

@@ -1000,10 +1000,12 @@ def spectral_density_model( # noqa: C901, PLR0912, PLR0915
# quantities isn't consistent with the number of that species defined
# by ifract or efract.

def _spectral_density_model_lambda(wavelengths, **params):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def _spectral_density_model_lambda(wavelengths, **params):
def _spectral_density_model_wrapper(wavelengths, **params):

❔ 🏷️ Since this isn't defined with a lambda statement, what would you think of renaming it as a wrapper?

Also I'm trying out prefixing code review comments with emojis! I'm still figuring it out, but I'm using ❔ to indicate that it's optional and up to you, and 🏷️ refers to naming.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, too late, looks like it's already merged but sure I'm fine with either name! I originally had it as a lambda, but switched to this syntax just to keep it under the line limit

# Create and return the lmfit.Model
return Model(
_spectral_density_model,
_spectral_density_model_lambda,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_spectral_density_model_lambda,
_spectral_density_model_wrapper,

@pheuer
Copy link
Member Author

pheuer commented Apr 5, 2024

@namurphy codecov token issue?

gpg: directory '/Users/runner/.gnupg' created
gpg: /Users/runner/.gnupg/trustdb.gpg: trustdb created
gpg: key 806BB28AED779869: public key "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1

gpg: Signature made Thu Mar 28 15:15:56 20[24](https://github.com/PlasmaPy/PlasmaPy/actions/runs/8574775638/job/23502319136?pr=2623#step:7:25) UTC
gpg:                using RSA key 27034E7FDB850E0BBC2C62FF806BB28AED779869
gpg: Good signature from "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2703 4E7F DB85 0E0B BC2C  62FF 806B B28A ED77 9869

==> Uploader SHASUM verified (cb[25](https://github.com/PlasmaPy/PlasmaPy/actions/runs/8574775638/job/23502319136?pr=2623#step:7:26)0ac4addcd9a21bf1c73d583cdae0e7fbd2c369350829fcc21ffb55ca81e6  codecov)
info - 2024-04-05 19:32:40,217 -- ci service found: github-actions
info - 2024-04-05 19:32:40,586 -- The PR is happening in a forked repo. Using tokenless upload.
info - 2024-04-05 19:32:40,851 -- Process Commit creating complete
error - 2024-04-05 19:32:40,852 -- Commit creating failed: {"detail":"Tokenless has reached GitHub rate limit. Please upload using a token: https://docs.codecov.com/docs/adding-the-codecov-token. Expected available in 191 seconds."}

@namurphy
Copy link
Member

namurphy commented Apr 5, 2024

@namurphy codecov token issue?

NOOoooOOOoooOOOOooOOOOO!!!!!!! 😿😿😿😿😿😿😿😿 I thought I had fixed that! Let's...ignore codecov checks until we get them working again. Thank you for pointing this out!

@namurphy
Copy link
Member

namurphy commented Apr 5, 2024

@namurphy codecov token issue?

Also I realized that my response should have technically been "YEEEeeeEEEeeeeSSSSsssSSSS!" 👀 😹

@namurphy namurphy added this to the v2024.5.0 milestone Apr 5, 2024
@namurphy namurphy merged commit ac0ffc8 into PlasmaPy:main Apr 5, 2024
17 checks passed
@namurphy namurphy added bugfix Pull requests that fix a bug. Remember: a bug is a sign of a missing test! and removed bug Issues describing unexpected behavior or defects. Remember: a bug is a sign of a missing test! labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull requests that fix a bug. Remember: a bug is a sign of a missing test! plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants