Skip to content

Commit

Permalink
Drop redundant array-creation when calling bin1d_vec in `.get_ind…
Browse files Browse the repository at this point in the history
…ex_of`

(`bin1d_vec` already does that with `.asarray`)
  • Loading branch information
mherrmann3 committed Feb 6, 2025
1 parent 1fac3bf commit 9c14ee8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions csep/core/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ def get_index_of(self, lons, lats):
Returns:
idx: ndarray-like
"""
idx = bin1d_vec(numpy.array(lons), self.xs)
idy = bin1d_vec(numpy.array(lats), self.ys)
idx = bin1d_vec(lons, self.xs)
idy = bin1d_vec(lats, self.ys)
if numpy.any(idx == -1) or numpy.any(idy == -1):
raise ValueError("at least one lon and lat pair contain values that are outside of the valid region.")
if numpy.any(self.bbox_mask[idy, idx] == 1):
Expand Down Expand Up @@ -1061,7 +1061,7 @@ def get_cell_area(self):
self.cell_area = cell_area
return self.cell_area

def get_index_of(self, lons, lats):
def get_index_of(self, lons, lats):
""" Returns the index of lons, lats in self.polygons
Args:
Expand Down

0 comments on commit 9c14ee8

Please sign in to comment.