Skip to content

Commit

Permalink
Remove warning for scalar divide with inf
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay authored and joein committed Apr 22, 2024
1 parent ef8e772 commit bbe0131
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions qdrant_client/local/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ def calculate_distance_core(


def fast_sigmoid(x: np.float32) -> np.float32:
if np.isnan(x):
# To avoid divisions on NaNs, which gets: RuntimeWarning: invalid value encountered in scalar divide
return x # NaN

if np.isnan(x) or np.isinf(x):
# To avoid divisions on NaNs or inf, which gets: RuntimeWarning: invalid value encountered in scalar divide
return x
return x / np.add(1.0, abs(x))


Expand Down

0 comments on commit bbe0131

Please sign in to comment.