diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 641f8d7..4790706 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: check-ast - id: trailing-whitespace @@ -30,12 +30,12 @@ repos: - python - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/nbQA-dev/nbQA - rev: 0.8.0 + rev: 1.3.1 hooks: - id: nbqa-black additional_dependencies: @@ -49,7 +49,7 @@ repos: - --nbqa-mutate - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.1.0 + rev: v2.3.0 hooks: - id: pretty-format-ini args: [--autofix] diff --git a/plasmapy_nei/nei/nei.py b/plasmapy_nei/nei/nei.py index d05c169..c9ccac9 100644 --- a/plasmapy_nei/nei/nei.py +++ b/plasmapy_nei/nei/nei.py @@ -88,15 +88,15 @@ def __init__( self._number_densities = { elem: np.full((max_steps + 1, self.nstates[elem]), np.nan, dtype=np.float64) - * u.cm ** -3 + * u.cm**-3 for elem in self.elements } self._n_elem = { - elem: np.full(max_steps + 1, np.nan) * u.cm ** -3 for elem in self.elements + elem: np.full(max_steps + 1, np.nan) * u.cm**-3 for elem in self.elements } - self._n_e = np.full(max_steps + 1, np.nan) * u.cm ** -3 + self._n_e = np.full(max_steps + 1, np.nan) * u.cm**-3 self._T_e = np.full(max_steps + 1, np.nan) * u.K self._time = np.full(max_steps + 1, np.nan) * u.s @@ -161,7 +161,7 @@ def _assign( } # Calculate the electron number density - n_e = 0.0 * u.cm ** -3 + n_e = 0.0 * u.cm**-3 for elem in elements: integer_charges = np.linspace( 0, self.nstates[elem] - 1, self.nstates[elem] @@ -920,7 +920,7 @@ def n_input(self) -> u.Quantity: def n_input(self, n: u.Quantity): if isinstance(n, u.Quantity): try: - n = n.to(u.cm ** -3) + n = n.to(u.cm**-3) except u.UnitConversionError: raise u.UnitsError("Invalid hydrogen density.") if n.isscalar: @@ -938,13 +938,13 @@ def n_input(self, n: u.Quantity): bounds_error=False, fill_value="extrapolate", ) - self._hydrogen_number_density = lambda time: f(time.value) * u.cm ** -3 + self._hydrogen_number_density = lambda time: f(time.value) * u.cm**-3 self._n_input = n elif callable(n): if self.time_start is not None: try: - n(self.time_start).to(u.cm ** -3) - n(self.time_max).to(u.cm ** -3) + n(self.time_start).to(u.cm**-3) + n(self.time_max).to(u.cm**-3) except Exception: raise ValueError("Invalid number density function.") self._n_input = n diff --git a/plasmapy_nei/nei/tests/test_nei.py b/plasmapy_nei/nei/tests/test_nei.py index bdf49d5..642e023 100644 --- a/plasmapy_nei/nei/tests/test_nei.py +++ b/plasmapy_nei/nei/tests/test_nei.py @@ -13,7 +13,7 @@ time_array = np.array([0, 800]) * u.s T_e_array = np.array([4e4, 6e4]) * u.K -n_array = np.array([1e9, 5e8]) * u.cm ** -3 +n_array = np.array([1e9, 5e8]) * u.cm**-3 @pytest.fixture( @@ -57,7 +57,7 @@ "inputs": inputs_dict, "abundances": abundances, "T_e": T_e_array, - "n": 1e9 * u.cm ** -3, + "n": 1e9 * u.cm**-3, "time_input": time_array, "time_start": 0 * u.s, "time_max": 800 * u.s, @@ -73,7 +73,7 @@ "inputs": inputs_dict, "abundances": abundances, "T_e": lambda time: 1e4 * (1 + time / u.s) * u.K, - "n": 1e15 * u.cm ** -3, + "n": 1e15 * u.cm**-3, "time_max": 800 * u.s, "max_steps": 2, "dt": 100 * u.s, @@ -87,7 +87,7 @@ "inputs": inputs_dict, "abundances": abundances, "T_e": 6e4 * u.K, - "n": lambda time: 1e9 * (1 + time / u.s) * u.cm ** -3, + "n": lambda time: 1e9 * (1 + time / u.s) * u.cm**-3, "time_start": 0 * u.s, "time_max": 800 * u.s, "adapt_dt": False, @@ -109,7 +109,7 @@ "Fe": 1e-4, }, "T_e": 10001.0 * u.K, - "n": 1e13 * u.cm ** -3, + "n": 1e13 * u.cm**-3, "time_max": 2e6 * u.s, "tol": 1e-9, "adapt_dt": False, @@ -132,7 +132,7 @@ "S": 2e-6, }, "T_e": 7e6 * u.K, - "n": 1e9 * u.cm ** -3, + "n": 1e9 * u.cm**-3, "time_max": 1e8 * u.s, "dt": 5e7 * u.s, "max_steps": 3, @@ -150,7 +150,7 @@ }, "abundances": {"H": 1, "He": 0.1, "O": 1e-4}, "T_e": 3e6 * u.K, - "n": 1e9 * u.cm ** -3, + "n": 1e9 * u.cm**-3, "dt": 1e6 * u.s, "time_start": 0 * u.s, "time_max": 1e6 * u.s, @@ -165,7 +165,7 @@ "inputs": ["H", "He"], "abundances": {"H": 1, "He": 0.1}, "T_e": lambda t: u.K * (1e6 + 1.3e4 * np.sin(t.value)), - "n": 1e10 * u.cm ** -3, + "n": 1e10 * u.cm**-3, "max_steps": 300, "time_start": 0 * u.s, "time_max": 2 * np.pi * u.s,