From 4cbe73a916d6c1034d4f75bfa5d713452a529692 Mon Sep 17 00:00:00 2001 From: Ben Dudson Date: Sun, 28 Jan 2024 17:44:34 -0800 Subject: [PATCH] Apply black 24.1.1 Same version as now used in Github CI. --- hypnotoad/cases/circular.py | 15 ++-- hypnotoad/core/equilibrium.py | 20 ++---- hypnotoad/core/mesh.py | 130 +++++++++++++++++----------------- hypnotoad/gui/gui.py | 6 +- hypnotoad/utils/critical.py | 1 - 5 files changed, 76 insertions(+), 96 deletions(-) diff --git a/hypnotoad/cases/circular.py b/hypnotoad/cases/circular.py index ca7e05fc..29c8e24f 100644 --- a/hypnotoad/cases/circular.py +++ b/hypnotoad/cases/circular.py @@ -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) @@ -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 @@ -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) ) ) ) @@ -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) ) ) ) diff --git a/hypnotoad/core/equilibrium.py b/hypnotoad/core/equilibrium.py index 78731d2a..d4b75f04 100644 --- a/hypnotoad/core/equilibrium.py +++ b/hypnotoad/core/equilibrium.py @@ -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 @@ -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 @@ -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 diff --git a/hypnotoad/core/mesh.py b/hypnotoad/core/mesh.py index ccf16d61..8f1c1c38 100644 --- a/hypnotoad/core/mesh.py +++ b/hypnotoad/core/mesh.py @@ -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: @@ -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 @@ -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, : @@ -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 @@ -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 = {} @@ -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: @@ -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" diff --git a/hypnotoad/gui/gui.py b/hypnotoad/gui/gui.py index b737396e..dca0646a 100644 --- a/hypnotoad/gui/gui.py +++ b/hypnotoad/gui/gui.py @@ -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() diff --git a/hypnotoad/utils/critical.py b/hypnotoad/utils/critical.py index 4885e6e6..a2e0a1c9 100644 --- a/hypnotoad/utils/critical.py +++ b/hypnotoad/utils/critical.py @@ -20,7 +20,6 @@ """ - from scipy import interpolate from numpy.linalg import inv from numpy import (