in spotify_confidence/samplesize/sample_size_calculator.py [0:0]
def _validate_percentage(num):
"""Validate that num is a percentage.
Args:
num(float): Valid percentage.
Returns:
float: Valid percentage.
Raises:
TypeError: If `num` is not a float.
ValueError: If `num` is not between zero and one.
"""
if not isinstance(num, float):
raise TypeError("num must be a float")
elif not 0 < num < 1:
raise ValueError("num must be between 0 and 1")
else:
return num