Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/struphy/console/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def struphy_profile(dirs, replace, all, n_lines, print_callers, savefig):
)
print("-" * 154)
for position, key in enumerate(dicts[0].keys()):
if list_of_funcs == None:
if list_of_funcs is None:
for dict, sim_name, n, dim in zip(dicts, sim_names, nproc, Nel):
string = f"{sim_name}".ljust(20) + f"{n}".ljust(7) + f"{position:2d}".ljust(5) + str(key.ljust(70))
for value in dict[key].values():
Expand Down
6 changes: 3 additions & 3 deletions src/struphy/diagnostics/diagn_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ def power_spectrum_2d(
temp[n, :, :, :] = snapshot[component]

# Extract 2d data (t, eta) for fft
if slice_at[0] == None:
if slice_at[0] is None:
data = temp[:, :, slice_at[1], slice_at[2]]
grid = grids[0]
if grids_mapped is not None:
grid = grids_mapped[0][:, slice_at[1], slice_at[2]]

elif slice_at[1] == None:
elif slice_at[1] is None:
data = temp[:, slice_at[0], :, slice_at[2]]
grid = grids[1]
if grids_mapped is not None:
grid = grids_mapped[1][slice_at[0], :, slice_at[2]]

elif slice_at[2] == None:
elif slice_at[2] is None:
data = temp[:, slice_at[0], slice_at[1], :]
grid = grids[2].flatten()
if grids_mapped is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/struphy/eigenvalue_solvers/legacy/inner_products_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def inner_prod_V0(spline_space, fun, mapping=None):
basisN = spline_space.basisN # evaluated basis functions at quadrature points

# evaluation of mapping at quadrature points
if mapping == None:
if mapping is None:
mat_map = xp.ones(pts.shape, dtype=float)
else:
mat_map = mapping(pts.flatten()).reshape(pts.shape)
Expand Down Expand Up @@ -89,7 +89,7 @@ def inner_prod_V1(spline_space, fun, mapping=None):
basisD = spline_space.basisD # evaluated basis functions at quadrature points

# evaluation of mapping at quadrature points
if mapping == None:
if mapping is None:
mat_map = xp.ones(pts.shape, dtype=float)
else:
mat_map = 1 / mapping(pts.flatten()).reshape(pts.shape)
Expand Down
10 changes: 5 additions & 5 deletions src/struphy/eigenvalue_solvers/legacy/mass_matrices_3d_pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def get_M0_PRE_3(tensor_space_FEM, mats_pol=None):
TODO
"""

if mats_pol == None:
if mats_pol is None:
mat = tensor_space_FEM.B0_pol.dot(tensor_space_FEM.M0_pol_mat.dot(tensor_space_FEM.B0_pol.T))
else:
mat = mats_pol
Expand All @@ -255,7 +255,7 @@ def get_M1_PRE_3(tensor_space_FEM, mats_pol=None):
TODO
"""

if mats_pol == None:
if mats_pol is None:
mat = [
tensor_space_FEM.B1_pol.dot(tensor_space_FEM.M1_pol_mat[0].dot(tensor_space_FEM.B1_pol.T)),
tensor_space_FEM.B0_pol.dot(tensor_space_FEM.M1_pol_mat[1].dot(tensor_space_FEM.B0_pol.T)),
Expand Down Expand Up @@ -295,7 +295,7 @@ def get_M2_PRE_3(tensor_space_FEM, mats_pol=None):
TODO
"""

if mats_pol == None:
if mats_pol is None:
mat = [
tensor_space_FEM.B2_pol.dot(tensor_space_FEM.M2_pol_mat[0].dot(tensor_space_FEM.B2_pol.T)),
tensor_space_FEM.B3_pol.dot(tensor_space_FEM.M2_pol_mat[1].dot(tensor_space_FEM.B3_pol.T)),
Expand Down Expand Up @@ -335,7 +335,7 @@ def get_M3_PRE_3(tensor_space_FEM, mats_pol=None):
TODO
"""

if mats_pol == None:
if mats_pol is None:
mat = tensor_space_FEM.B3_pol.dot(tensor_space_FEM.M3_pol_mat.dot(tensor_space_FEM.B3_pol.T))
else:
mat = mats_pol
Expand All @@ -360,7 +360,7 @@ def get_Mv_PRE_3(tensor_space_FEM, mats_pol=None):
TODO
"""

if mats_pol == None:
if mats_pol is None:
mat = [
tensor_space_FEM.Bv_pol.dot(tensor_space_FEM.Mv_pol_mat[0].dot(tensor_space_FEM.Bv_pol.T)),
tensor_space_FEM.Mv_pol_mat[1],
Expand Down
6 changes: 3 additions & 3 deletions src/struphy/eigenvalue_solvers/mass_matrices_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_M(spline_space, phi_i=0, phi_j=0, fun=None):
basisD = spline_space.basisD # evaluated basis functions at quadrature points

# evaluation of weight function at quadrature points (optional)
if fun == None:
if fun is None:
mat_fun = xp.ones(pts.shape, dtype=float)
else:
mat_fun = fun(pts.flatten()).reshape(Nel, n_quad)
Expand Down Expand Up @@ -136,13 +136,13 @@ def get_M_gen(spline_space, phi_i=0, phi_j=0, fun=None, jac=None):
basis_t = bsp.basis_ders_on_quad_grid(spline_space.t, p - 1, spline_space.pts, 0, normalize=False)

# evaluation of weight function at quadrature points (optional)
if fun == None:
if fun is None:
mat_fun = xp.ones(pts.shape, dtype=float)
else:
mat_fun = fun(pts.flatten()).reshape(Nel, n_quad)

# evaluation of jacobian at quadrature points
if jac == None:
if jac is None:
mat_jac = xp.ones(pts.shape, dtype=float)
else:
mat_jac = jac(pts.flatten()).reshape(Nel, n_quad)
Expand Down
10 changes: 5 additions & 5 deletions src/struphy/eigenvalue_solvers/mass_matrices_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_M0(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
det_df = det_df.reshape(Nel[0], n_quad[0], Nel[1], n_quad[1])

# evaluation of weight function at quadrature points
if weight == None:
if weight is None:
mat_w = xp.ones(det_df.shape, dtype=float)
else:
mat_w = weight(pts[0].flatten(), pts[1].flatten(), 0.0)
Expand Down Expand Up @@ -159,7 +159,7 @@ def get_M1(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], 2 * p[0] + 1, 2 * p[1] + 1), dtype=float)

# evaluate inverse metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g_inv[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), 0.0)
Expand Down Expand Up @@ -275,7 +275,7 @@ def get_M2(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], 2 * p[0] + 1, 2 * p[1] + 1), dtype=float)

# evaluate metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), 0.0)
Expand Down Expand Up @@ -368,7 +368,7 @@ def get_M3(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
det_df = det_df.reshape(Nel[0], n_quad[0], Nel[1], n_quad[1])

# evaluation of weight function at quadrature points
if weight == None:
if weight is None:
mat_w = xp.ones(det_df.shape, dtype=float)
else:
mat_w = weight(pts[0].flatten(), pts[1].flatten(), 0.0)
Expand Down Expand Up @@ -478,7 +478,7 @@ def get_Mv(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], 2 * p[0] + 1, 2 * p[1] + 1), dtype=float)

# evaluate metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), 0.0)
Expand Down
10 changes: 5 additions & 5 deletions src/struphy/eigenvalue_solvers/mass_matrices_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_M0(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
det_df = det_df.reshape(Nel[0], n_quad[0], Nel[1], n_quad[1], Nel[2], n_quad[2])

# evaluation of weight function at quadrature points
if weight == None:
if weight is None:
mat_w = xp.ones(det_df.shape, dtype=float)
else:
mat_w = weight(pts[0].flatten(), pts[1].flatten(), pts[2].flatten())
Expand Down Expand Up @@ -164,7 +164,7 @@ def get_M1(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], Ni[2], 2 * p[0] + 1, 2 * p[1] + 1, 2 * p[2] + 1), dtype=float)

# evaluate metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g_inv[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), pts[2].flatten())
Expand Down Expand Up @@ -284,7 +284,7 @@ def get_M2(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], Ni[2], 2 * p[0] + 1, 2 * p[1] + 1, 2 * p[2] + 1), dtype=float)

# evaluate metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), pts[2].flatten())
Expand Down Expand Up @@ -382,7 +382,7 @@ def get_M3(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
det_df = det_df.reshape(Nel[0], n_quad[0], Nel[1], n_quad[1], Nel[2], n_quad[2])

# evaluation of weight function at quadrature points
if weight == None:
if weight is None:
mat_w = xp.ones(det_df.shape, dtype=float)
else:
mat_w = weight(pts[0].flatten(), pts[1].flatten(), pts[2].flatten())
Expand Down Expand Up @@ -520,7 +520,7 @@ def get_Mv(tensor_space_FEM, domain, apply_boundary_ops=False, weight=None):
M[a][b] = xp.zeros((Ni[0], Ni[1], Ni[2], 2 * p[0] + 1, 2 * p[1] + 1, 2 * p[2] + 1), dtype=float)

# evaluate metric tensor at quadrature points
if weight == None:
if weight is None:
mat_w = g[a, b]
else:
mat_w = weight[a][b](pts[0].flatten(), pts[1].flatten(), pts[2].flatten())
Expand Down
8 changes: 4 additions & 4 deletions src/struphy/feec/projectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ def get_rowstarts(self, i, h=None):
Array that tell us for which rows the basis function in the i-th direction produces non-zero entries in the BasisProjectionOperatorLocal matrix.
This array contains the start indices of said regions.
"""
if h == None:
if h is None:
rows_splines = getattr(self, f"_rows_B_or_D_splines_{i}")
translation_indices = getattr(self, f"_translation_indices_B_or_D_splines_{i}")
return rows_splines[self._B_or_D[i]][translation_indices[self._B_or_D[i]][self._basis_indices[i]]]
Expand Down Expand Up @@ -1745,7 +1745,7 @@ def get_rowends(self, i, h=None):
Array that tell us for which rows the basis function in the i-th direction produces non-zero entries in the BasisProjectionOperatorLocal matrix.
This array contains the end indices of said regions.
"""
if h == None:
if h is None:
rowe_splines = getattr(self, f"_rowe_B_or_D_splines_{i}")
translation_indices = getattr(self, f"_translation_indices_B_or_D_splines_{i}")
return rowe_splines[self._B_or_D[i]][translation_indices[self._B_or_D[i]][self._basis_indices[i]]]
Expand All @@ -1772,7 +1772,7 @@ def get_values(self, i, h=None):
self._values_B_or_D_splines_i[self._B_or_D[i]][self._translation_indices_B_or_D_splines_i[self._B_or_D[i]][self._basis_indices[i]]] : 1d float array
Array with the evaluated basis function for the i-th direction.
"""
if h == None:
if h is None:
values_splines = getattr(self, f"_values_B_or_D_splines_{i}")
translation_indices = getattr(self, f"_translation_indices_B_or_D_splines_{i}")
return values_splines[self._B_or_D[i]][translation_indices[self._B_or_D[i]][self._basis_indices[i]]]
Expand Down Expand Up @@ -1800,7 +1800,7 @@ def get_are_zero(self, i, h=None):
Array of zeros or ones. A one at index j means that for the set of quadrature points found in self._localpts[i][j] the basis function is not zero
for at least one of them.
"""
if h == None:
if h is None:
are_zero_splines = getattr(self, f"_are_zero_B_or_D_splines_{i}")
translation_indices = getattr(self, f"_translation_indices_B_or_D_splines_{i}")
return are_zero_splines[self._B_or_D[i]][translation_indices[self._B_or_D[i]][self._basis_indices[i]]]
Expand Down
6 changes: 3 additions & 3 deletions src/struphy/feec/psydac_derham.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ def _get_neighbour_one_component(self, comp):
neigh_inds = xp.array(neigh_inds)

# only use indices where information is present to find the neighbours rank
inds = xp.where(neigh_inds != None)
inds = xp.where(xp.not_equal(neigh_inds, None))

# find ranks (row index of domain_array) which agree in start/end indices
index_temp = xp.squeeze(self.index_array[:, inds])
Expand Down Expand Up @@ -2252,7 +2252,7 @@ def _add_noise(
sli = []
gl_s = []
for d in range(3):
if n == None:
if n is None:
sli += [slice(self._gl_s[d], self._gl_e[d] + 1)]
gl_s += [self._gl_s[d]]
vec = self._vector
Expand All @@ -2262,7 +2262,7 @@ def _add_noise(
vec = self._vector[n]

# local shape without ghost regions
if n == None:
if n is None:
_shape = (
self._gl_e[0] + 1 - self._gl_s[0],
self._gl_e[1] + 1 - self._gl_s[1],
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/feec/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def compare_arrays(arr_psy, arr, rank, atol=1e-14, verbose=False):
elif isinstance(arr_psy, BlockLinearOperator):
for row_psy, row in zip(arr_psy.blocks, arr):
for mat_psy, mat in zip(row_psy, row):
if mat_psy == None:
if mat_psy is None:
continue

s = mat_psy.codomain.starts
Expand Down
4 changes: 2 additions & 2 deletions src/struphy/feec/variational_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def __init__(self, derham, transposed=False, weights=None):
# Get the projector and the spaces
self._derham = derham
self._transposed = transposed
if weights == None:
if weights is None:
weights = [[None] * 3] * 3
self._weights = weights
if self._transposed:
Expand Down Expand Up @@ -477,7 +477,7 @@ def __init__(self, derham, transposed=False, weights=None):
# Get the projector and the spaces
self._derham = derham
self._transposed = transposed
if weights == None:
if weights is None:
weights = [[None] * 3] * 3
self._weights = weights
if self._transposed:
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/linear_algebra/saddle_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
max_iter: int = 1000,
**solver_params,
):
assert type(A) == type(B)
assert type(A) is type(B)
if isinstance(A, list):
self._variant = "Uzawa"
for i in A:
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run(
save_step = env.save_step
sort_step = env.sort_step
num_clones = env.num_clones
use_mpi = (not comm is None,)
use_mpi = (comm is not None,)

meta = {}
meta["platform"] = sysconfig.get_platform()
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/pic/tests/test_pic_legacy_files/pusher_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def pusher_step4(

# ========================================================================================================
def reflect(
df: "",
df,
):
from numpy import empty, sqrt

Expand Down
4 changes: 2 additions & 2 deletions src/struphy/post_processing/cprofile_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def compare_cprofile_data(path, list_of_funcs=None):
with open(os.path.join(path, "profile_dict.sav"), "rb") as f:
data_cprofile = pickle.load(f)

if list_of_funcs == None:
if list_of_funcs is None:
print("-" * 76)
print("function name".ljust(60), "cumulative time")
print("-" * 76)
Expand All @@ -96,7 +96,7 @@ def compare_cprofile_data(path, list_of_funcs=None):
counter = 0
for k, v in data_cprofile.items():
counter += 1
if list_of_funcs == None:
if list_of_funcs is None:
print(k.ljust(60), v["cumtime"])
if counter > 49:
break
Expand Down
4 changes: 2 additions & 2 deletions src/struphy/post_processing/likwid/roofline_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ def add_plot_flop(
theoretical_max_gflops=3072.0,
xmax=1e3,
):
if label == None:
if label is None:
legend_label = f"{round(gflops)} GFLOP/s, {round(gflops / theoretical_max_gflops * 100, 2)} % of theoretical"
else:
legend_label = (
f"{label}({round(gflops)} GFLOP/s, {round(gflops / theoretical_max_gflops * 100, 2)} % of theoretical)"
)

if color == None:
if color is None:
# line, = mfig.axs.loglog([xmin,xmax],[gflops,gflops],linestyle=linestyle)#,label = legend_label)
line = mfig.axs.axhline(y=gflops, linestyle=linestyle)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/post_processing/profile_struphy.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main():
)
print("-" * 154)
for position, key in enumerate(dicts[0].keys()):
if list_of_funcs == None:
if list_of_funcs is None:
for dict, sim_name, n, dim in zip(dicts, sim_names, nproc, Nel):
string = f"{sim_name}".ljust(20) + f"{n}".ljust(7) + f"{position:2d}".ljust(5) + str(key.ljust(70))
for value in dict[key].values():
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/propagators/propagators_coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def allocate(self):
# ================================

# Preconditioner
if self.options.precond == None:
if self.options.precond is None:
pc = None
else:
pc_class = getattr(preconditioner, self.options.precond)
Expand Down
Loading