Visitar URL original
Update docstring and annotations for `spectral_density` by namurphy · Pull Request #1756 · PlasmaPy/PlasmaPy · GitHub
Skip to content

Update docstring and annotations for spectral_density - #1756

Merged
namurphy merged 15 commits into
PlasmaPy:mainfrom
namurphy:thomson-docstring
Jan 12, 2023
Merged

namurphy merged 15 commits into
PlasmaPy:mainfrom
namurphy:thomson-docstring

Conversation

@namurphy

@namurphy namurphy commented Oct 7, 2022

Copy link
Copy Markdown
Member

This PR makes some updates to the docstring for spectral_density. It updates the parameters section, in particular the type line. It also updates some of the type hint annotations and justifies lines to ≤ 72 characters as per PEP 8.

This probably closes #1755, since it specifies that several parameters are keyword-only.

@github-actions github-actions Bot added the plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage label Oct 7, 2022
@github-actions

github-actions Bot commented Oct 7, 2022 •

Copy link
Copy Markdown

Thank you for contributing to PlasmaPy! The project's future depends deeply on contributors like you, so we deeply appreciate it! 🌱 The following checklist will be used by the code reviewer to help guide the code review process.

  • Overall
    • Does the PR do what it intends to do?
    • Except for very minor changes, is a changelog entry included and consistent with the changelog guide?
    • Are the continuous integration checks passing? (Most linter problems can be automagically fixed by commenting on this PR with pre-commit.ci autofix.)
  • Code
    • Is new/updated code understandable and consistent with the coding guide?
    • Are there ways to greatly simplify the implementation?
    • Are there any large functions that should be split up into shorter functions?
  • Tests
    • Are tests added/updated as required, and consistent with the testing guide?
    • Are the tests understandable?
    • Do the tests cover all important cases?
  • Docs
    • Are docs added/updated as required, and consistent with the doc guide?
    • Are the docs understandable?
    • Do the docs show up correctly in the preview, including Jupyter notebooks?

@codecov

codecov Bot commented Oct 7, 2022 •

Copy link
Copy Markdown

Codecov Report

Base: 98.32% // Head: 98.32% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (82abbe3) compared to base (b1fa1ed).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 82abbe3 differs from pull request most recent head eb2e4a3. Consider uploading reports for the commit eb2e4a3 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1756   +/-   ##
=======================================
  Coverage   98.32%   98.32%           
=======================================
  Files          95       95           
  Lines        8395     8396    +1     
=======================================
+ Hits         8254     8255    +1     
  Misses        141      141           
Impacted Files Coverage Δ
plasmapy/diagnostics/thomson.py 97.95% <100.00%> (+<0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@StanczakDominik

StanczakDominik commented Oct 8, 2022 •

Copy link
Copy Markdown
Member

Looks good in the overall clarification sense!

We did get a whole bunch of sphinx warnings...

/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:: ERROR: Undefined substitution referenced: "array-like".
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:: ERROR: Undefined substitution referenced: "array-like".
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:: ERROR: Undefined substitution referenced: "array-like".
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._array_like._SupportsArray
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._nested_sequence._NestedSequence
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._array_like._SupportsArray
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._nested_sequence._NestedSequence
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._array_like._SupportsArray
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._nested_sequence._NestedSequence
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._array_like._SupportsArray
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._nested_sequence._NestedSequence

Looks related to this from https://plasmapy--1756.org.readthedocs.build/en/1756/api/plasmapy.diagnostics.thomson.spectral_density.html#plasmapy.diagnostics.thomson.spectral_density

efract: Optional[Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]]

@pheuer

pheuer commented Oct 10, 2022

Copy link
Copy Markdown
Member

Other than the documentation build errors, looks good to me, thanks for improving this!

@namurphy namurphy added this to the 0.9.0 milestone Oct 25, 2022
@namurphy namurphy added the priority: high Issues & PRs with significant urgency and importance that should be addressed soon label Nov 8, 2022
@StanczakDominik StanczakDominik modified the milestones: 0.9.0, 0.10.0 Nov 8, 2022
@github-actions

github-actions Bot commented Nov 9, 2022

Copy link
Copy Markdown

Thank you for contributing to PlasmaPy! The project's future depends deeply on contributors like you, so we deeply appreciate it! 🌱 The following checklist will be used by the code reviewer to help guide the code review process.

  • Overall
    • Does the PR do what it intends to do?
    • Except for very minor changes, is a changelog entry included and consistent with the changelog guide?
    • Are the continuous integration checks passing? (Most linter problems can be automagically fixed by commenting on this PR with pre-commit.ci autofix.)
  • Code
    • Is new/updated code understandable and consistent with the coding guide?
    • Are there ways to greatly simplify the implementation?
    • Are there any large functions that should be split up into shorter functions?
  • Tests
    • Are tests added/updated as required, and consistent with the testing guide?
    • Are the tests understandable?
    • Do the tests cover all important cases?
  • Docs
    • Are docs added/updated as required, and consistent with the doc guide?
    • Are the docs understandable?
    • Do the docs show up correctly in the preview, including Jupyter notebooks?

Comment on lines +90 to +91
Temperature of each electron population in kelvin, where Ne is
the number of electron populations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the docstrings here, "population" and "component" were being used interchangeably, and I was thinking it'd be helpful to use one or the other consistently. I tentatively went with population only because it implies multiple things, but I'd be happy to go with either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed - they are pretty much interchangeable and I think your decision here is good

by :math:`F_i` below. Must sum to one. The default corresponds
to a single ion population.

ions : (Ni,) |particle-like|, |keyword-only|, default: "p+"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Continuing to try out the parameter type descriptions from the matplotlib dev guide...in particular that if there's a simple default that can go in the type line, a parameter does not need to be described as "optional".


.. math::
n_i = \frac{F_i n}{\sum_i F_i Z_i}
n_i = \frac{F_i n}{∑_i F_i Z_i}

@namurphy namurphy Nov 9, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  • Check that this renders correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread plasmapy/diagnostics/thomson.py Resolved
@namurphy
namurphy marked this pull request as ready for review December 7, 2022 03:57
@namurphy
namurphy requested review from a team and rocco8773 as code owners December 7, 2022 03:57
@namurphy

namurphy commented Dec 7, 2022

Copy link
Copy Markdown
Member Author

As part of this I also used grep to see if there were any places in package where we used Thompson instead of Thomson, and didn't find any!

@pheuer pheuer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, forgot to review this! LGTM, thanks for making the updates!

Edit: Except for the documentation build errors I just noticed. Looks like something to do with the typing?

Comment on lines +90 to +91
Temperature of each electron population in kelvin, where Ne is
the number of electron populations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed - they are pretty much interchangeable and I think your decision here is good


.. math::
n_i = \frac{F_i n}{\sum_i F_i Z_i}
n_i = \frac{F_i n}{∑_i F_i Z_i}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@StanczakDominik StanczakDominik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed with Peter - changes look good, doc errors look cryptic and concerning.

@StanczakDominik StanczakDominik removed the priority: high Issues & PRs with significant urgency and importance that should be addressed soon label Jan 10, 2023
@namurphy

namurphy commented Jan 12, 2023 •

Copy link
Copy Markdown
Member Author

Strange! I'm getting these doc build errors.

/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._array_like._SupportsArray
/home/runner/work/PlasmaPy/PlasmaPy/plasmapy/diagnostics/thomson.py:docstring of plasmapy.diagnostics.thomson.spectral_density:1: WARNING: py:class reference target not found: numpy._typing._nested_sequence._NestedSequence

I do not know what is happening here. 🤔 🌵 👀 🎆 🧄

Update: best guess, using |array_like| in parameter type descriptions.

Update to the update: It looks like it was because of the Optional[ArrayLike] annotations. I don't understand why they're not working, though.

@namurphy
namurphy enabled auto-merge (squash) January 12, 2023 02:48
@namurphy
namurphy merged commit 627d62e into PlasmaPy:main Jan 12, 2023
@namurphy
namurphy deleted the thomson-docstring branch May 24, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

argument error in thomson code

3 participants