def infer_type(data):
    """
    Infer the type of objects returned by indicators.

    infer_type returns:
     - 'scalar' for a number or None,
     - 'summarystats' for a SummaryStats object,
     - 'distribution_scalar' for a list of scalars,
     - 'distribution_summarystats' for a list of SummaryStats objects
    """

    if isinstance(data, (type(None), numbers.Number)):
        return 'scalar'

    if isinstance(data, SummaryStats):
        return 'summarystats'

    if hasattr(data, "__len__"):  # list or numpy array
        data = [x for x in data if x is not None]
        if len(data) == 0 or isinstance(data[0], numbers.Number):
            return 'distribution_scalar'
        if isinstance(data[0], SummaryStats):
            return 'distribution_summarystats'

        raise TypeError(
            "{} is not a valid input. It should be a number, a SummaryStats "
            "object, or None".format(data[0]))

    raise TypeError(
        "{} is not a valid input. It should be a number, a SummaryStats "
        "object, or a list".format(data))
def infer_type ( data ) : if isinstance ( data , ( type ( None ) , numbers . Number ) ) : return 'scalar' if isinstance ( data , SummaryStats ) : return 'summarystats' if hasattr ( data , "__len__" ) : data = [ x for x in data if x is not None ] if len ( data ) == 0 or isinstance ( data [ 0 ] , numbers . Number ) : return 'distribution_scalar' if isinstance ( data [ 0 ] , SummaryStats ) : return 'distribution_summarystats' raise TypeError ( "{} is not a valid input. It should be a number, a SummaryStats " "object, or None" . format ( data [ 0 ] ) ) raise TypeError ( "{} is not a valid input. It should be a number, a SummaryStats " "object, or a list" . format ( data ) )
Infer the type of objects returned by indicators.

    infer_type returns:
     - 'scalar' for a number or None,
     - 'summarystats' for a SummaryStats object,
     - 'distribution_scalar' for a list of scalars,
     - 'distribution_summarystats' for a list of SummaryStats objects