Skip to content

Commit

Permalink
Use float, bool instead of np.float, np.bool (#163)
Browse files Browse the repository at this point in the history
* Replaced instances of 'np.float' with 'float'; the former is a depreciated alias for the latter.

* np.bool -> bool

---------

Co-authored-by: jemma <[email protected]>
Co-authored-by: dcherian <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2023
1 parent fc1df4a commit d3c80c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/source/examples/lateral-fill-idealized.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions pop_tools/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d3c80c0

Please sign in to comment.