When k is large enough in early iterations, there may be too few valid scores from which to calculate a top-k average. This results in a TypeError of trying to sum over an iterable of Optional[float]. This PR adds a simple change to convert these Nones to 0s in the sum() call. This depresses the top-k average, but I would argue that's logically correct when the top-k contains invalid scores.
Description
When
k
is large enough in early iterations, there may be too few valid scores from which to calculate a top-k
average. This results in aTypeError
of trying to sum over an iterable ofOptional[float]
. This PR adds a simple change to convert theseNone
s to0
s in thesum()
call. This depresses the top-k
average, but I would argue that's logically correct when the top-k
contains invalid scores.Checklist