Skip to content

Commit

Permalink
Apply black 24.1.1
Browse files Browse the repository at this point in the history
Same version as now used in Github CI.
  • Loading branch information
bendudson committed Jan 29, 2024
1 parent e4fb835 commit 4cbe73a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 96 deletions.
15 changes: 4 additions & 11 deletions hypnotoad/cases/circular.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def d2psidr2_r(self, r):
def func(x):
return (
B0 / (np.sqrt(1.0 - x**2 / R0**2) * self.q(x))
+ B0
* x**2
/ (R0**2 * (1.0 - x**2 / R0**2) ** 1.5 * self.q(x))
+ B0 * x**2 / (R0**2 * (1.0 - x**2 / R0**2) ** 1.5 * self.q(x))
- B0
* x
* self.dqdr(x)
Expand Down Expand Up @@ -326,10 +324,7 @@ def psi_r(self, r):

def func(x):
return (
B0
* R0**2
/ coef_array[0]
* (1.0 - np.sqrt(1.0 - x**2 / R0**2))
B0 * R0**2 / coef_array[0] * (1.0 - np.sqrt(1.0 - x**2 / R0**2))
)

self._psi_r = func
Expand All @@ -346,8 +341,7 @@ def func(x):
* (
-1.0
+ np.sqrt(
(a1 * (-(x**2) + R0**2))
/ (a0 + a1 * R0**2)
(a1 * (-(x**2) + R0**2)) / (a0 + a1 * R0**2)
)
)
)
Expand All @@ -356,8 +350,7 @@ def func(x):
* (
1.0
+ np.sqrt(
(a1 * (-(x**2) + R0**2))
/ (a0 + a1 * R0**2)
(a1 * (-(x**2) + R0**2)) / (a0 + a1 * R0**2)
)
)
)
Expand Down
20 changes: 4 additions & 16 deletions hypnotoad/core/equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -4792,10 +4792,7 @@ def psi(i):
* numpy.pi
* CosInt_m_j1
* numpy.sin(b * numpy.pi / n)
+ b**2
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_b_n
+ b**2 * numpy.pi * numpy.cos(b * numpy.pi / n) * SinInt_b_n
- b
* j1(i)
* numpy.pi
Expand All @@ -4812,14 +4809,8 @@ def psi(i):
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_b_n
+ n**2
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_b_n
- b**2
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_j1
+ n**2 * numpy.pi * numpy.cos(b * numpy.pi / n) * SinInt_b_n
- b**2 * numpy.pi * numpy.cos(b * numpy.pi / n) * SinInt_j1
+ b
* j1(i)
* numpy.pi
Expand All @@ -4836,10 +4827,7 @@ def psi(i):
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_j1
- n**2
* numpy.pi
* numpy.cos(b * numpy.pi / n)
* SinInt_j1
- n**2 * numpy.pi * numpy.cos(b * numpy.pi / n) * SinInt_j1
)
+ grad_upper / 2 * j2(i) * (b + n) / (b + j2(i))
- grad_upper
Expand Down
130 changes: 65 additions & 65 deletions hypnotoad/core/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,11 @@ def correct_sfunc_orthogonal_and_set_startInd(
# along the contour where the grid would be orthogonal need to
# correct sfunc_orthogonal for the distance between the point at
# the lower wall and the original start-point
self.sfunc_orthogonal_list[
i
] = correct_sfunc_orthogonal_and_set_startInd(
contour,
self.sfunc_orthogonal_list[i],
self.sfunc_orthogonal_list[i] = (
correct_sfunc_orthogonal_and_set_startInd(
contour,
self.sfunc_orthogonal_list[i],
)
)

if upper_wall:
Expand Down Expand Up @@ -1699,18 +1699,18 @@ def calcPoloidalDistance(self):
next_region.poloidal_distance = MultiLocationArray(
next_region.nx, next_region.ny
)
next_region.poloidal_distance.centre[
:, :
] = region.poloidal_distance.ylow[:, -1, numpy.newaxis]
next_region.poloidal_distance.ylow[
:, :
] = region.poloidal_distance.ylow[:, -1, numpy.newaxis]
next_region.poloidal_distance.xlow[
:, :
] = region.poloidal_distance.corners[:, -1, numpy.newaxis]
next_region.poloidal_distance.corners[
:, :
] = region.poloidal_distance.corners[:, -1, numpy.newaxis]
next_region.poloidal_distance.centre[:, :] = (
region.poloidal_distance.ylow[:, -1, numpy.newaxis]
)
next_region.poloidal_distance.ylow[:, :] = (
region.poloidal_distance.ylow[:, -1, numpy.newaxis]
)
next_region.poloidal_distance.xlow[:, :] = (
region.poloidal_distance.corners[:, -1, numpy.newaxis]
)
next_region.poloidal_distance.corners[:, :] = (
region.poloidal_distance.corners[:, -1, numpy.newaxis]
)
region = next_region

# Save total poloidal distance in core
Expand Down Expand Up @@ -2895,12 +2895,12 @@ def smoothnl(self, varname):
marky[region_name].centre[1:-1, 1:-1] = this_marky

if region.connections["inner"] is not None:
markx[region.connections["inner"]].centre[
-1, 1:-1
] = this_markx[0, :]
marky[region.connections["inner"]].centre[
-1, 1:-1
] = this_marky[0, :]
markx[region.connections["inner"]].centre[-1, 1:-1] = (
this_markx[0, :]
)
marky[region.connections["inner"]].centre[-1, 1:-1] = (
this_marky[0, :]
)
if region.connections["outer"] is not None:
markx[region.connections["outer"]].centre[0, 1:-1] = this_markx[
-1, :
Expand All @@ -2909,12 +2909,12 @@ def smoothnl(self, varname):
-1, :
]
if region.connections["lower"] is not None:
markx[region.connections["lower"]].centre[
1:-1, -1
] = this_markx[:, 0]
marky[region.connections["lower"]].centre[
1:-1, -1
] = this_marky[:, 0]
markx[region.connections["lower"]].centre[1:-1, -1] = (
this_markx[:, 0]
)
marky[region.connections["lower"]].centre[1:-1, -1] = (
this_marky[:, 0]
)
if region.connections["upper"] is not None:
markx[region.connections["upper"]].centre[1:-1, 0] = this_markx[
:, -1
Expand Down Expand Up @@ -3022,33 +3022,33 @@ def smoothnl(self, varname):
marky[region_name].corners[1:-1, 1:-1] = this_marky

if region.connections["inner"] is not None:
markx[region.connections["inner"]].corners[
-1, 1:-1
] = this_markx[0, :]
marky[region.connections["inner"]].corners[
-1, 1:-1
] = this_marky[0, :]
markx[region.connections["inner"]].corners[-1, 1:-1] = (
this_markx[0, :]
)
marky[region.connections["inner"]].corners[-1, 1:-1] = (
this_marky[0, :]
)
if region.connections["outer"] is not None:
markx[region.connections["outer"]].corners[
0, 1:-1
] = this_markx[-1, :]
marky[region.connections["outer"]].corners[
0, 1:-1
] = this_marky[-1, :]
markx[region.connections["outer"]].corners[0, 1:-1] = (
this_markx[-1, :]
)
marky[region.connections["outer"]].corners[0, 1:-1] = (
this_marky[-1, :]
)
if region.connections["lower"] is not None:
markx[region.connections["lower"]].corners[
1:-1, -1
] = this_markx[:, 0]
marky[region.connections["lower"]].corners[
1:-1, -1
] = this_marky[:, 0]
markx[region.connections["lower"]].corners[1:-1, -1] = (
this_markx[:, 0]
)
marky[region.connections["lower"]].corners[1:-1, -1] = (
this_marky[:, 0]
)
if region.connections["upper"] is not None:
markx[region.connections["upper"]].corners[
1:-1, 0
] = this_markx[:, -1]
marky[region.connections["upper"]].corners[
1:-1, 0
] = this_marky[:, -1]
markx[region.connections["upper"]].corners[1:-1, 0] = (
this_markx[:, -1]
)
marky[region.connections["upper"]].corners[1:-1, 0] = (
this_marky[:, -1]
)

changes = []
tmp = {}
Expand Down Expand Up @@ -3522,9 +3522,9 @@ def __init__(self, equilibrium, settings):
self.region_indices = {}
for reg_name in self.equilibrium.regions:
for i in range(len(x_regions)):
self.region_indices[
self.region_lookup[(reg_name, i)]
] = numpy.index_exp[x_regions[i], y_regions[reg_name]]
self.region_indices[self.region_lookup[(reg_name, i)]] = (
numpy.index_exp[x_regions[i], y_regions[reg_name]]
)

# constant spacing in y for now
if self.ny_core > 0:
Expand Down Expand Up @@ -3563,15 +3563,15 @@ def addFromRegions(name, *, all_corners=False):
]
if all_corners:
if f_region._corners_array is not None:
f.lower_right_corners[
self.region_indices[region.myID]
] = f_region.corners[1:, :-1]
f.upper_right_corners[
self.region_indices[region.myID]
] = f_region.corners[1:, 1:]
f.upper_left_corners[
self.region_indices[region.myID]
] = f_region.corners[:-1, 1:]
f.lower_right_corners[self.region_indices[region.myID]] = (
f_region.corners[1:, :-1]
)
f.upper_right_corners[self.region_indices[region.myID]] = (
f_region.corners[1:, 1:]
)
f.upper_left_corners[self.region_indices[region.myID]] = (
f_region.corners[:-1, 1:]
)

# Set 'bout_type' so it gets saved in the grid file
f.attributes["bout_type"] = "Field2D"
Expand Down
6 changes: 3 additions & 3 deletions hypnotoad/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,9 @@ def accept(self):
self.parent.gui_options["plot_xlow"] = self.plotXlowCheckBox.isChecked()
self.parent.gui_options["plot_ylow"] = self.plotYlowCheckBox.isChecked()
self.parent.gui_options["plot_corners"] = self.plotCornersCheckBox.isChecked()
self.parent.gui_options[
"save_full_yaml"
] = self.saveFullYamlCheckBox.isChecked()
self.parent.gui_options["save_full_yaml"] = (
self.saveFullYamlCheckBox.isChecked()
)

self.parent.updateMenuFromGuiOptions()

Expand Down
1 change: 0 additions & 1 deletion hypnotoad/utils/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""


from scipy import interpolate
from numpy.linalg import inv
from numpy import (
Expand Down

0 comments on commit 4cbe73a

Please sign in to comment.