Skip to content

Commit

Permalink
NUMPY: remove deprecated type aliases [MPY-301]
Browse files Browse the repository at this point in the history
  • Loading branch information
iainrussell committed Mar 4, 2021
1 parent 16be632 commit f1b1d49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions metview/bindings.py
Expand Up @@ -378,11 +378,11 @@ def push_vector(npa):
elif dtype == np.float32: # can directly pass the data buffer
cffi_buffer = ffi.cast("float*", npa.ctypes.data)
lib.p_push_vector_from_float32_array(cffi_buffer, len(npa), np.nan)
elif dtype == np.bool: # convert first to float32
elif dtype == bool: # convert first to float32
f32_array = npa.astype(np.float32)
cffi_buffer = ffi.cast("float*", f32_array.ctypes.data)
lib.p_push_vector_from_float32_array(cffi_buffer, len(f32_array), np.nan)
elif dtype == np.int: # convert first to float64
elif dtype == int: # convert first to float64
f64_array = npa.astype(np.float64)
cffi_buffer = ffi.cast("double*", f64_array.ctypes.data)
lib.p_push_vector_from_double_array(cffi_buffer, len(f64_array), np.nan)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_metview.py
Expand Up @@ -1672,23 +1672,23 @@ def test_set_vector_float32_from_numpy_array():


def test_set_vector_10_bool_from_numpy_array():
r = np.array([1, 0, 0, 1, 1, 0, 1], dtype=np.bool)
r = np.array([1, 0, 0, 1, 1, 0, 1], dtype=bool)
assert mv.type(r) == "vector"
assert mv.dtype(r) == "float32"
assert mv.count(r) == 7
assert np.array_equal(mv.abs(r), np.array([1, 0, 0, 1, 1, 0, 1], dtype=np.float32))


def test_set_vector_TF_bool_from_numpy_array():
r = np.array([True, False, False, True, True, False, True], dtype=np.bool)
r = np.array([True, False, False, True, True, False, True], dtype=bool)
assert mv.type(r) == "vector"
assert mv.dtype(r) == "float32"
assert mv.count(r) == 7
assert np.array_equal(mv.abs(r), np.array([1, 0, 0, 1, 1, 0, 1], dtype=np.float32))


def test_set_vector_from_int_numpy_array():
r = np.array([5, 8, 7, 1, 2900], dtype=np.int)
r = np.array([5, 8, 7, 1, 2900], dtype=int)
assert mv.type(r) == "vector"
assert mv.dtype(r) == "float64"
assert mv.count(r) == 5
Expand Down

0 comments on commit f1b1d49

Please sign in to comment.