def _try_compute_mode(objects):
"""
Computes the mode of a set of object, if a unique such exists.
Args:
objects (list[T]): the object whose mode is to be computed
Returns:
T: the modal value, or None if a unique mode does not exist
"""
try:
numeric_value = statistics.mode(objects) # This _is_ 'None' friendly
except statistics.StatisticsError: # No unique value, or empty data
numeric_value = None
return numeric_value
评论列表
文章目录