Skip to content

Commit

Permalink
black formatting v2.21
Browse files Browse the repository at this point in the history
  • Loading branch information
jordidj committed Jan 31, 2022
1 parent 41a26f3 commit 6d8ea3a
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion post_processing/pylbo/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions post_processing/pylbo/utilities/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions post_processing/pylbo/visualisation/continua.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"]
Expand All @@ -71,20 +71,20 @@ 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

# thermal and slow continuum are coupled in a third degree polynomial in omega,
# 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion post_processing/pylbo/visualisation/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion post_processing/pylbo/visualisation/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/pylbo_tests/test_visualisations_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/test_multi_gravito_HD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/test_multi_gravito_MHD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/test_multi_interchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
}
4 changes: 2 additions & 2 deletions tests/regression_tests/test_multi_iso_atmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6d8ea3a

Please sign in to comment.