Coverage for python/lsst/sims/maf/metrics/stringCountMetric.py : 84%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Helper object to unpack dictionary values as reduceFunction results. """
"""Count up the number of times each string appears in a column.
Dynamically builds reduce functions for each unique string value, so summary sats can be named the same as strings in the simData array without knowing the values of those trings ahead of time. """
col='filter', percent=False, **kwargs): """ Parameters ----------
col: str ('filter') Column name that has strings to look at percent : bool (False) Normalize and return results as percents ranther than raw count """ units = 'percent' else: metricDtype=object, **kwargs)
# convert to a numpy array # Numpy can't handle empty string as a dtype else: norm = sum(metricValue[0])/100. # Not sure I really like having to loop here, but the dtype is inflexible for key in metricValue.dtype.names: metricValue[key] = metricValue[key]/norm
# Now to dynamically set up the reduce functions
|