def rec_round(x, ndigits=2):
    """ round x recursively

    Parameters
    ----------
    x: float, int, list, list of list, ...
        variable to round, support many types
    ndigits: int
        precision in decimal digits
    """
    if isinstance(x, collections.Iterable):
        return [rec_round(item, ndigits) for item in x]
    return round(x, ndigits)
 round x recursively

    Parameters
    ----------
    x: float, int, list, list of list, ...
        variable to round, support many types
    ndigits: int
        precision in decimal digits
    
python/magent/utility.py