Skip to content

Commit

Permalink
black 21.12b0
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Dec 14, 2021
1 parent 2f11919 commit 719522c
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 37 deletions.
1 change: 1 addition & 0 deletions bench/bench_mpi/bench_point2point.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from mpi4py import MPI
import numpy as np

# from numpy.polynomial import Polynomial

# import matplotlib.pyplot as plt
Expand Down
4 changes: 1 addition & 3 deletions bench/bench_mpi/submit_legi_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
]

if infiniband:
cluster.commands_setting_env.extend(
["module load openmpi/4.0.5-ib"]
)
cluster.commands_setting_env.extend(["module load openmpi/4.0.5-ib"])
resource_conditions = "net='ib' and os='buster'"
name_run = "bench_cpp_mpi_ib"
command = "./bench_ib.out"
Expand Down
5 changes: 4 additions & 1 deletion bench/bench_mpi/submit_legi_simul.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import sys
from pathlib import Path

path_script = Path(__file__).absolute().parent.parent.parent / "doc/examples/milestone/run_simul.py"
path_script = (
Path(__file__).absolute().parent.parent.parent
/ "doc/examples/milestone/run_simul.py"
)

assert path_script.exists()

Expand Down
4 changes: 2 additions & 2 deletions bench/skew_sym/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def solve(Simul, nx, time_scheme, coef_dealiasing):
u = np.sin(x)
u_fft = sim.oper.fft(u)
# Set "oddball mode" to zero
u_fft[sim.oper.nkx-1] = 0.
u_fft[sim.oper.nkx - 1] = 0.0

sim.state.init_statephys_from(u=u)
sim.state.init_statespect_from(u_fft=u_fft)
Expand Down Expand Up @@ -102,7 +102,7 @@ def run(solver, nx, ts, dealias):
else:
from fluidsim.solvers.burgers1d.skew_sym.solver import Simul

solve(Simul, nx, ts, 2. / 3 if dealias else 1.0)
solve(Simul, nx, ts, 2.0 / 3 if dealias else 1.0)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@


import matplotlib.pyplot as plt

plt.show()
2 changes: 1 addition & 1 deletion doc/examples/taylor-green_forcing/run_simul.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main(args):
"sim.output.phys_fields.plot()",
"sim.output.spect_energy_budg.plot_fluxes(tmin=16)",
"sim.output.print_stdout.plot_clock_times()",
sep="\n"
sep="\n",
)

return params, sim
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/phys_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def update_times(self):
def get_min_time(self):
if hasattr(self, "times"):
return self.times.min()
return 0.
return 0.0

def get_field_to_plot(
self,
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/print_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _make_str_info(self):
)

def _evaluate_duration_left(self):
""" Computes the remaining time. """
"""Computes the remaining time."""
t_clock = time()
try:
delta_clock_time = t_clock - self.t_clock_last
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _init_files(self, arrays_1st_time=None):
self.t_last_save = self.sim.time_stepping.t

def _online_save(self):
"""Save the values at one time. """
"""Save the values at one time."""
tsim = self.sim.time_stepping.t
if tsim - self.t_last_save >= self.period_save:
self.t_last_save = tsim
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/spectra3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def has_to_save_kzkh(self, only_rank0=False):
return mpi.comm.bcast(answer, root=0)

def _online_save(self):
"""Save the values at one time. """
"""Save the values at one time."""
tsim = self.sim.time_stepping.t
if self._has_to_online_save():
self.t_last_save = tsim
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/spectra_multidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _init_files(self, arrays_1st_time=None):
self.t_last_save = self.sim.time_stepping.t

def _online_save(self):
"""Save the values at one time. """
"""Save the values at one time."""
tsim = self.sim.time_stepping.t
if tsim - self.t_last_save >= self.period_save:
self.t_last_save = tsim
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/base/output/time_signals_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _init_files(self, arrays_1st_time=None):
self.t_last_save = self.sim.time_stepping.t

def _online_save(self):
"""Save the values at one time. """
"""Save the values at one time."""
tsim = self.sim.time_stepping.t
if tsim - self.t_last_save >= self.period_save:
self.t_last_save = tsim
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/solvers/burgers1d/skew_sym/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ def tendencies_nonlin(self, state_spect=None, old=None):

self.oper.dealiasing(f_fft)
# Set "oddball mode" to zero
f_fft[self.oper.nkx-1] = 0.
f_fft[self.oper.nkx - 1] = 0.0
return tendencies_fft
2 changes: 1 addition & 1 deletion fluidsim/solvers/burgers1d/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def tendencies_nonlin(self, state_spect=None, old=None):
self.oper.fft_as_arg(f_signal, f_fft)
self.oper.dealiasing(f_fft)
# Set "oddball mode" to zero
f_fft[self.oper.nkx-1] = 0.
f_fft[self.oper.nkx - 1] = 0.0
return tendencies_fft


Expand Down
22 changes: 11 additions & 11 deletions fluidsim/solvers/ns2d/strat/find_dissipation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def make_parameters_simulation(gamma, key_viscosity):
""" Make parameters of the first simulation. """
"""Make parameters of the first simulation."""
# Parameters simulation
F = np.sin(pi / 4)
sigma = 1
Expand Down Expand Up @@ -86,7 +86,7 @@ def make_parameters_simulation(gamma, key_viscosity):


def modify_parameters(params):
""" Function modifies default parameters. """
"""Function modifies default parameters."""
# Output parameters
params.output.HAS_TO_SAVE = True
params.output.sub_directory = "find_diss_coef"
Expand All @@ -97,7 +97,7 @@ def modify_parameters(params):


def compute_diff(idx_dealiasing, idy_dealiasing, dissE_kx, dissE_ky):
"""Computes the number of modes between the dissipation peak and the largest modes. """
"""Computes the number of modes between the dissipation peak and the largest modes."""
idx_diss_max = np.argmax(abs(dissE_kx))
idy_diss_max = np.argmax(abs(dissE_ky))

Expand Down Expand Up @@ -178,23 +178,23 @@ def normalization_initialized_field(sim, coef_norm=1e-4):


def _compute_ikdiss(dissE_kx, dissE_ky):
""" Computes index peak dissipation. """
"""Computes index peak dissipation."""
idx_diss_max = np.argmax(abs(dissE_kx))
idy_diss_max = np.argmax(abs(dissE_ky))

return idx_diss_max, idy_diss_max


def _compute_ikmax(kxE, kyE):
""" Computes index largest modes. """
"""Computes index largest modes."""
idx_dealiasing = np.argmin(abs(kxE - sim.oper.kxmax_dealiasing))
idy_dealiasing = np.argmin(abs(kyE - sim.oper.kymax_dealiasing))

return idx_dealiasing, idy_dealiasing


def compute_delta_ik(kxE, kyE, dissE_kx, dissE_ky):
""" Computes the difference between the dissipation peak and target. """
"""Computes the difference between the dissipation peak and target."""
idx_diss_max, idy_diss_max = _compute_ikdiss(dissE_kx, dissE_ky)
idx_dealiasing, idy_dealiasing = _compute_ikmax(kxE, kyE)

Expand All @@ -208,7 +208,7 @@ def compute_delta_ik(kxE, kyE, dissE_kx, dissE_ky):


def compute_energy_spatial(sim):
""" Compute energy without energy in shear modes """
"""Compute energy without energy in shear modes"""
dict_spatial = sim.output.spatial_means.load()
E = dict_spatial["E"] - dict_spatial["E_shear"]
t = dict_spatial["t"]
Expand All @@ -220,7 +220,7 @@ def compute_energy_spatial(sim):


def modify_factor(sim, key_viscosity):
""" Modifies factor for viscosity. """
"""Modifies factor for viscosity."""
params = _deepcopy(sim.params)

params_old = sim.params
Expand All @@ -242,13 +242,13 @@ def modify_factor(sim, key_viscosity):


def write_to_file(path, to_print, mode="a"):
""" Writes to a file."""
"""Writes to a file."""
with open(path, mode) as file:
file.write(to_print)


def make_float_value_for_path(value):
""" Makes float. """
"""Makes float."""
value_not = str(value)
if "." in value_not:
return value_not.split(".")[0] + "_" + value_not.split(".")[1]
Expand All @@ -257,7 +257,7 @@ def make_float_value_for_path(value):


def check_dissipation():
""" Checks dissipation"""
"""Checks dissipation"""
ratio_x = dissE_kx[idx_diss_max] / dissE_kx[idx_dealiasing - 1]
ratio_y = dissE_ky[idy_diss_max] / dissE_ky[idy_dealiasing - 1]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ def plot_kz_omega_cross_section(
fig.tight_layout()

def print_info_frequency_spectra(self):
"""Print information frequency spectra. """
"""Print information frequency spectra."""

print("""*** Info frequency spectra ***""")
print("dt = ", self.params.time_stepping.deltat0)
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/solvers/ns2d/strat/output/phys_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class PhysFields2DStrat(PhysFieldsBase2D):
"""Class physical fields of solver ns2d.strat """
"""Class physical fields of solver ns2d.strat"""

def update_animation(self, frame, **fargs):

Expand Down
2 changes: 1 addition & 1 deletion fluidsim/solvers/ns2d/strat/output/print_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _write_memory_txt(self):
os.fsync(self.file_memory.fileno())

def plot_memory(self):
""" Plot memory used from memory_out.txt """
"""Plot memory used from memory_out.txt"""
with open(self.output.path_run + "/memory_out.txt") as file_memory:
lines = file_memory.readlines()

Expand Down
2 changes: 1 addition & 1 deletion fluidsim/solvers/ns2d/strat/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def tendencies_nonlin(self, state_spect=None, old=None):
return tendencies_fft

def check_energy_conservation(self, rot_fft, b_fft, f_rot_fft, f_b_fft):
""" Check energy conservation for the inviscid case. """
"""Check energy conservation for the inviscid case."""
oper = self.oper
params = self.params

Expand Down
4 changes: 2 additions & 2 deletions fluidsim/solvers/ns2d/strat/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ def init_from_rotbfft(self, rot_fft, b_fft):
self.statephys_from_statespect()

def init_from_apfft(self, ap_fft):
"""Initialize the state from the linear mode ap_fft. """
"""Initialize the state from the linear mode ap_fft."""
rot_fft, b_fft = self.compute_rotbfft_from_apfft(ap_fft)
self.init_from_rotbfft(rot_fft, b_fft)

def init_from_amfft(self, am_fft):
"""Initialize the state from the linear mode am_fft. """
"""Initialize the state from the linear mode am_fft."""
rot_fft, b_fft = self.compute_rotbfft_from_amfft(am_fft)
self.init_from_rotbfft(rot_fft, b_fft)

Expand Down
2 changes: 1 addition & 1 deletion fluidsim/solvers/plate2d/output/correlations_freq.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _init_files2(self, correlations):
self.t_last_save = self.sim.time_stepping.t

def _online_save(self):
"""Save the values at one time. """
"""Save the values at one time."""
itsim = self.sim.time_stepping.t / self.sim.time_stepping.deltat
periods_save = self.sim.params.output.periods_save.correl_freq

Expand Down
2 changes: 1 addition & 1 deletion fluidsim/util/console/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def plot_pie(
for_latex=False,
**kwargs,
):
"""Plot a pie chart """
"""Plot a pie chart"""
percentages = []
labels = []
for k, v in long_functions.items():
Expand Down
2 changes: 1 addition & 1 deletion fluidsim/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def write_result(self, *strs):


def _mname(obj):
""" Get the full dotted name of the test method """
"""Get the full dotted name of the test method"""

mod_name = obj.__class__.__module__.replace("fluidsim.", "")
return f"{mod_name}.{obj.__class__.__name__}.{obj._testMethodName}"
Expand Down
2 changes: 1 addition & 1 deletion lib/fluidsim_core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def import_cls_simul(key, entrypoint_grp):
"""

if key.startswith(entrypoint_grp + "."):
key = key[len(entrypoint_grp) + 1:]
key = key[len(entrypoint_grp) + 1 :]

solver = import_module_solver(key, entrypoint_grp)
return solver.Simul
2 changes: 1 addition & 1 deletion scripts/ns2d.strat/coeff_diss.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def compute_delta_ik(kxE, kyE, dissE_kx, dissE_ky):


def compute_energy_spatial(sim):
""" Compute energy without energy in shear modes """
"""Compute energy without energy in shear modes"""
dict_spatial = sim.output.spatial_means.load()
E = dict_spatial["E"] - dict_spatial["E_shear"]
t = dict_spatial["t"]
Expand Down

0 comments on commit 719522c

Please sign in to comment.