From d3c80c0576ae4838c0e04a0157734eb0c977e613 Mon Sep 17 00:00:00 2001 From: jemmajeffree <98864717+jemmajeffree@users.noreply.github.com> Date: Thu, 6 Jul 2023 07:18:49 +1000 Subject: [PATCH] Use float, bool instead of np.float, np.bool (#163) * Replaced instances of 'np.float' with 'float'; the former is a depreciated alias for the latter. * np.bool -> bool --------- Co-authored-by: jemma Co-authored-by: dcherian --- .../source/examples/lateral-fill-idealized.ipynb | 2 +- pop_tools/grid.py | 16 ++++++++-------- tests/test_fill.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/source/examples/lateral-fill-idealized.ipynb b/docs/source/examples/lateral-fill-idealized.ipynb index 4408dd74..6c19a127 100644 --- a/docs/source/examples/lateral-fill-idealized.ipynb +++ b/docs/source/examples/lateral-fill-idealized.ipynb @@ -50,7 +50,7 @@ "\n", "z_orig = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)\n", "\n", - "valid_points = np.ones(z_orig.shape, dtype=np.bool)\n", + "valid_points = np.ones(z_orig.shape, dtype=bool)\n", "valid_points = np.where(y < 0.5 * np.sin(5 * x) + 1.5, False, valid_points)\n", "\n", "z_orig = np.where(~valid_points, np.nan, z_orig)\n", diff --git a/pop_tools/grid.py b/pop_tools/grid.py index a1c37aa4..89927c83 100644 --- a/pop_tools/grid.py +++ b/pop_tools/grid.py @@ -139,14 +139,14 @@ def get_grid(grid_name, scrip=False): grid_file_data = np.fromfile(horiz_grid_fname, dtype='>f8', count=-1) grid_file_data = grid_file_data.reshape((7, nlat, nlon)) - ULAT = grid_file_data[0, :, :].astype(np.float) - ULONG = grid_file_data[1, :, :].astype(np.float) - HTN = grid_file_data[2, :, :].astype(np.float) - HTE = grid_file_data[3, :, :].astype(np.float) + ULAT = grid_file_data[0, :, :].astype(float) + ULONG = grid_file_data[1, :, :].astype(float) + HTN = grid_file_data[2, :, :].astype(float) + HTE = grid_file_data[3, :, :].astype(float) # compute TLAT, TLONG - TLAT = np.empty((nlat, nlon), dtype=np.float) - TLONG = np.empty((nlat, nlon), dtype=np.float) + TLAT = np.empty((nlat, nlon), dtype=float) + TLONG = np.empty((nlat, nlon), dtype=float) _compute_TLAT_TLONG(ULAT, ULONG, TLAT, TLONG, nlat, nlon) # generate DXT, DYT @@ -439,8 +439,8 @@ def _compute_corners(ULAT, ULONG): """Compute grid corners.""" nlat, nlon = ULAT.shape - corner_lat = np.empty((nlat, nlon, 4), dtype=np.float) - corner_lon = np.empty((nlat, nlon, 4), dtype=np.float) + corner_lat = np.empty((nlat, nlon, 4), dtype=float) + corner_lon = np.empty((nlat, nlon, 4), dtype=float) # NE corner corner_lat[:, :, 0] = ULAT diff --git a/tests/test_fill.py b/tests/test_fill.py index 258d8150..c5c73c0d 100644 --- a/tests/test_fill.py +++ b/tests/test_fill.py @@ -181,7 +181,7 @@ def _generate_2D_test_dataset(tripole=False): z_orig = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x) # construct mask and apply mask - valid_points = np.ones(z_orig.shape, dtype=np.bool) + valid_points = np.ones(z_orig.shape, dtype=bool) valid_points = np.where(y < 0.5 * np.sin(5 * x) + 1.5, False, valid_points) z_orig = np.where(~valid_points, np.nan, z_orig)