From 6d8ea3acb60f260c5c248949ad1554cfc19db77a Mon Sep 17 00:00:00 2001 From: jordidj Date: Mon, 31 Jan 2022 11:53:31 +0100 Subject: [PATCH] black formatting v2.21 --- post_processing/pylbo/data_containers.py | 2 +- post_processing/pylbo/utilities/toolbox.py | 12 ++++++------ post_processing/pylbo/visualisation/continua.py | 12 ++++++------ .../pylbo/visualisation/derived_eigenfunctions.py | 2 +- post_processing/pylbo/visualisation/profiles.py | 2 +- post_processing/pylbo/visualisation/spectra.py | 2 +- tests/pylbo_tests/test_visualisations_spectra.py | 2 +- tests/regression_tests/test_multi_gravito_HD.py | 2 +- tests/regression_tests/test_multi_gravito_MHD.py | 2 +- tests/regression_tests/test_multi_interchange.py | 2 +- tests/regression_tests/test_multi_iso_atmo.py | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/post_processing/pylbo/data_containers.py b/post_processing/pylbo/data_containers.py index e74c72b4..421f7a9c 100644 --- a/post_processing/pylbo/data_containers.py +++ b/post_processing/pylbo/data_containers.py @@ -400,7 +400,7 @@ def get_tube_speed(self, which_values=None): else: cA = self.get_alfven_speed() cs = self.get_sound_speed() - ct = cs * cA / np.sqrt(cs ** 2 + cA ** 2) + ct = cs * cA / np.sqrt(cs**2 + cA**2) return self._get_values(ct, which_values) def get_reynolds_nb(self, which_values=None): diff --git a/post_processing/pylbo/utilities/toolbox.py b/post_processing/pylbo/utilities/toolbox.py index 43273dcc..3a75f4ea 100644 --- a/post_processing/pylbo/utilities/toolbox.py +++ b/post_processing/pylbo/utilities/toolbox.py @@ -170,20 +170,20 @@ def solve_cubic_exact(a, b, c, d): q = c / a r = d / a Aterm = ( - -2 * p ** 3 + -2 * p**3 + 9 * p * q - 27 * r + 3 * np.sqrt(3) * np.sqrt( - -(p ** 2) * q ** 2 - + 4 * q ** 3 - + 4 * p ** 3 * r + -(p**2) * q**2 + + 4 * q**3 + + 4 * p**3 * r - 18 * p * q * r - + 27 * r ** 2 + + 27 * r**2 ) ) ** (1 / 3) / (3 * 2 ** (1 / 3)) - Bterm = (-(p ** 2) + 3 * q) / (9 * Aterm) + Bterm = (-(p**2) + 3 * q) / (9 * Aterm) cterm_min = (-1 - np.sqrt(3) * 1j) / 2 cterm_pos = (-1 + np.sqrt(3) * 1j) / 2 x1 = -p / 3 + Aterm - Bterm diff --git a/post_processing/pylbo/visualisation/continua.py b/post_processing/pylbo/visualisation/continua.py index 4c1048e3..81771196 100644 --- a/post_processing/pylbo/visualisation/continua.py +++ b/post_processing/pylbo/visualisation/continua.py @@ -35,7 +35,7 @@ def calculate_continua(ds): # Alfven and slow continuum (squared) alfven2 = (1 / rho) * ((k2 * B02 / ds.scale_factor) + k3 * B03) ** 2 - slow2 = (gamma * p / (gamma * p + B0 ** 2)) * alfven2 + slow2 = (gamma * p / (gamma * p + B0**2)) * alfven2 # doppler shift equals dot product of k and v doppler = k2 * v02 / ds.scale_factor + k3 * v03 slow_min = -np.sqrt(slow2) @@ -50,7 +50,7 @@ def calculate_continua(ds): else: kpara = 0 cs2 = gamma * p / rho # sound speed - vA2 = B0 ** 2 / rho # Alfvén speed + vA2 = B0**2 / rho # Alfvén speed ci2 = p / rho # isothermal sound speed dLdT = ds.equilibria["dLdT"] dLdrho = ds.equilibria["dLdrho"] @@ -71,7 +71,7 @@ def calculate_continua(ds): elif slow_is_zero: thermal = 1j * (gamma - 1) * (rho * dLdrho - dLdT * (ci2 + vA2)) / (cs2 + vA2) else: - sigma_A2 = kpara ** 2 * vA2 # Alfvén frequency + sigma_A2 = kpara**2 * vA2 # Alfvén frequency sigma_c2 = cs2 * sigma_A2 / (vA2 + cs2) # cusp frequency sigma_i2 = ci2 * sigma_A2 / (vA2 + ci2) # isothermal cusp frequency @@ -79,12 +79,12 @@ def calculate_continua(ds): # coeffi means the coefficient corresponding to the term omega^i coeff3 = rho * (cs2 + vA2) * 1j / (gamma - 1) coeff2 = ( - -(kappa_para * kpara ** 2 + rho * dLdT) * (ci2 + vA2) + rho ** 2 * dLdrho + -(kappa_para * kpara**2 + rho * dLdT) * (ci2 + vA2) + rho**2 * dLdrho ) coeff1 = -rho * (cs2 + vA2) * sigma_c2 * 1j / (gamma - 1) - coeff0 = (kappa_para * kpara ** 2 + rho * dLdT) * ( + coeff0 = (kappa_para * kpara**2 + rho * dLdT) * ( ci2 + vA2 - ) * sigma_i2 - rho ** 2 * dLdrho * sigma_A2 + ) * sigma_i2 - rho**2 * dLdrho * sigma_A2 # we have to solve this equation "gauss_gridpts" times. # the thermal continuum corresponds to the (only) purely imaginary solution, # modified slow continuum are other two solutions diff --git a/post_processing/pylbo/visualisation/derived_eigenfunctions.py b/post_processing/pylbo/visualisation/derived_eigenfunctions.py index dc537e4c..7a604c46 100644 --- a/post_processing/pylbo/visualisation/derived_eigenfunctions.py +++ b/post_processing/pylbo/visualisation/derived_eigenfunctions.py @@ -78,7 +78,7 @@ def _get_title(self, ef_name): ef_name = ef_name.replace("curl", "\\nabla\\times") ef_name = ef_name.replace("para", "\\parallel") ef_name = ef_name.replace("perp", "\\perp") - name = fr"{part}(${ef_name}$)" + name = rf"{part}(${ef_name}$)" return name def _mark_points_without_data_written(self): diff --git a/post_processing/pylbo/visualisation/profiles.py b/post_processing/pylbo/visualisation/profiles.py index d3e6493b..b4279d21 100644 --- a/post_processing/pylbo/visualisation/profiles.py +++ b/post_processing/pylbo/visualisation/profiles.py @@ -177,7 +177,7 @@ def draw(self): + b02 * db02 + b03 * db03 + rho * g - - (dr_scale / r_scale) * (rho * v02 ** 2 - b02 ** 2) + - (dr_scale / r_scale) * (rho * v02**2 - b02**2) ) equil_force[np.where(abs(equil_force) <= 1e-16)] = 0 self.ax.plot(self.data.grid_gauss, equil_force, **self.kwargs) diff --git a/post_processing/pylbo/visualisation/spectra.py b/post_processing/pylbo/visualisation/spectra.py index e65ab48c..01b22cae 100644 --- a/post_processing/pylbo/visualisation/spectra.py +++ b/post_processing/pylbo/visualisation/spectra.py @@ -329,7 +329,7 @@ def _get_ydata(self): """ ydata = np.empty(len(self.dataseries), dtype=object) for i, ds in enumerate(self.dataseries): - ydata[i] = ds.eigenvalues ** self._w_pow + ydata[i] = ds.eigenvalues**self._w_pow if self.use_real_parts: ydata[i] = ydata[i].real else: diff --git a/tests/pylbo_tests/test_visualisations_spectra.py b/tests/pylbo_tests/test_visualisations_spectra.py index d9d29c64..557b365c 100644 --- a/tests/pylbo_tests/test_visualisations_spectra.py +++ b/tests/pylbo_tests/test_visualisations_spectra.py @@ -178,7 +178,7 @@ def test_multispectrum_plot_ydata_squared(ds_v112, series_v112): p = pylbo.plot_spectrum_multi( series_v112, xdata="k3", use_squared_omega=True, use_real_parts=True ) - evs = (ds_v112.eigenvalues ** 2).real + evs = (ds_v112.eigenvalues**2).real for data in p.ydata: assert not np.all(np.isnan(data)) assert not np.all(np.isnan(evs)) diff --git a/tests/regression_tests/test_multi_gravito_HD.py b/tests/regression_tests/test_multi_gravito_HD.py index a2d4a7de..3527b360 100644 --- a/tests/regression_tests/test_multi_gravito_HD.py +++ b/tests/regression_tests/test_multi_gravito_HD.py @@ -22,7 +22,7 @@ "show_results": False, "logging_level": 0, }, - "xdata": 2 * _kvals ** 2, # k0**2 + "xdata": 2 * _kvals**2, # k0**2 "y_scaling": 3 * 40.84 / 5, # 1 / cs**2 "use_squared_omega": True, "limits": {"xlims": (0, 550), "ylims": (0, 550)}, diff --git a/tests/regression_tests/test_multi_gravito_MHD.py b/tests/regression_tests/test_multi_gravito_MHD.py index d5f3d440..01888af7 100644 --- a/tests/regression_tests/test_multi_gravito_MHD.py +++ b/tests/regression_tests/test_multi_gravito_MHD.py @@ -22,7 +22,7 @@ "show_results": False, "logging_level": 0, }, - "xdata": 2 * _kvals ** 2, + "xdata": 2 * _kvals**2, "y_scaling": 1, "use_squared_omega": True, "limits": {"xlims": (0, 550), "ylims": (0, 550)}, diff --git a/tests/regression_tests/test_multi_interchange.py b/tests/regression_tests/test_multi_interchange.py index b4505f54..c8892c39 100644 --- a/tests/regression_tests/test_multi_interchange.py +++ b/tests/regression_tests/test_multi_interchange.py @@ -24,7 +24,7 @@ "logging_level": 0, }, "xdata": np.linspace(0, np.pi, NB_RUNS) / np.pi, - "y_scaling": 1 / ca_avg ** 2, + "y_scaling": 1 / ca_avg**2, "use_squared_omega": True, "limits": {"xlims": (-0.01, 1.01), "ylims": (-4.1, 14.4)}, } diff --git a/tests/regression_tests/test_multi_iso_atmo.py b/tests/regression_tests/test_multi_iso_atmo.py index 67ad5a03..a2fc9dca 100644 --- a/tests/regression_tests/test_multi_iso_atmo.py +++ b/tests/regression_tests/test_multi_iso_atmo.py @@ -8,12 +8,12 @@ temp_unit = 1e6 bfield_unit = 10.0 length_unit = 5e9 -pres_unit = bfield_unit ** 2 / (4 * np.pi) +pres_unit = bfield_unit**2 / (4 * np.pi) rho_unit = pres_unit * 1.672621777e-24 / (1.3806488e-16 * temp_unit) vel_unit = bfield_unit / np.sqrt(4 * np.pi * rho_unit) time_unit = length_unit / vel_unit -g = 2.74e4 / (length_unit / time_unit ** 2) +g = 2.74e4 / (length_unit / time_unit**2) cte_T0 = g * SCALE_HEIGHT gamma = 5 / 3