Skip to content

Commit

Permalink
Merge pull request #395 from pnuu/fix-deprecated-np-int
Browse files Browse the repository at this point in the history
Replace depracated Numpy dtypes
  • Loading branch information
djhoese authored Nov 17, 2021
2 parents 00cfc24 + 015efc2 commit 1c7b8f9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyresample/_spatial_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(self, *args, **kwargs):
def transform_lonlats(self, lons, lats):
"""Transform longitudes and latitues to cartesian coordinates."""
if np.issubdtype(lons.dtype, np.integer):
lons = lons.astype(np.float)
lons = lons.astype(np.float64)
coords = np.zeros((lons.size, 3), dtype=lons.dtype)
if ne:
deg2rad = np.pi / 180 # noqa: F841
Expand Down
2 changes: 1 addition & 1 deletion pyresample/bilinear/xarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _get_valid_input_index_and_input_coords(self):
self._radius_of_influence)
input_coords = lonlat2xyz(source_lons, source_lats)
valid_input_index = np.ravel(valid_input_index)
input_coords = input_coords[valid_input_index, :].astype(np.float)
input_coords = input_coords[valid_input_index, :].astype(np.float64)

return da.compute(valid_input_index, input_coords)

Expand Down
8 changes: 4 additions & 4 deletions pyresample/bucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def _get_indices(self):
# Calculate array indices. Orient so that 0-meridian is pointing down.
adef = self.target_area
x_res, y_res = adef.resolution
x_idxs = da.floor((proj_x - adef.area_extent[0]) / x_res).astype(np.int)
y_idxs = da.floor((adef.area_extent[3] - proj_y) / y_res).astype(np.int)
x_idxs = da.floor((proj_x - adef.area_extent[0]) / x_res).astype(np.int64)
y_idxs = da.floor((adef.area_extent[3] - proj_y) / y_res).astype(np.int64)

# Get valid index locations
mask = (x_idxs >= 0) & (x_idxs < adef.width) & (y_idxs >= 0) & (y_idxs < adef.height)
Expand Down Expand Up @@ -230,7 +230,7 @@ def _call_pandas_groupby_statistics(self, scipy_method, data, fill_value=None, s
# fill missed index
statistics = (statistics + pd.Series(np.zeros(out_size))).fillna(0)

counts = self.get_sum(np.logical_not(np.isnan(data)).astype(int)).ravel()
counts = self.get_sum(np.logical_not(np.isnan(data)).astype(np.int64)).ravel()

# TODO remove following line in favour of weights = data when dask histogram bug (issue #6935) is fixed
statistics = self._mask_bins_with_nan_if_not_skipna(skipna, data, out_size, statistics)
Expand Down Expand Up @@ -346,7 +346,7 @@ def get_average(self, data, fill_value=np.nan, skipna=True):
data = da.where(data == fill_value, np.nan, data)

sums = self.get_sum(data, skipna=skipna)
counts = self.get_sum(np.logical_not(np.isnan(data)).astype(int))
counts = self.get_sum(np.logical_not(np.isnan(data)).astype(np.int64))

average = sums / da.where(counts == 0, np.nan, counts)
average = da.where(np.isnan(average), fill_value, average)
Expand Down
2 changes: 1 addition & 1 deletion pyresample/future/resamplers/nearest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _query_resample_kdtree(self,
query_no_distance, 'jik', tlons, 'ji', tlats, 'ji',
valid_output_index, 'ji', *args, kdtree=resample_kdtree,
neighbours=neighbors, epsilon=epsilon,
radius=radius_of_influence, dtype=np.int,
radius=radius_of_influence, dtype=np.int64,
new_axes={'k': neighbors}, concatenate=True)
return res

Expand Down
2 changes: 1 addition & 1 deletion pyresample/kd_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def query_resample_kdtree(self,
res = blockwise(query_no_distance, 'jik', tlons, 'ji', tlats, 'ji',
valid_oi, 'ji', *args, kdtree=resample_kdtree,
neighbours=self.neighbours, epsilon=self.epsilon,
radius=self.radius_of_influence, dtype=np.int,
radius=self.radius_of_influence, dtype=np.int64,
new_axes={'k': self.neighbours}, concatenate=True)
return res, None

Expand Down
2 changes: 1 addition & 1 deletion pyresample/test/test_kd_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_nearest_masked_swath_target(self):
data = np.fromfunction(lambda y, x: y * x, (50, 10))
lons = np.fromfunction(lambda y, x: 3 + x, (50, 10))
lats = np.fromfunction(lambda y, x: 75 - y, (50, 10))
mask = np.ones_like(lons, dtype=np.bool)
mask = np.ones_like(lons, dtype=np.bool_)
mask[::2, ::2] = False
swath_def = geometry.SwathDefinition(
lons=np.ma.masked_array(lons, mask=mask),
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
'tests': test_requires}

setup_requires = ['numpy>=1.10.0', 'cython']
test_requires = ['rasterio', 'dask', 'xarray', 'cartopy>=0.20.0', 'pillow', 'matplotlib', 'scipy', 'zarr']
test_requires = ['rasterio', 'dask', 'xarray', 'cartopy>=0.20.0', 'pillow', 'matplotlib', 'scipy', 'zarr',
'pytest-lazy-fixture']

if sys.platform.startswith("win"):
extra_compile_args = []
Expand Down

0 comments on commit 1c7b8f9

Please sign in to comment.