diff --git a/hysop/core/graph/computational_node_frontend.py b/hysop/core/graph/computational_node_frontend.py index 5ba94835576d20bbc1f330bc6befd05377210a3e..2066a2247eb1d1f218076cfdfa6039125922dbee 100644 --- a/hysop/core/graph/computational_node_frontend.py +++ b/hysop/core/graph/computational_node_frontend.py @@ -157,13 +157,13 @@ class ComputationalGraphNodeFrontend(ComputationalGraphNodeGenerator): try: op = self.impl(**self.impl_kwds) except: - sargs = [f"*{k} = {v.__class__}" for (k, v) in self.impl_kwds.items()] - msg = "FATAL ERROR during {}.generate():\n" - msg += " => failed to initialize an instance of type {}" - msg += "\n by using the following keyword arguments:" - msg += "\n " + "\n ".join(sargs) - msg = msg.format(self.__class__, self.impl) - print(f"\n{msg}") + sargs = [f'*{k} = {repr(v)}' + for (k, v) in self.impl_kwds.items()] + msg = f'FATAL ERROR during {self.__class__}.generate():\n' + msg += f' => failed to initialize an instance of type {self.impl}' + msg += '\n by using the following keyword arguments:' + msg += '\n '+'\n '.join(sargs) + print(f'\n{msg}') raise for kwds in self._input_fields_to_dump: diff --git a/hysop/numerics/stencil/stencil_generator.py b/hysop/numerics/stencil/stencil_generator.py index 92e475655026b7b0756838b30c9d391d6adb15b3..caa47f0d80d1d9f39c0fd3ef6ad18a267c07188e 100644 --- a/hysop/numerics/stencil/stencil_generator.py +++ b/hysop/numerics/stencil/stencil_generator.py @@ -666,15 +666,13 @@ if __name__ == "__main__": print(f" origin: {i} => {stencil.factor} . {stencil.coeffs}") sg.configure(dim=1, derivative=1, order=2, dtype=np.float64) - print( - "\ndim=1, 1st order first derivative, np.float64, approximative, shape=(5,):" - ) + print('\ndim=1, 1st order first derivative, np.float64, approximative, shape=(5,):') for i in range(sg.get_config().shape()[0]): stencil = sg.generate_approximative_stencil(origin=i).reshape((5,)) print(f" origin: {i} => {stencil.factor} . {stencil.coeffs}") sg.configure(dim=1, derivative=2, order=2, dtype=np.float64) - print("\ndim=1, 2nd order first derivative, np.float64, approximative:") + print('\ndim=1, 2nd order first derivative, np.float64, approximative:') for i in range(sg.get_config().shape()[0]): stencil = sg.generate_approximative_stencil(origin=i) print(f" origin: {i} => {stencil.factor} . {stencil.coeffs}") @@ -710,13 +708,13 @@ if __name__ == "__main__": sg.configure(derivative=2) print("\nCentered second order derivative stencils:") for i in range(1, 4): - stencil = sg.generate_approximative_stencil(order=2 * i, dtype=np.float16) - print(f" {stencil.coeffs}") + stencil = sg.generate_approximative_stencil(order=2*i, dtype=np.float16) + print(f' {stencil.coeffs}') print() for i in range(1, 4): stencil = sg.generate_approximative_stencil(order=2 * i, dtype=MPQ) print(f" {stencil.coeffs}") print() for i in range(1, 4): - stencil = sg.generate_exact_stencil(order=2 * i) - print(f" {stencil.coeffs}") + stencil = sg.generate_exact_stencil(order=2*i) + print(f' {stencil.coeffs}') diff --git a/hysop/simulation.py b/hysop/simulation.py index 38d889038df13f86f705043719e5eb3d4095552c..ced67e6dd00f6aceaa0e9e78567d01fcafddf85a 100644 --- a/hysop/simulation.py +++ b/hysop/simulation.py @@ -176,8 +176,8 @@ class Simulation: else: raise ValueError("You must set nb_iter or dt0 value.") - msg = f"dt0={dt0}, start={start}, end={end}" - assert (dt0 > 0.0) and (dt0 <= (end - start)), msg + msg = f'dt0={dt0}, start={start}, end={end}' + assert (dt0 > 0.0) and -1e-6 < ((end-start)-dt0)/dt0, msg self._dt0 = dt0 dt_name = f"{name}_dt" if (name is not None) else "dt"