Repository: PlasmaPy/PlasmaPy
Pull request #481 (2018-05-31 13:58:07)

Improve documentation and simplify syntax of check_quantity
This PR kind of grew on me. While reworking the examples, I realized this syntax was dumb:
```python
@utils.check_quantity({
    'T': {'units': u.K, 'can_be_negative': False},
    'n_e': {'units': u.m**-3, 'can_be_negative': False},
})
```

And this syntax looked better:
```python
@utils.check_quantity(
    T={'units': u.K, 'can_be_negative': False},
    n_e={'units': u.m**-3, 'can_be_negative': False},
)
```

So I went ahead and changed everything up. This of course required changes to wherever `check_quantity` was used.

In fact, I think it would make sense to change this up further in a couple of different ways... but that's for another issue, I think.


Patch:
diff --git a/plasmapy/physics/conftest.py b/plasmapy/conftest.py
similarity index 100%
rename from plasmapy/physics/conftest.py
rename to plasmapy/conftest.py
diff --git a/plasmapy/diagnostics/langmuir.py b/plasmapy/diagnostics/langmuir.py
index c8ad1db9..93045695 100644
--- a/plasmapy/diagnostics/langmuir.py
+++ b/plasmapy/diagnostics/langmuir.py
@@ -69,16 +69,16 @@ class Characteristic:
 
     """
 
-    @utils.check_quantity({'bias': {'units': u.V,
-                                    'can_be_negative': True,
-                                    'can_be_complex': False,
-                                    'can_be_inf': False,
-                                    'can_be_nan': True},
-                           'current': {'units': u.A,
-                                       'can_be_negative': True,
-                                       'can_be_complex': False,
-                                       'can_be_inf': False,
-                                       'can_be_nan': True}})
+    @utils.check_quantity(bias={'units': u.V,
+                                'can_be_negative': True,
+                                'can_be_complex': False,
+                                'can_be_inf': False,
+                                'can_be_nan': True},
+                          current={'units': u.A,
+                                   'can_be_negative': True,
+                                   'can_be_complex': False,
+                                   'can_be_inf': False,
+                                   'can_be_nan': True})
     def __init__(self, bias, current):
         self.bias = bias
         self.current = current
@@ -200,16 +200,16 @@ def plot(self):  # coveralls: ignore
             plt.title("Probe characteristic")
 
 
-@utils.check_quantity({'probe_area': {'units': u.m**2,
-                                      'can_be_negative': False,
-                                      'can_be_complex': False,
-                                      'can_be_inf': False,
-                                      'can_be_nan': False},
-                       'gas': {'units': u.u,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False}})
+@utils.check_quantity(probe_area={'units': u.m**2,
+                                  'can_be_negative': False,
+                                  'can_be_complex': False,
+                                  'can_be_inf': False,
+                                  'can_be_nan': False},
+                      gas={'units': u.u,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False})
 def swept_probe_analysis(probe_characteristic, probe_area, gas,
                          bimaxwellian=False, visualize=False,
                          plot_electron_fit=False, plot_EEDF=False):
@@ -534,26 +534,26 @@ def get_ion_saturation_current(probe_characteristic):
     return np.min(probe_characteristic.current)
 
 
-@utils.check_quantity({'ion_saturation_current': {'units': u.A,
-                                                  'can_be_negative': True,
-                                                  'can_be_complex': False,
-                                                  'can_be_inf': False,
-                                                  'can_be_nan': False},
-                       'T_e': {'units': u.eV,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False},
-                       'probe_area': {'units': u.m**2,
-                                      'can_be_negative': False,
-                                      'can_be_complex': False,
-                                      'can_be_inf': False,
-                                      'can_be_nan': False},
-                       'gas': {'units': u.u,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False}})
+@utils.check_quantity(ion_saturation_current={'units': u.A,
+                                              'can_be_negative': True,
+                                              'can_be_complex': False,
+                                              'can_be_inf': False,
+                                              'can_be_nan': False},
+                      T_e={'units': u.eV,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False},
+                      probe_area={'units': u.m**2,
+                                  'can_be_negative': False,
+                                  'can_be_complex': False,
+                                  'can_be_inf': False,
+                                  'can_be_nan': False},
+                      gas={'units': u.u,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False})
 def get_ion_density_LM(ion_saturation_current, T_e,
                        probe_area, gas):
     r"""Implement the Langmuir-Mottley (LM) method of obtaining the ion
@@ -600,21 +600,21 @@ def get_ion_density_LM(ion_saturation_current, T_e,
     return n_i.to(u.m**-3)
 
 
-@utils.check_quantity({'electron_saturation_current': {'units': u.A,
-                                                       'can_be_negative': True,
-                                                       'can_be_complex': False,
-                                                       'can_be_inf': False,
-                                                       'can_be_nan': False},
-                       'T_e': {'units': u.eV,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False},
-                       'probe_area': {'units': u.m**2,
-                                      'can_be_negative': False,
-                                      'can_be_complex': False,
-                                      'can_be_inf': False,
-                                      'can_be_nan': False}})
+@utils.check_quantity(electron_saturation_current={'units': u.A,
+                                                   'can_be_negative': True,
+                                                   'can_be_complex': False,
+                                                   'can_be_inf': False,
+                                                   'can_be_nan': False},
+                      T_e={'units': u.eV,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False},
+                      probe_area={'units': u.m**2,
+                                  'can_be_negative': False,
+                                  'can_be_complex': False,
+                                  'can_be_inf': False,
+                                  'can_be_nan': False})
 def get_electron_density_LM(electron_saturation_current, T_e,
                             probe_area):
     r"""Implement the Langmuir-Mottley (LM) method of obtaining the electron
@@ -962,11 +962,11 @@ def extrapolate_electron_current(probe_characteristic, fit,
     return electron_characteristic
 
 
-@utils.check_quantity({'T_e': {'units': u.eV,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False}})
+@utils.check_quantity(T_e={'units': u.eV,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False})
 def reduce_bimaxwellian_temperature(T_e, hot_fraction):
     r"""Reduce a bi-Maxwellian (dual) temperature to a single mean temperature
     for a given fraction.
@@ -1005,16 +1005,16 @@ def reduce_bimaxwellian_temperature(T_e, hot_fraction):
     return T_e[0] * (1 - hot_fraction) + T_e[1] * hot_fraction
 
 
-@utils.check_quantity({'probe_area': {'units': u.m**2,
-                                      'can_be_negative': False,
-                                      'can_be_complex': False,
-                                      'can_be_inf': False,
-                                      'can_be_nan': False},
-                       'gas': {'units': u.u,
-                               'can_be_negative': False,
-                               'can_be_complex': False,
-                               'can_be_inf': False,
-                               'can_be_nan': False}})
+@utils.check_quantity(probe_area={'units': u.m**2,
+                                  'can_be_negative': False,
+                                  'can_be_complex': False,
+                                  'can_be_inf': False,
+                                  'can_be_nan': False},
+                      gas={'units': u.u,
+                           'can_be_negative': False,
+                           'can_be_complex': False,
+                           'can_be_inf': False,
+                           'can_be_nan': False})
 def get_ion_density_OML(probe_characteristic, probe_area, gas,
                         visualize=False, return_fit=False):
     r"""Implement the Orbital Motion Limit (OML) method of obtaining an
diff --git a/plasmapy/physics/dielectric.py b/plasmapy/physics/dielectric.py
index f7b3c8d7..7efb23ba 100644
--- a/plasmapy/physics/dielectric.py
+++ b/plasmapy/physics/dielectric.py
@@ -3,7 +3,6 @@
 from astropy import units as u
 from plasmapy import utils
 from plasmapy.physics import parameters
-from plasmapy.constants import (pi, m_e, c, mu0, e, eps0)
 
 r"""
 Values should be returned as a `~astropy.units.Quantity` in SI units.
@@ -12,10 +11,11 @@
 __all__ = ['cold_plasma_permittivity_SDP',
            'cold_plasma_permittivity_LRP']
 
-@utils.check_quantity({
-    'B': {'units': u.T, 'can_be_negative': False},
-    'omega': {'units': u.rad / u.s, 'can_be_negative': False},
-})
+
+@utils.check_quantity(
+    B={'units': u.T, 'can_be_negative': False},
+    omega={'units': u.rad / u.s, 'can_be_negative': False},
+    )
 def cold_plasma_permittivity_SDP(B, species, n, omega):
     r"""
     Magnetized Cold Plasma Dielectric Permittivity Tensor Elements.
@@ -109,7 +109,11 @@ def cold_plasma_permittivity_SDP(B, species, n, omega):
     return S, D, P
 
 
-def cold_plasma_permittivity_LRP(B, species, n, omega):
+@utils.check_quantity(
+    B={'units': u.T, 'can_be_negative': False},
+    omega={'units': u.rad / u.s, 'can_be_negative': False},
+    )
+def cold_plasma_permittivity_LRP(B: u.T, species, n, omega: u.rad / u.s):
     r"""
     Magnetized Cold Plasma Dielectric Permittivity Tensor Elements.
 
diff --git a/plasmapy/physics/dimensionless.py b/plasmapy/physics/dimensionless.py
index 4c4f4d09..0593ed2e 100644
--- a/plasmapy/physics/dimensionless.py
+++ b/plasmapy/physics/dimensionless.py
@@ -16,10 +16,11 @@
 
 __all__ = ['quantum_theta', 'beta']
 
-@utils.check_quantity({
-    'T': {'units': u.K, 'can_be_negative': False},
-    'n_e': {'units': u.m**-3, 'can_be_negative': False},
-})
+
+@utils.check_quantity(
+    T={'units': u.K, 'can_be_negative': False},
+    n_e={'units': u.m**-3, 'can_be_negative': False},
+)
 def quantum_theta(T: u.K, n_e: u.m**-3):
     """
     Compares Fermi energy to thermal kinetic energy to check if quantum
@@ -55,11 +56,11 @@ def quantum_theta(T: u.K, n_e: u.m**-3):
     return theta
 
 
-@utils.check_quantity({
-    'T': {'units': u.K, 'can_be_negative': False},
-    'n': {'units': u.m**-3, 'can_be_negative': False},
-    'B': {'units': u.T}
-})
+@utils.check_quantity(
+    T={'units': u.K, 'can_be_negative': False},
+    n={'units': u.m**-3, 'can_be_negative': False},
+    B={'units': u.T}
+)
 def beta(T: u.K, n: u.m**-3, B: u.T):
     """
     The ratio of thermal pressure to magnetic pressure.
diff --git a/plasmapy/physics/parameters.py b/plasmapy/physics/parameters.py
index f01bea4e..24ff421f 100644
--- a/plasmapy/physics/parameters.py
+++ b/plasmapy/physics/parameters.py
@@ -113,9 +113,9 @@ def mass_density(density, particle: str = None, z_mean: float = None) -> u.kg /
 
 
 @utils.check_relativistic
-@utils.check_quantity({'B': {'units': u.T},
-                       'density': {'units': [u.m ** -3, u.kg / u.m ** 3],
-                                   'can_be_negative': False}})
+@utils.check_quantity(B={'units': u.T},
+                      density={'units': [u.m ** -3, u.kg / u.m ** 3],
+                               'can_be_negative': False})
 def Alfven_speed(B, density, ion="p+", z_mean=None):
     r"""
     Return the Alfven speed.
@@ -216,10 +216,10 @@ def Alfven_speed(B, density, ion="p+", z_mean=None):
 
 
 @utils.check_relativistic
-@utils.check_quantity({
-    'T_i': {'units': u.K, 'can_be_negative': False},
-    'T_e': {'units': u.K, 'can_be_negative': False}
-    })
+@utils.check_quantity(
+    T_i={'units': u.K, 'can_be_negative': False},
+    T_e={'units': u.K, 'can_be_negative': False}
+    )
 def ion_sound_speed(T_e,
                     T_i,
                     gamma_e=1,
@@ -353,12 +353,13 @@ def ion_sound_speed(T_e,
 
 
 @utils.check_relativistic
-@utils.check_quantity({
-    'T': {'units': u.K, 'can_be_negative': False},
-    'mass': {'units': u.kg, 'can_be_negative': False, 'can_be_nan': True}
-    })
+@utils.check_quantity(
+    T={'units': u.K, 'can_be_negative': False},
+    mass={'units': u.kg, 'can_be_negative': False, 'can_be_nan': True}
+    )
 @atomic.particle_input
-def thermal_speed(T, particle: atomic.Particle="e-", method="most_probable", mass=np.nan*u.kg):
+def thermal_speed(T, particle: atomic.Particle = "e-", method="most_probable",
+                  mass=np.nan*u.kg):
     r"""
     Return the most probable speed for a particle within a Maxwellian
     distribution.
@@ -459,10 +460,10 @@ def thermal_speed(T, particle: atomic.Particle="e-", method="most_probable", mas
     return V
 
 
-@utils.check_quantity({
-    'T': {'units': u.K, 'can_be_negative': False},
-    'n': {'units': u.m**-3, 'can_be_negative': False}
-    })
+@utils.check_quantity(
+    T={'units': u.K, 'can_be_negative': False},
+    n={'units': u.m**-3, 'can_be_negative': False}
+    )
 def thermal_pressure(T, n):
     r"""
     Return the thermal pressure for a Maxwellian distribution.
@@ -510,9 +511,9 @@ def thermal_pressure(T, n):
 
 
 @utils.check_relativistic
-@utils.check_quantity({
-    'T': {'units': u.K, 'can_be_negative': False}
-    })
+@utils.check_quantity(
+    T={'units': u.K, 'can_be_negative': False}
+    )
 def kappa_thermal_speed(T, kappa, particle="e-", method="most_probable"):
     r"""Return the most probable speed for a particle within a Kappa
     distribution.
@@ -615,11 +616,11 @@ def kappa_thermal_speed(T, kappa, particle="e-", method="most_probable"):
     return vTh * coeff
 
 
-@utils.check_quantity({
-    'n': {'units': u.m ** -3, 'can_be_negative': False},
-    'T': {'units': u.K, 'can_be_negative': False},
-    'B': {'units': u.T}
-    })
+@utils.check_quantity(
+    n={'units': u.m ** -3, 'can_be_negative': False},
+    T={'units': u.K, 'can_be_negative': False},
+    B={'units': u.T}
+    )
 def Hall_parameter(n,
                    T,
                    B,
@@ -678,10 +679,8 @@ def Hall_parameter(n,
     return gyro_frequency / coll_rate
 
 
-@utils.check_quantity({
-    'B': {'units': u.T}
-    })
-def gyrofrequency(B, particle='e-', signed=False, Z=None):
+@utils.check_quantity(B={'units': u.T})
+def gyrofrequency(B: u.T, particle='e-', signed=False, Z=None):
     r"""Calculate the particle gyrofrequency in units of radians per second.
 
     Parameters
@@ -778,11 +777,15 @@ def gyrofrequency(B, particle='e-', signed=False, Z=None):
     return omega_ci
 
 
-@utils.check_quantity({'B': {'units': u.T},
-                       'Vperp': {'units': u.m / u.s, 'can_be_nan': True},
-                       'T_i': {'units': u.K, 'can_be_nan': True},
-                       })
-def gyroradius(B, particle='e-', *, Vperp=np.nan * u.m / u.s, T_i=np.nan * u.K):
+@utils.check_quantity(B={'units': u.T},
+                      Vperp={'units': u.m / u.s, 'can_be_nan': True},
+                      T_i={'units': u.K, 'can_be_nan': True},
+                      )
+def gyroradius(B: u.T,
+               particle='e-',
+               *,
+               Vperp: u.m / u.s = np.nan * u.m / u.s,
+               T_i: u.K = np.nan * u.K):
     r"""Return the particle gyroradius.
 
     Parameters
@@ -921,10 +924,10 @@ def gyroradius(B, particle='e-', *, Vperp=np.nan * u.m / u.s, T_i=np.nan * u.K):
     return r_Li.to(u.m, equivalencies=u.dimensionless_angles())
 
 
-@utils.check_quantity({
-    'n': {'units': u.m ** -3, 'can_be_negative': False}
-    })
-def plasma_frequency(n, particle='e-', z_mean=None):
+@utils.check_quantity(
+    n={'units': u.m ** -3, 'can_be_negative': False}
+    )
+def plasma_frequency(n: u.m**-3, particle='e-', z_mean=None):
     r"""Calculate the particle plasma frequency.
 
     Parameters
@@ -1017,11 +1020,11 @@ def plasma_frequency(n, particle='e-', z_mean=None):
     return omega_p.si
 
 
-@utils.check_quantity({
-    'T_e': {'units': u.K, 'can_be_negative': False},
-    'n_e': {'units': u.m ** -3, 'can_be_negative': False}
-    })
-def Debye_length(T_e, n_e):
+@utils.check_quantity(
+    T_e={'units': u.K, 'can_be_negative': False},
+    n_e={'units': u.m ** -3, 'can_be_negative': False}
+    )
+def Debye_length(T_e: u.K, n_e: u.m**-3):
     r"""Calculate the characteristic decay length for electric fields,
      due to charge screening.
 
@@ -1087,11 +1090,11 @@ def Debye_length(T_e, n_e):
     return lambda_D.to(u.m)
 
 
-@utils.check_quantity({
-    'T_e': {'units': u.K, 'can_be_negative': False},
-    'n_e': {'units': u.m ** -3, 'can_be_negative': False}
-    })
-def Debye_number(T_e, n_e):
+@utils.check_quantity(
+    T_e={'units': u.K, 'can_be_negative': False},
+    n_e={'units': u.m ** -3, 'can_be_negative': False}
+    )
+def Debye_number(T_e: u.K, n_e: u.m**-3):
     r"""Return the number of electrons within a sphere with a radius
     of the Debye length.
 
@@ -1154,10 +1157,10 @@ def Debye_number(T_e, n_e):
     return N_D.to(u.dimensionless_unscaled)
 
 
-@utils.check_quantity({
-    'n': {'units': u.m ** -3, 'can_be_negative': False}
-    })
-def inertial_length(n, particle='e-'):
+@utils.check_quantity(
+    n={'units': u.m ** -3, 'can_be_negative': False}
+    )
+def inertial_length(n: u.m**-3, particle='e-'):
     r"""Calculate the particle inertial length. At this length, the Hall effect
     becomes important.
 
@@ -1217,10 +1220,8 @@ def inertial_length(n, particle='e-'):
     return d
 
 
-@utils.check_quantity({
-    'B': {'units': u.T}
-    })
-def magnetic_pressure(B):
+@utils.check_quantity(B={'units': u.T})
+def magnetic_pressure(B: u.T):
     r"""
     Calculate the magnetic pressure.
 
@@ -1281,9 +1282,7 @@ def magnetic_pressure(B):
     return p_B
 
 
-@utils.check_quantity({
-    'B': {'units': u.T}
-    })
+@utils.check_quantity(B={'units': u.T})
 def magnetic_energy_density(B: u.T):
     r"""
     Calculate the magnetic energy density.
@@ -1345,11 +1344,11 @@ def magnetic_energy_density(B: u.T):
     return E_B
 
 
-@utils.check_quantity({
-    'B': {'units': u.T},
-    'n_e': {'units': u.m ** -3, 'can_be_negative': False}
-    })
-def upper_hybrid_frequency(B, n_e):
+@utils.check_quantity(
+    B={'units': u.T},
+    n_e={'units': u.m ** -3, 'can_be_negative': False}
+    )
+def upper_hybrid_frequency(B: u.T, n_e: u.m**-3):
     r"""
     Return the upper hybrid frequency.
 
@@ -1408,10 +1407,10 @@ def upper_hybrid_frequency(B, n_e):
     return omega_uh.to(u.rad / u.s)
 
 
-@utils.check_quantity({
-    'B': {'units': u.T},
-    'n_i': {'units': u.m ** -3, 'can_be_negative': False}
-    })
+@utils.check_quantity(
+    B={'units': u.T},
+    n_i={'units': u.m ** -3, 'can_be_negative': False}
+    )
 def lower_hybrid_frequency(B, n_i, ion='p+'):
     r"""
     Return the lower hybrid frequency.
diff --git a/plasmapy/physics/quantum.py b/plasmapy/physics/quantum.py
index 40658157..0cc7ef2e 100644
--- a/plasmapy/physics/quantum.py
+++ b/plasmapy/physics/quantum.py
@@ -24,12 +24,10 @@
 ]
 
 
-
 # TODO: Use @check_relativistic and @particle_input
-
-@utils.check_quantity({
-    'V': {'units': u.m / u.s, 'can_be_negative': True}
-    })
+@utils.check_quantity(
+    V={'units': u.m / u.s, 'can_be_negative': True}
+    )
 def deBroglie_wavelength(V, particle):
     r"""
     Calculates the de Broglie wavelength.
@@ -128,9 +126,9 @@ def deBroglie_wavelength(V, particle):
     return lambda_dBr.to(u.m)
 
 
-@utils.check_quantity({
-    'T_e': {'units': u.K, 'can_be_negative': False}
-})
+@utils.check_quantity(
+    T_e={'units': u.K, 'can_be_negative': False}
+)
 def thermal_deBroglie_wavelength(T_e):
     r"""
     Calculate the thermal deBroglie wavelength for electrons.
@@ -181,9 +179,9 @@ def thermal_deBroglie_wavelength(T_e):
     return lambda_dbTh.to(u.m)
 
 
-@utils.check_quantity({
-    'n_e': {'units': u.m**-3, 'can_be_negative': False}
-})
+@utils.check_quantity(
+    n_e={'units': u.m**-3, 'can_be_negative': False}
+)
 def Fermi_energy(n_e):
     r"""
     Calculate the kinetic energy in a degenerate electron gas.
@@ -242,9 +240,9 @@ def Fermi_energy(n_e):
     return energy_F.to(u.Joule)
 
 
-@utils.check_quantity({
-    'n_e': {'units': u.m**-3, 'can_be_negative': False}
-})
+@utils.check_quantity(
+    n_e={'units': u.m**-3, 'can_be_negative': False}
+)
 def Thomas_Fermi_length(n_e):
     r"""
     Calculate the exponential scale length for charge screening
@@ -313,9 +311,9 @@ def Thomas_Fermi_length(n_e):
     return lambda_TF.to(u.m)
 
 
-@check_quantity({
-    'n': {'units': u.m**-3, 'can_be_negative': False}
-})
+@check_quantity(
+    n={'units': u.m**-3, 'can_be_negative': False}
+)
 def Wigner_Seitz_radius(n: u.m**-3):
     r"""
     Calculate the Wigner-Seitz radius, which approximates the inter-
diff --git a/plasmapy/physics/relativity.py b/plasmapy/physics/relativity.py
index ef984c85..9d5f3f63 100644
--- a/plasmapy/physics/relativity.py
+++ b/plasmapy/physics/relativity.py
@@ -6,15 +6,16 @@
 from astropy import units as u
 
 from plasmapy.constants import c
-from plasmapy import atomic, utils
+from plasmapy import utils
 
 __all__ = [
     "Lorentz_factor",
 ]
 
-@utils.check_quantity({
-    'V': {'units': u.m / u.s, 'can_be_negative': True}
-    })
+
+@utils.check_quantity(
+    V={'units': u.m / u.s, 'can_be_negative': True}
+    )
 def Lorentz_factor(V: u.m / u.s):
     r"""
     Return the Lorentz factor.
diff --git a/plasmapy/physics/transport/braginskii.py b/plasmapy/physics/transport/braginskii.py
index 7617683f..774d882d 100644
--- a/plasmapy/physics/transport/braginskii.py
+++ b/plasmapy/physics/transport/braginskii.py
@@ -295,16 +295,16 @@ class can be initialized once with all of the variables necessary for
 
     """
 
-    @utils.check_quantity({"T_e": {"units": u.K, "can_be_negative": False},
-                           "n_e": {"units": u.m ** -3},
-                           "T_i": {"units": u.K, "can_be_negative": False},
-                           "n_i": {"units": u.m ** -3},
-                           })
+    @utils.check_quantity(T_e={"units": u.K, "can_be_negative": False},
+                          n_e={"units": u.m ** -3},
+                          T_i={"units": u.K, "can_be_negative": False},
+                          n_i={"units": u.m ** -3},
+                          )
     def __init__(self,
-                 T_e,
-                 n_e,
-                 T_i,
-                 n_i,
+                 T_e: u.K,
+                 n_e: u.m**-3,
+                 T_i: u.K,
+                 n_i: u.m**-3,
                  ion_particle,
                  m_i=None,
                  Z=None,
diff --git a/plasmapy/physics/transport/collisions.py b/plasmapy/physics/transport/collisions.py
index 2f33222d..95df6443 100644
--- a/plasmapy/physics/transport/collisions.py
+++ b/plasmapy/physics/transport/collisions.py
@@ -70,12 +70,11 @@
     "mobility",
     "Knudsen_number",
     "coupling_parameter",
-]
+    ]
 
 
-@utils.check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                       "n_e": {"units": u.m ** -3}
-                       })
+@utils.check_quantity(T={"units": u.K, "can_be_negative": False},
+                      n_e={"units": u.m ** -3})
 def Coulomb_logarithm(T,
                       n_e,
                       particles,
@@ -315,8 +314,7 @@ def _boilerPlate(T, particles, V):
     return T, masses, charges, reduced_mass, V
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False})
 def impact_parameter_perp(T,
                           particles,
                           V=np.nan * u.m / u.s):
@@ -404,9 +402,9 @@ def impact_parameter_perp(T,
     return bPerp.to(u.m)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n_e": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n_e={"units": u.m ** -3}
+                )
 def impact_parameter(T,
                      n_e,
                      particles,
@@ -595,9 +593,9 @@ def impact_parameter(T,
     return bmin.to(u.m), bmax.to(u.m)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n={"units": u.m ** -3}
+                )
 def collision_frequency(T,
                         n,
                         particles,
@@ -772,10 +770,7 @@ def collision_frequency(T,
     return freq.to(u.Hz)
 
 
-@check_quantity({
-    'impact_param': {'units': u.m,
-                    'can_be_negative': False}
-    })
+@check_quantity(impact_param={'units': u.m, 'can_be_negative': False})
 def Coulomb_cross_section(impact_param: u.m):
     r"""Cross section for a large angle Coulomb collision.
 
@@ -816,10 +811,11 @@ def Coulomb_cross_section(impact_param: u.m):
     sigma = np.pi * (2 * impact_param) ** 2
     return sigma
 
-@utils.check_quantity({
-    'T_e': {'units': u.K, 'can_be_negative': False},
-    'n_e': {'units': u.m ** -3, 'can_be_negative': False}
-    })
+
+@utils.check_quantity(
+    T_e={'units': u.K, 'can_be_negative': False},
+    n_e={'units': u.m ** -3, 'can_be_negative': False}
+    )
 def fundamental_electron_collision_freq(T_e,
                                         n_e,
                                         ion_particle,
@@ -945,10 +941,10 @@ def fundamental_electron_collision_freq(T_e,
     return nu_e.to(1 / u.s)
 
 
-@utils.check_quantity({
-    'T_i': {'units': u.K, 'can_be_negative': False},
-    'n_i': {'units': u.m ** -3, 'can_be_negative': False}
-    })
+@utils.check_quantity(
+    T_i={'units': u.K, 'can_be_negative': False},
+    n_i={'units': u.m ** -3, 'can_be_negative': False}
+    )
 def fundamental_ion_collision_freq(T_i,
                                    n_i,
                                    ion_particle,
@@ -1081,9 +1077,9 @@ def fundamental_ion_collision_freq(T_i,
     return nu_i.to(1 / u.s)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n_e": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n_e={"units": u.m ** -3}
+                )
 def mean_free_path(T,
                    n_e,
                    particles,
@@ -1199,9 +1195,9 @@ def mean_free_path(T,
     return mfp.to(u.m)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n={"units": u.m ** -3}
+                )
 def Spitzer_resistivity(T,
                         n,
                         particles,
@@ -1327,9 +1323,9 @@ def Spitzer_resistivity(T,
     return spitzer.to(u.Ohm * u.m)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n_e": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n_e={"units": u.m ** -3}
+                )
 def mobility(T,
              n_e,
              particles,
@@ -1454,9 +1450,9 @@ def mobility(T,
     return mobility_value.to(u.m ** 2 / (u.V * u.s))
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n_e": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n_e={"units": u.m ** -3}
+                )
 def Knudsen_number(characteristic_length,
                    T,
                    n_e,
@@ -1573,9 +1569,9 @@ def Knudsen_number(characteristic_length,
     return knudsen_param.to(u.dimensionless_unscaled)
 
 
-@check_quantity({"T": {"units": u.K, "can_be_negative": False},
-                 "n_e": {"units": u.m ** -3}
-                 })
+@check_quantity(T={"units": u.K, "can_be_negative": False},
+                n_e={"units": u.m ** -3}
+                )
 def coupling_parameter(T,
                        n_e,
                        particles,
diff --git a/plasmapy/utils/checks.py b/plasmapy/utils/checks.py
index b6f01f37..f0b11fe2 100644
--- a/plasmapy/utils/checks.py
+++ b/plasmapy/utils/checks.py
@@ -11,20 +11,72 @@
 
 __all__ = [
     "check_quantity",
+    "_check_quantity",
     "check_relativistic",
 ]
 
 
-def check_quantity(validations):  # TODO simplify via **kwargs
+def check_quantity(**validations):
     """
-    Raise an exception if an annotated argument in a decorated function
-    is an `~astropy.units.Quantity` with incorrect units and valid
-    numerical values, or assume inputs are SI Quantities.
+    Verify that the function's arguments have correct units.
+
+    This decorator raises an exception if an annotated argument in the
+    decorated function is an `~astropy.units.Quantity` with incorrect units
+    or of the incorrect # TODO name - Nones, NaNs, negatives...
+
+    If a number (non-Quantity) value is inserted in place of a value with units,
+    assume the input is an SI Quantity and cast it to one.
+
+    This is probably best illustrated with an example:
+
+    Examples
+    --------
+    >>> from astropy import units as u
+    >>> @check_quantity(x={"units": u.m,
+    ...       "can_be_negative": False,
+    ...       "can_be_complex": True,
+    ...       "can_be_inf": True})
+    ... def func(x):
+    ...     return x
+
+    >>> func(1 * u.m)
+    <Quantity 1. m>
+
+    >>> func(1 * u.s)
+    Traceback (most recent call last):
+      ...
+    astropy.units.core.UnitConversionError: The argument x to func should be a Quantity with the following units: m
+
+    >>> import pytest    # to show the UnitsWarning
+    >>> with pytest.warns(u.UnitsWarning, message="Assuming units of m."):
+    ...     func(1)
+    <Quantity 1. m>
+
+    >>> func(-1 * u.m)
+    Traceback (most recent call last):
+      ...
+    ValueError: The argument x to function func cannot contain negative numbers.
+
+    >>> func(np.inf * u.m)
+    <Quantity inf m>
+
+    >>> func(None)
+    Traceback (most recent call last):
+      ...
+    ValueError: The argument x to function func cannot contain Nones.
 
     Parameters
     ----------
-    validations : `dict`
-        Validation dictionary.
+    Arguments to be validated passed in as keyword
+    arguments, with values as validation dictionaries,
+    with structure as in the example.
+    Valid keys for each argument are:
+        'units': `astropy.units.Unit`,
+        'can_be_negative': `bool`,
+        'can_be_complex': `bool`,
+        'can_be_inf': `bool`,
+        'can_be_nan': `bool`,
+        'none_shall_pass': `bool`
 
     Raises
     ------
@@ -35,7 +87,7 @@ def check_quantity(validations):  # TODO simplify via **kwargs
     `~astropy.units.UnitConversionError`
         If the argument is not in acceptable units.
 
-    ~astropy.units.UnitsError
+    `~astropy.units.UnitsError`
         If after the assumption checks, the argument is still not in acceptable
         units.
 
@@ -45,7 +97,7 @@ def check_quantity(validations):  # TODO simplify via **kwargs
 
     Warns
     -----
-    ~astropy.units.UnitsWarning
+    `~astropy.units.UnitsWarning`
         If a `~astropy.units.Quantity` is not provided and unique units
         are provided, a `UnitsWarning` will be raised and the inputted
         units will be assumed.
@@ -55,25 +107,9 @@ def check_quantity(validations):  # TODO simplify via **kwargs
     function
         Decorated function.
 
-    Examples
+    See also
     --------
-    >>> from astropy import units as u
-    >>> @check_quantity({
-    ... "x": {"units": u.m},
-    ... "y": {"units": u.s,
-    ...       "can_be_negative": False,
-    ...       "can_be_complex": True,
-    ...       "can_be_inf": False}
-    ... })
-    ... def func(x: u.m, y: u.s=1 * u.s):
-    ...     return x
-    ...
-    >>> func(1 * u.m)
-    <Quantity 1. m>
-    >>> func(1 * u.m, 2 * u.m)
-    Traceback (most recent call last):
-      ...
-    astropy.units.core.UnitConversionError: The argument y to func should be a Quantity with the following units: s
+    _check_quantity
 
     """
     def decorator(f):
diff --git a/setup.cfg b/setup.cfg
index c14989df..504ccf85 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -51,7 +51,7 @@ auto_use = True
 # E113 - 4 spaces per indentation level
 # E901 - SyntaxError or IndentationError
 # E902 - IOError
-select = E226,E241,E242,E704,W504
+# select = E226,E241,E242,E704,W504
 exclude = astropy_helpers,ah_bootstrap.py,ez_setup.py,version.py,build
 max-line-length = 99
 


Test patch:
diff --git a/plasmapy/utils/tests/test_checks.py b/plasmapy/utils/tests/test_checks.py
index 4ec694d0..85465ab6 100644
--- a/plasmapy/utils/tests/test_checks.py
+++ b/plasmapy/utils/tests/test_checks.py
@@ -97,9 +97,7 @@ def test__check_quantity_default(value, units):
     "value, units, error", quantity_error_examples_default)
 def test_check_quantity_decorator_errors_default(value, units, error):
 
-    @check_quantity({
-        "x": {"units": units}
-    })
+    @check_quantity(x={"units": units})
     def func(x):
         return x
 
@@ -113,10 +111,10 @@ def func(x):
 def test_check_quantity_decorator_errors_non_default(
         value, units, can_be_negative, can_be_complex, can_be_inf, error):
 
-    @check_quantity({
-        "x": {"units": units, "can_be_negative": can_be_negative,
-              "can_be_complex": can_be_complex, "can_be_inf": can_be_inf}
-    })
+    @check_quantity(
+       x={"units": units, "can_be_negative": can_be_negative,
+          "can_be_complex": can_be_complex, "can_be_inf": can_be_inf}
+    )
     def func(x):
         return x
 
@@ -127,9 +125,7 @@ def func(x):
 @pytest.mark.parametrize("value, units", quantity_valid_examples_default)
 def test_check_quantity_decorator_default(value, units):
 
-    @check_quantity({
-        "x": {"units": units}
-    })
+    @check_quantity(x={"units": units})
     def func(x):
         return x
 
@@ -142,10 +138,9 @@ def func(x):
 def test_check_quantity_decorator_non_default(
         value, units, can_be_negative, can_be_complex, can_be_inf):
 
-    @check_quantity({
-        "x": {"units": units, "can_be_negative": can_be_negative,
-              "can_be_complex": can_be_complex, "can_be_inf": can_be_inf}
-    })
+    @check_quantity(x={"units": units, "can_be_negative": can_be_negative,
+                       "can_be_complex": can_be_complex, "can_be_inf": can_be_inf}
+                    )
     def func(x):
         return x
 
@@ -154,10 +149,10 @@ def func(x):
 
 def test_check_quantity_decorator_missing_validated_params():
 
-    @check_quantity({
-        "x": {"units": u.m},
-        "y": {"units": u.s}
-    })
+    @check_quantity(
+        x={"units": u.m},
+        y={"units": u.s}
+    )
     def func(x):
         return x
 
@@ -169,10 +164,10 @@ def func(x):
 
 def test_check_quantity_decorator_two_args_default():
 
-    @check_quantity({
-        "x": {"units": u.m},
-        "y": {"units": u.s}
-    })
+    @check_quantity(
+        x={"units": u.m},
+        y={"units": u.s}
+    )
     def func(x, y):
         return x / y
 
@@ -181,10 +176,10 @@ def func(x, y):
 
 def test_check_quantity_decorator_two_args_not_default():
 
-    @check_quantity({
-        "x": {"units": u.m, "can_be_negative": False},
-        "y": {"units": u.s}
-    })
+    @check_quantity(
+        x={"units": u.m, "can_be_negative": False},
+        y={"units": u.s}
+    )
     def func(x, y):
         return x / y
 
@@ -194,23 +189,24 @@ def func(x, y):
 
 def test_check_quantity_decorator_two_args_one_kwargs_default():
 
-    @check_quantity({
-        "x": {"units": u.m},
-        "y": {"units": u.s},
-        "z": {"units": u.eV}
-    })
+    @check_quantity(
+        x={"units": u.m},
+        y={"units": u.s},
+        z={"units": u.eV}
+    )
     def func(x, y, another, z=10 * u.eV):
         return x * y * z
 
     func(1 * u.m, 1 * u.s, 10 * u.T)
 
+
 def test_check_quantity_decorator_two_args_one_kwargs_not_default():
 
-    @check_quantity({
-        "x": {"units": u.m},
-        "y": {"units": u.s, "can_be_negative": False},
-        "z": {"units": u.eV, "can_be_inf": False}
-    })
+    @check_quantity(
+        x={"units": u.m},
+        y={"units": u.s, "can_be_negative": False},
+        z={"units": u.eV, "can_be_inf": False}
+    )
     def func(x, y, z=10 * u.eV):
         return x * y * z
 
@@ -219,10 +215,8 @@ def func(x, y, z=10 * u.eV):
 
 
 class Test_check_quantity_none_shall_pass:
-    @check_quantity({
-        "x": {"units": u.m, "none_shall_pass": True},
-    })
-    def func(self, x = None):
+    @check_quantity(x={"units": u.m, "none_shall_pass": True})
+    def func(self, x=None):
         if x is None:
             return 0 * u.m
         return x