from typing import Sequence from .hr_absence_bradford_factor_types import BradfordFactor def bradford_factor(spell_days: Sequence[int]) -> BradfordFactor: """B = S x S x D over the spells given.""" days = 0 for d in spell_days: if isinstance(d, bool) or not isinstance(d, int) or d < 1: raise ValueError("each spell must be at least one whole day, received %s" % (d,)) days += d spells = len(spell_days) return BradfordFactor(spells=spells, days=days, score=spells * spells * days)