Skip to content

Commit

Permalink
Fix possible division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
pcuestas committed Apr 13, 2024
1 parent e91419d commit 4bd8713
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion skfda/misc/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ def _integral_average_fdatairregular(

integrals = np.mean(score.integrate(), axis=1)
lebesgue_measures = np.diff(score.sample_range, axis=-1).reshape(-1)
normalized_integrals = integrals / lebesgue_measures
normalized_integrals = np.divide(
integrals,
lebesgue_measures,
out=np.zeros_like(integrals),
where=lebesgue_measures != 0,
)
return np.average(normalized_integrals, weights=weights)


Expand Down

0 comments on commit 4bd8713

Please sign in to comment.