Visitar URL original
Revise the code guide in the contributor guide by namurphy · Pull Request #1305 · PlasmaPy/PlasmaPy · GitHub
Skip to content

Revise the code guide in the contributor guide - #1305

Closed
namurphy wants to merge 51 commits into
PlasmaPy:mainfrom
namurphy:code-guide
Closed

namurphy wants to merge 51 commits into
PlasmaPy:mainfrom
namurphy:code-guide

Conversation

@namurphy

@namurphy namurphy commented Oct 8, 2021 •

Copy link
Copy Markdown
Member

This PR is going to be an update of the code guide that follows up on #1156, #1163, and #1198. This falls under #1117.

I'm starting it now since I wanted to make sure to talk about making comments future-proof (inspired by this comment), but I'm guessing I won't finish it in 2021 😬 .

This might be a good PR in which to address #582, #685, #797, #1227, and #1234...but those might wait until another PR (especially #1227). We will definitely need to talk about validate_quantities and particle_input here too.

Closes #1214.

This information should all be in the doc guide.
@namurphy namurphy added docs PlasmaPy Docs at http://docs.plasmapy.org effort: high Requiring perhaps ∼1–2 weeks. Can this be split up into multiple smaller/focused issues? labels Oct 8, 2021
@codecov

codecov Bot commented Oct 8, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #1305 (b9673da) into main (34c717c) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1305   +/-   ##
=======================================
  Coverage   97.09%   97.09%           
=======================================
  Files          81       81           
  Lines        7679     7679           
=======================================
  Hits         7456     7456           
  Misses        223      223           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34c717c...b9673da. Read the comment docs.

@namurphy

namurphy commented Oct 8, 2021 •

Copy link
Copy Markdown
Member Author

Reminders to myself:

  • I'll probably be making a bunch of changes to docs/common_links.rst which is a frequently edited file. To start out with I should put all of the newly defined links at the bottom of code_guide.rst, and then move them to docs/common_links.rst later on in order to avoid dreaded merge conflicts of joy and despair.
  • It might be helpful to add in here how instead of having a function like def f(): return x, y we can create a namedtuple to use as the output so that we can use output.x and output.y.
  • We should also add a discussion on licensing, including: license compatibility, how limitations on licenses of databases that restrict data redistribution are
  • We want to balance "concise" and "comprehensive"

@namurphy

namurphy commented Nov 2, 2021

Copy link
Copy Markdown
Member Author
  • (Briefly) describe the different techniques use to optimize code. (Maybe a different PR, but if so, raise an issue instead.)

@rocco8773

Copy link
Copy Markdown
Member

How to import functionality from plasmapy.formulary?

  1. For end users, they should import directly from plasmapy.formulary (e.g. from plasmapy.formulary import plasma_frequency), because this would lead to more robustness against changing internal pkg structure.
  2. For contributors developing code,..
    1. For locations outside plasmapy.formulary functionality can be imported from plasmapy.formulary.
    2. For locations inside plasmapy.formulary, ...
      • Importing from plasmapy.formulary will absolutely cause circular imports, so this option can not be done.
      • Functionality to be directly imported from its sub-module or the sub-module itself should be imported.
      • Importing functionality from a sub-module can still cause circular imports, in that case import the sub-module and dot access the functionality. For example,
        from plasmapy.formulary import frequencies
        
        wp = frequencies.plasmapy_frequency(...)

@github-actions github-actions Bot added docs PlasmaPy Docs at http://docs.plasmapy.org and removed notebooks Related to example Jupyter notebooks in docs/examples/ labels Apr 20, 2022
@namurphy

namurphy commented May 3, 2022

Copy link
Copy Markdown
Member Author

Add that we can use tools like WebPlotDigitizer to get values from graphs. Was used in #1189.

Comment on lines +33 to +52
* The `Python Standard Library`_ contains numerous components. Some of
the ones used in PlasmaPy are:

- `collections` — Container datatypes
- `collections.abc` — Abstract base classes
- `contextlib` — Utilities for ``with`` statement contexts
- `dataclasses` — Data classes
- `functools` — Higher-order functions and operations on callable objects
- `glob` — Unix style pathname pattern expansion
- `inspect` — Inspect live objects
- `itertools` — Functions creating iterators for efficient looping
- `json` — JSON encoder and decoder
- `numbers` — Numeric abstract base classes, often used for type hint annotations
- `os` — Miscellaneous operating system interfaces
- `pdb` — The Python debugger
- `re` — Regular expression operations
- `string` — Common string operations
- `sys` — System-specific parameters and functions
- `typing` — Support for type hints
- `warnings` — Warning control

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.

I don't think this section is necessary - there are plenty of resources for the Python STL and it's not really relevant to, to quote, common conventions, guidelines, and strategies for contributing code!

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.

Yeah, I was going back and forth on this one. My main motivation for including this is that I've been slow to learn about and appreciate everything that's in the STL. I think I'll drop the list, but include a link to the STL and say that it's worth learning more about.

An `integrated development environment`_ (IDE) is an application that
includes multiple tools needed for software development, such as a
source code editor, test automation tools, and a debugger. Commonly used
IDEs for Python include PyCharm_, `Visual Studio Code`_, and Atom_.

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.

Atom is now passè and at EOL given that its crew got absorbed into the VSCode team, IIRC.

Also could be just cut, I think, for same reason as the above.

@namurphy

Copy link
Copy Markdown
Member Author
  • Specify the dependency tree for subpackages. utils can't import from anywhere else; particles can import from utils, formulary can import from particles & utils, etc.

@namurphy

Copy link
Copy Markdown
Member Author

@namurphy namurphy added this to the 0.9.0 milestone Jun 28, 2022
@namurphy

namurphy commented Jul 1, 2022 •

Copy link
Copy Markdown
Member Author
  • Make sure to incorporate the following text, which came from docs/formulary/index.rst:

Notes for developers

Values should be returned as an Astropy |Quantity| in SI units.

If a quantity has several names, then the function name should be the
one that provides the most physical insight into what the quantity
represents. For example, gyrofrequency indicates gyration, while
Larmor frequency indicates that this frequency is somehow related to a
human (or perhaps a cat?) named Larmor. Similarly, using omega_ce
as a function name for this quantity will make the code less readable to
people who are unfamiliar with the notation or use a different symbol.

The docstrings for plasma parameter methods should describe the
physics associated with these quantities in ways that are
understandable to students who are taking their first course in plasma
physics while still being useful to experienced plasma physicists.

@namurphy

Copy link
Copy Markdown
Member Author
  • Mention annotations and what they're used for
  • Bring up how to use validate_quantities and particle_input

@namurphy

Copy link
Copy Markdown
Member Author

Thinking about this more, it's probably a better idea to break this up into multiple, smaller pull requests.

@namurphy

namurphy commented Aug 4, 2022

Copy link
Copy Markdown
Member Author

Closing this in favor of a few separate pull requests (see above). The two main sections that I haven't moved over are on:

  • Python standard library
  • IDEs

The paragraph on IDEs could perhaps be shortened and put in #1656. Right now I'm not planning on putting the section on the Python standard library anywhere else, but it might be worth thinking about again in shorter form if we add a resources page to the contributor guide.

@namurphy namurphy closed this Aug 4, 2022
@namurphy
namurphy deleted the code-guide branch August 4, 2022 18:51
@namurphy namurphy mentioned this pull request Aug 18, 2022
4 of 8 tasks
@namurphy namurphy removed status: nearing completion status: on hold Issues & PRs that are being intentionally delayed labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor guide docs PlasmaPy Docs at http://docs.plasmapy.org effort: high Requiring perhaps ∼1–2 weeks. Can this be split up into multiple smaller/focused issues?

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discuss in code development guide when to use and not use function aliases

3 participants