Repository: PlasmaPy/PlasmaPy

Issue:
Add more comprehensive testing
Would you consider adding more jobs to the test matrices? E.g. test against more numpy versions you support, or astropy versions.

Also, preferably also against the dev versions of these to issues like #587 would surface much earlier, still in the development cycle.
astropy.units.core.UnitConversionError: 's / m' and 's / m' are not convertible
https://travis-ci.org/PlasmaPy/PlasmaPy/jobs/466396211

After wrestling with system packages (`conda`, `pip` and `pacman`, argh!), I've managed to figure out that this is localized to `astropy` 3.1. Also, running `python setup.py test -d` and getting into `plasmapy.physics.distribution.Maxwellian_1D`:

```python
(Pdb) distFunc
<Quantity 5.91632969e-07 s / m>
(Pdb) p u.s / u.m
Unit("s / m")
(Pdb) p distFunc
<Quantity 5.91632969e-07 s / m>
(Pdb) p distFunc.unit
Unit("s / m")
(Pdb) p distFunc.to(u.s / u.m)
*** astropy.units.core.UnitConversionError: 's / m' and 's / m' are not convertible
```
Update Type Hint Annotations for Consistency
- Closes #572


Discussion:
Well, it was on my own to do list, and while I haven't exactly kept track,
the number of bugs it would have prevented in this and certain other
packages has just grown by one. :)

 Will do as soon as I get some time to do that (though if anyone wants to
do it first, be my guest :D)!

You're right, that definitely would have helped with catching things like #587 much earlier.  We did try testing against astropy-dev a while ago in #172 and #264 but ran into some problems and weren't able to figure it out.  Thanks!
Looks like this is going to be fixed for Astropy 3.1.1 in https://github.com/astropy/astropy/pull/8263 which leaves us to figure out how to block 3.1 in requirements. Basically we want to say `Astropy >= 3.0.2 & Astropy != 3.1.0"`
I could find only this as the package installation file having astropy. Should this be made to `Astropy >= 3.0.2 & Astropy != 3.1.0"` or I am missing something?

 [https://github.com/PlasmaPy/PlasmaPy/blob/3e919ff0b69e2bfc735e0e60e26f1a34659eba5e/requirements/requirements.txt#L3](https://github.com/PlasmaPy/PlasmaPy/blob/3e919ff0b69e2bfc735e0e60e26f1a34659eba5e/requirements/requirements.txt#L3)
@manasbedmutha98 Yep, modifying that line to a format which requirements.txt accepts would be the way to go. I think replacing it with something like `astropy (>= 3.0.2, != 3.1.0)` should work.

Perhaps it would be also be a good idea to add a comment in requirements.txt referencing this issue for why we do not want `astropy v3.1.0`.
Wait. This doesn't seems to be working. If I `pip install "astropy==3.1.0"` and then modify the astropy line in `requirements.txt` to `astropy (>= 3.0.2, != 3.1.0)`. It doesn't seem to install a different version (anything other than `v3.1.0`) when running `python setup.py install`.

This seems a problem specific to PlasmaPy as I am able to create a dummy `test.txt` with a line containing `astropy (>= 3.0.2, != 3.1.0)` and then when installing it with `pip install -r test.txt` it indeed downgrades to `v3.0.5` from `v3.1.0`.


Resolving patch:
diff --git a/plasmapy/utils/pytest_helpers.py b/plasmapy/utils/pytest_helpers.py
--- a/plasmapy/utils/pytest_helpers.py
+++ b/plasmapy/utils/pytest_helpers.py
@@ -25,6 +25,22 @@
 _result_color = f"{_blue}{_bold}"
 _message_color = f"{_red}{_bold}"
 
+__all__ = [
+    "RunTestError",
+    "UnexpectedResultError",
+    "InconsistentTypeError",
+    "MissingExceptionError",
+    "UnexpectedResultError",
+    "MissingExceptionError",
+    "MissingWarningError",
+    "IncorrectResultError",
+    "InvalidTestError",
+    "call_string",
+    "run_test",
+    "run_test_equivalent_calls",
+    "assert_can_handle_nparray",
+]
+
 
 class RunTestError(Exception):
     """Base exception for test failures. Derived from `Exception`."""


Test patch:
diff --git a/plasmapy/mathematics/tests/test_Fermi_integral.py b/plasmapy/mathematics/tests/test_Fermi_integral.py
--- a/plasmapy/mathematics/tests/test_Fermi_integral.py
+++ b/plasmapy/mathematics/tests/test_Fermi_integral.py
@@ -48,14 +48,6 @@ def test_fail1(self):
                   f"not be equal to {fail1}.")
         assert testTrue, errStr
 
-    def test_polog_fail(self):
-        """
-        Test whether Fermi_integral fails due to `~mpmath.polylog`
-        not having an implementation for larger argument values.
-        """
-        with pytest.raises(NotImplementedError):
-            Fermi_integral(self.argFail1, self.order1)
-
     def test_array(self):
         """Test Fermi_integral where argument is an array of inputs."""
         methodVals = Fermi_integral(self.args, self.order1)
diff --git a/plasmapy/physics/tests/test_quantum.py b/plasmapy/physics/tests/test_quantum.py
--- a/plasmapy/physics/tests/test_quantum.py
+++ b/plasmapy/physics/tests/test_quantum.py
@@ -181,14 +181,6 @@ def test_fail1(self):
                   f"should not be equal to {fail1}.")
         assert testTrue, errStr
 
-    def test_polog_fail(self):
-        """
-        Tests whether Fermi_integral() fails due to polylog from mpmath
-        not having an implementation for larger argument values.
-        """
-        with pytest.raises(NotImplementedError):
-            chemical_potential(self.n_e_fail, self.T)
-
 
 class Test__chemical_potential_interp:
     @classmethod