Skip to content

added examples in boris_push docstring #1556

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

Merged
merged 13 commits into from
Aug 16, 2022

Conversation

MKastek
Copy link
Contributor

@MKastek MKastek commented May 15, 2022

  • I have added a changelog entry for this pull request.
  • If adding new functionality, I have added tests and
    docstrings.
  • I have fixed any newly failing tests.

pre-commit.ci autofix

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for making your first contribution to PlasmaPy! The project's future depends on contributors like you, so we deeply appreciate it! 🌱
To make sure that you get credit for this pull request (PR), please add yourself to the list of contributors in docs/about/credits.rst.
We encourage you to check out our contributor guide, which discusses topics like adding changelog entries. If you'd like to talk with us in real time, the easiest way is via our chat room. We also invite you to stop by our weekly community meeting or office hours.
The bottom of this page includes several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. Eventually we'll want to get checks on this PR to pass before merging it. Clicking on Details next to the check will show the results of the test, including error messages. Please feel free to ask for help if you're having trouble (we do that all the time, as well).
Our testing guide describes these checks in more detail, as well as how to write and run tests. We recommend trying out test-driven development: write tests first, and then write code to make tests pass. Remember to run tests often!
As described in our documentation guide, PlasmaPy's documentation is written in reStructuredText using the numpydoc docstring standard. To see a preview of the documentation from this PR, click on Details next to the docs/readthedocs.org:plasmapy check.
To automagically fix most linter problems, comment on this PR with pre-commit.ci autofix, followed by a git pullto bring the changes home to your own computer.
A code maintainer should come by soon to begin a code review. This step often includes suggestions for fixing bugs, adding tests, or simplifying the implementation. After that you'll have a chance to make changes. If you'd like more time before a code review happens, you can convert this PR to a draft now and mark it as ready for review later.
Finally, we try to be the best community we can be. We have a Code of Conduct to foster a community of care and appreciation.
We thank you once again! ✨

Comment on lines 55 to 60
>>> plt.plot(x,y)
>>> plt.xlabel('x [m]')
>>> plt.ylabel('y [m]')
>>> plt.title(r"Single particle motion without $\vec{E}$ field")
>>> plt.grid()
>>> plt.gca().set_aspect('equal')
Copy link
Member

Choose a reason for hiding this comment

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

Rather than plotting, which is not going to display in rendered docs at https://docs.plasmapy.org/en/stable/api/plasmapy.simulation.particle_integrators.boris_push.html#plasmapy.simulation.particle_integrators.boris_push and is best kept in jupyter notebooks such as https://docs.plasmapy.org/en/stable/notebooks/ExB_drift.html, perhaps we can instead display a few examples? This chains into something I also just realized...

>>> y = []
>>>
>>> for _ in range(150):
>>> boris_push(x = x_0, v = v_0, B=B, E=0, q=1.0, m=1.0, dt=0.01)
Copy link
Member

Choose a reason for hiding this comment

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

So I just realized that the boris_push implementation we've got here only modifies the input x, v arrays. This is good for performance but is dreadful for quickly displaying how it works. I think adding an inplace = False keyword argument would be okay both for docs and for future developments here (for example I have a couple ideas on doing this through jax or some such optimizer...), if you'd be up for it!

And then, rather than having an embedded minimal simulation here, I think it'd be better to show how how to use the boris pusher:

  1. how it returns the x, v arrays in the next time step (the essence of what it does)
  2. how it modifies the x, v arrays by default (show them before/after)
  3. how, for B parallel to V, it does nothing;
  4. what it does for B perpendicular to V;
  5. how for nonzero E and zero B it reduces to the leapfrog algorithm.

Also, to easily do this from the IPython shell, try the %doctest_mode magic command:

[ins] In [1]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON
>>> 2 + 2
4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will work on that and prepare new version in accordance with your suggestions.

@StanczakDominik
Copy link
Member

So, uh, I guess this one issue was a bit under-specified 😅

@MKastek MKastek marked this pull request as draft May 16, 2022 13:50
@rocco8773 rocco8773 added this to the 0.9.0 milestone Jun 28, 2022
@MKastek MKastek marked this pull request as ready for review July 1, 2022 12:55
@MKastek
Copy link
Contributor Author

MKastek commented Jul 1, 2022

pre-commit.ci autofix

Copy link
Member

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

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

Hey, finally circled back to looking into this! I'm sorry for the long delay, a lot has been happening, as you likely well know :) Looks great, I do have one minor suggestion though - changing the default back to the previous one.

If you agree with the proposed changes, we can merge this pretty quickly. It would still need a changelog entry, but besides that, it looks pretty much done.

@StanczakDominik
Copy link
Member

StanczakDominik commented Jul 29, 2022

I also think merging the suggestions (or doing anything to the branch, really) and re-triggering CI might get rid of some of the noise from the Documentation test 😅

MKastek and others added 3 commits July 30, 2022 10:14
Co-authored-by: Dominik Stańczak <stanczakdominik@gmail.com>
Co-authored-by: Dominik Stańczak <stanczakdominik@gmail.com>
Co-authored-by: Dominik Stańczak <stanczakdominik@gmail.com>
@MKastek
Copy link
Contributor Author

MKastek commented Aug 1, 2022

I also think merging the suggestions (or doing anything to the branch, really) and re-triggering CI might get rid of some of the noise from the Documentation test 😅

Unfortunately, I continue to get errors related to the documentation :(

@StanczakDominik
Copy link
Member

Let's see if that fixes things. The doc build seems to have been an unrelated issue fixed elsewhere (that's distributed project development for ya, sorry I missed it! 😅).

I also adjusted the doctest values for a few changes where they started differing from what we actually got.

@codecov
Copy link

codecov bot commented Aug 16, 2022

Codecov Report

Merging #1556 (d90dd9a) into main (d2ee9d6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1556   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files          84       84           
  Lines        8000     8003    +3     
=======================================
+ Hits         7778     7781    +3     
  Misses        222      222           
Impacted Files Coverage Δ
plasmapy/simulation/particle_integrators.py 100.00% <100.00%> (ø)

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

Copy link
Member

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

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

NOW this should do it :)

@StanczakDominik StanczakDominik enabled auto-merge (squash) August 16, 2022 17:29
@StanczakDominik StanczakDominik merged commit f80e923 into PlasmaPy:main Aug 16, 2022
@MKastek MKastek deleted the add-examples-in-boris_push branch August 16, 2022 20:12
namurphy added a commit to namurphy/PlasmaPy that referenced this pull request Oct 25, 2022
namurphy added a commit to namurphy/PlasmaPy that referenced this pull request Oct 26, 2022
The detail on the ``inplace`` keyword seemed different from the
docstring description, so I dropped the description from the changelog
entry.
@namurphy namurphy added plasmapy.simulation Related to the plasmapy.simulation subpackage docs PlasmaPy Docs at http://docs.plasmapy.org labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PlasmaPy Docs at http://docs.plasmapy.org plasmapy.simulation Related to the plasmapy.simulation subpackage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy