From dedd10c4392d05340688bd76a3a0e3e622e5d880 Mon Sep 17 00:00:00 2001 From: Maximilian Sander <55374514+maximilian-tech@users.noreply.github.com> Date: Tue, 31 Oct 2023 23:51:57 +0100 Subject: [PATCH] Fix wrong string compare and deprecated numpy array value extraction (Since nimpy 1.25) --- examples/mpi4py/example3/example3.py | 6 +++--- examples/mpi4py/example3/final/example3.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/mpi4py/example3/example3.py b/examples/mpi4py/example3/example3.py index 5dbb8d2..69c9df1 100644 --- a/examples/mpi4py/example3/example3.py +++ b/examples/mpi4py/example3/example3.py @@ -40,12 +40,12 @@ def generate_initial_state(method='random', file_name=None, num_particles=None, """ - if method is 'random': + if method == 'random': np.random.seed(seed=1) coordinates = (0.5 - np.random.rand(num_particles, 3)) * box_length - elif method is 'file': + elif method == 'file': coordinates = np.loadtxt(file_name, skiprows=2, usecols=(1,2,3)) @@ -320,7 +320,7 @@ def main(): total_energy = (total_pair_energy + tail_correction) / num_particles - energy_array[i_step] = total_energy + energy_array[i_step] = total_energy.item() if np.mod(i_step + 1, freq) == 0: if my_rank == 0: diff --git a/examples/mpi4py/example3/final/example3.py b/examples/mpi4py/example3/final/example3.py index 53c5b86..206f190 100644 --- a/examples/mpi4py/example3/final/example3.py +++ b/examples/mpi4py/example3/final/example3.py @@ -40,12 +40,12 @@ def generate_initial_state(method='random', file_name=None, num_particles=None, """ - if method is 'random': + if method == 'random': np.random.seed(seed=1) coordinates = (0.5 - np.random.rand(num_particles, 3)) * box_length - elif method is 'file': + elif method == 'file': coordinates = np.loadtxt(file_name, skiprows=2, usecols=(1,2,3)) @@ -342,7 +342,7 @@ def main(): total_energy = (total_pair_energy + tail_correction) / num_particles - energy_array[i_step] = total_energy + energy_array[i_step] = total_energy.item() if np.mod(i_step + 1, freq) == 0: