Skip to content

Commit

Permalink
replace np.in1d with np.isin
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKing93 authored Nov 18, 2024
1 parent 4030e60 commit b58c38d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pysheds/sgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def _d8_accumulation(self, fdir, weights=None, dirmap=(64, 128, 1, 2, 4, 8, 16,
nodata_out=0., efficiency=None, algorithm='iterative', **kwargs):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1149,7 +1149,7 @@ def _d8_flow_distance(self, x, y, fdir, weights=None, dirmap=(64, 128, 1, 2, 4,
snap='corner', algorithm='iterative', **kwargs):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1322,7 +1322,7 @@ def _d8_compute_hand(self, fdir, mask, dirmap=(64, 128, 1, 2, 4, 8, 16, 32),
nodata_out=-1, algorithm='iterative'):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1421,7 +1421,7 @@ def extract_river_network(self, fdir, mask, dirmap=(64, 128, 1, 2, 4, 8, 16, 32)
mask = self._input_handler(mask, **kwargs)
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1504,7 +1504,7 @@ def extract_profiles(self, fdir, mask, dirmap=(64, 128, 1, 2, 4, 8, 16, 32),
mask = self._input_handler(mask, **kwargs)
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1568,7 +1568,7 @@ def stream_order(self, fdir, mask, dirmap=(64, 128, 1, 2, 4, 8, 16, 32),
mask = self._input_handler(mask, **kwargs)
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1663,7 +1663,7 @@ def _d8_distance_to_ridge(self, fdir, weights, dirmap=(64, 128, 1, 2, 4, 8, 16,
algorithm='iterative', nodata_out=np.nan, **kwargs):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1818,7 +1818,7 @@ def _d8_cell_dh(self, dem, fdir, dirmap=(64, 128, 1, 2, 4, 8, 16, 32),
nodata_out=np.nan):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def _d8_cell_distances(self, fdir, dirmap=(64, 128, 1, 2, 4, 8, 16, 32),
nodata_out=np.nan):
# Find nodata cells and invalid cells
nodata_cells = self._get_nodata_cells(fdir)
invalid_cells = ~np.in1d(fdir.ravel(), dirmap).reshape(fdir.shape)
invalid_cells = ~np.isin(fdir.ravel(), dirmap).reshape(fdir.shape)
# Set nodata cells to zero
fdir[nodata_cells] = 0
fdir[invalid_cells] = 0
Expand Down

0 comments on commit b58c38d

Please sign in to comment.