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

Consolidate separate functions for ions and electrons in plasma parameter calculations #140

Merged

Conversation

RoberTnf
Copy link
Contributor

@RoberTnf RoberTnf commented Oct 3, 2017

Closing #106

The checklist of things to do are:

  • Merge electron_thermal_speed and ion_thermal_speed into thermal_speed
  • Merge electron_gyrofrequency and ion_gyrofrequency into gyrofrequency
  • Merge electron_gyroradius and ion_gyroradius into gyroradius
  • Merge electron_plasma_frequency and ion_plasma_frequency into plasma_frequency
  • Merge electron_inertial_length and ion_inertial_length into inertial_length
  • add a parameter method to thermal_speed
    I will be updating as I progress with the tasklist.

@pep8speaks
Copy link

pep8speaks commented Oct 3, 2017

Hello @RoberTnf! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on October 04, 2017 at 12:11 Hours UTC

@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 3, 2017

Why do I lack coverage in parts of the code that I didn't touch?

@StanczakDominik StanczakDominik mentioned this pull request Oct 4, 2017
4 tasks
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.

Good stuff overall! By the way, am I right in guessing you're using PyCharm or some other IDE? :D

distribution.
def thermal_speed(T, particle="e"):
r"""Returns the most probable speed for an particle within a Maxwellian
distributparticle.
Copy link
Member

Choose a reason for hiding this comment

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

What's a distributparticle? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is a distribution that also accepts electrons.

Copy link
Member

Choose a reason for hiding this comment

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

Ooooh wait, I get it. It's like a distribution, but particle? Does this exhaust the pun limit for physics? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an accidental pun, it's what happens when you try to replace the mentions to ion with particle. I will fix it 😄

@@ -380,7 +380,7 @@ def thermal_speed(T, ion="e"):
>>> from astropy import units as u
>>> thermal_speed(5*u.eV, 'p')
Copy link
Member

Choose a reason for hiding this comment

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

Do you think you could add an example for the default (electron) value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's is covered in line 386: thermal_speed(5*u.eV)

Copy link
Member

Choose a reason for hiding this comment

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

... huh, it is. Sorry, I missed it somehow!

def ion_plasma_frequency(n_i, ion='p'):
r"""Calculates the ion plasma frequency.
def plasma_frequency(n, particle='e'):
r"""Calculates the particle plasma frequency.
Copy link
Member

Choose a reason for hiding this comment

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

"Defaults to the fastest, electron plasma frequency.". How's that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what you mean.

Copy link
Member

Choose a reason for hiding this comment

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

I mean we could change the beginning of this docstring like this:

"""Calculates the particle plasma frequency. Defaults to the fastest, electron plasma frequency. 

The default behavior of this function seems important enough to mention it straight away :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, Ok, sounds fine. Should something similar be done for every other function I modified?

@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 4, 2017

I'm using VS Code, why?

@StanczakDominik
Copy link
Member

Well, your renaming commits come really fast, it's nice to see this kind of proficiency :D

@StanczakDominik
Copy link
Member

StanczakDominik commented Oct 4, 2017 via email

@RoberTnf RoberTnf force-pushed the refactor-consolidate-ion-electron branch from 4c49d56 to e78c189 Compare October 4, 2017 10:45
@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 4, 2017

I think that's everything, unless I missed something!

@StanczakDominik
Copy link
Member

Apparently we still have some conflicts on merge, probably because of the doctest thing I merged lately. Could you look into that? :)

@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 4, 2017

Ok, I'll try later!

@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 4, 2017

So after solving the conflicts I am not able to run pytest, it's trying to run docs/example.py, and obviously it can't. I suppose this is a separate issue but I'm not sure if it's something I did wrong.

@RoberTnf RoberTnf closed this Oct 4, 2017
@StanczakDominik
Copy link
Member

StanczakDominik commented Oct 4, 2017

Oh yeah, there was a fix in master to this one. Check out these two lines and make sure that's in your code.

In fact, with a proper merge from master this should be working, but git accidents happen all the time.

@RoberTnf
Copy link
Contributor Author

RoberTnf commented Oct 4, 2017

I closed this by accident, sorry, not used to github.

I have those lines, I've pulled master, but I get:

 $ pytest
============================= test session starts ==============================
platform linux -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0
rootdir: /home/roberto/git/PlasmaPy, inifile: pytest.ini
collected 706 items / 2 errors                                                  

==================================== ERRORS ====================================
__________________________ ERROR collecting setup.py ___________________________
/usr/lib/python3.6/distutils/core.py:134: in setup
    ok = dist.parse_command_line()
../../.virtualenvs/plasmapy/lib/python3.6/site-packages/setuptools/dist.py:442: in parse_command_line
    result = _Distribution.parse_command_line(self)
/usr/lib/python3.6/distutils/dist.py:490: in parse_command_line
    raise DistutilsArgError("no commands supplied")
E   distutils.errors.DistutilsArgError: no commands supplied

During handling of the above exception, another exception occurred:
setup.py:38: in <module>
    python_requires='>=3.6',
/usr/lib/python3.6/distutils/core.py:136: in setup
    raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
E   SystemExit: usage: pytest [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
E      or: pytest --help [cmd1 cmd2 ...]
E      or: pytest --help-commands
E      or: pytest cmd --help
E   
E   error: no commands supplied
_______________________ ERROR collecting docs/example.py _______________________
docs/example.py:34: in <module>
    from my_module import my_func, other_func
E   ModuleNotFoundError: No module named 'my_module'
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 2 error in 1.26 seconds ============================

@StanczakDominik
Copy link
Member

Happens to everyone :)

This is something we'll have to fix - as a workaround, run it as pytest plasmapy from the root of the repository for now. It should then get the doctest testing config from pytest.ini and avoid docs.

@StanczakDominik StanczakDominik merged commit 1b1db10 into PlasmaPy:master Oct 4, 2017
@StanczakDominik
Copy link
Member

Aaaand congratulations @RoberTnf ! :D

@RoberTnf RoberTnf deleted the refactor-consolidate-ion-electron branch October 4, 2017 12:38
@namurphy namurphy added plasmapy.formulary Related to the plasmapy.formulary subpackage Plasma parameters refactoring ♻️ Improving an implementation without adding new functionality labels Jan 17, 2018
@namurphy namurphy added this to To Do in Plasma parameters via automation Jan 17, 2018
@namurphy namurphy added this to the v0.1 milestone Jan 17, 2018
@namurphy namurphy mentioned this pull request Oct 15, 2018
@rocco8773 rocco8773 added this to Complete in Formulary Development Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plasmapy.formulary Related to the plasmapy.formulary subpackage refactoring ♻️ Improving an implementation without adding new functionality
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants