diff options
author | 2019-09-04 10:31:21 -0700 | |
---|---|---|
committer | 2019-09-04 10:31:21 -0700 | |
commit | e91a0ff8ea5ed124a4ee5f392935e75bb2e1374f (patch) | |
tree | ae4b267e367779d5c76f272ba5820e126532d49d /Python | |
parent | fe4572de4a697a8342deacab28f4ad326d723ea4 (diff) | |
download | WarpX-e91a0ff8ea5ed124a4ee5f392935e75bb2e1374f.tar.gz WarpX-e91a0ff8ea5ed124a4ee5f392935e75bb2e1374f.tar.zst WarpX-e91a0ff8ea5ed124a4ee5f392935e75bb2e1374f.zip |
Protect against bug in some versions of numpy
Diffstat (limited to 'Python')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index 2a37dbd5e..5df9aa0f9 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -392,7 +392,11 @@ def get_particle_arrays(species_number, comp): particle_data = [] for i in range(num_tiles.value): arr = np.ctypeslib.as_array(data[i], (particles_per_tile[i],)) - arr.setflags(write=1) + try: + # This fails on some versions of numpy + arr.setflags(write=1) + except ValueError: + pass particle_data.append(arr) _libc.free(particles_per_tile) @@ -623,7 +627,11 @@ def _get_mesh_field_list(warpx_func, level, direction, include_ghosts): shape = tuple([shapes[shapesize*i + d] for d in range(shapesize)]) # --- The data is stored in Fortran order, hence shape is reversed and a transpose is taken. arr = np.ctypeslib.as_array(data[i], shape[::-1]).T - arr.setflags(write=1) + try: + # This fails on some versions of numpy + arr.setflags(write=1) + except ValueError: + pass if include_ghosts: grid_data.append(arr) else: |