Skip to content

Commit 74e9536

Browse files
optimisation poly_indexs and bug correction with np.nan casting
1 parent e5bbf95 commit 74e9536

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/py_eddy_tracker/observations/observation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,10 @@ def contains(self, x, y, intern=False):
20502050
:rtype: array[int32]
20512051
"""
20522052
xname, yname = self.intern(intern)
2053-
return poly_indexs(x, y, self[xname], self[yname])
2053+
m = ~ (isnan(x) + isnan(y))
2054+
i = -ones(x.shape, dtype='i4')
2055+
i[m] = poly_indexs(x[m], y[m], self[xname], self[yname])
2056+
return i
20542057

20552058
def inside(self, x, y, intern=False):
20562059
"""

src/py_eddy_tracker/poly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def box_indexes(x, y, step):
815815

816816

817817
@njit(cache=True)
818-
def poly_indexs_(x_p, y_p, x_c, y_c):
818+
def poly_indexs(x_p, y_p, x_c, y_c):
819819
"""
820820
Index of contour for each postion inside a contour, -1 in case of no contour
821821
@@ -874,7 +874,7 @@ def poly_indexs_(x_p, y_p, x_c, y_c):
874874

875875

876876
@njit(cache=True)
877-
def poly_indexs(x_p, y_p, x_c, y_c):
877+
def poly_indexs_old(x_p, y_p, x_c, y_c):
878878
"""
879879
index of contour for each postion inside a contour, -1 in case of no contour
880880

0 commit comments

Comments
 (0)