def _clean_treatments()

in spotify_confidence/samplesize/sample_size_calculator.py [0:0]


    def _clean_treatments(treatments):
        """Validate treatments input.

        Args:
            treatments (int): Number of treatment variants in the a/b test,
                including control. Defaults to 2.

        Returns:
            int: Number of treatment variants.

        Raises:
            TypeError: If `treatments` is not a number.
            ValueError: If `treatments` is not an integer greater than or
                equal to two.

        """
        error_string = "Treatments must be a whole number " "greater than or equal to two"
        try:
            remainder = treatments % 1
        except TypeError:
            raise TypeError(error_string)

        if remainder != 0:
            raise ValueError(error_string)
        elif treatments < 2:
            raise ValueError(error_string)
        else:
            return int(treatments)