peng/functions.py
def _to_eng_tuple(number):
    """
    Return tuple with mantissa and exponent of number formatted in engineering notation.

    :param number: Number
    :type  number: integer or float

    :rtype: tuple
    """
    # pylint: disable=W0141
    # Helper function: split integer and fractional part of mantissa
    #  + ljust ensures that integer part in engineering notation has
    #    at most 3 digits (say if number given is 1E4)
    #  + rstrip ensures that there is no empty fractional part
    split = lambda x, p: (x.ljust(3 + neg, "0")[:p], x[p:].rstrip("0"))
    # Convert number to scientific notation, a "constant" format
    mant, exp = to_scientific_tuple(number)
    mant, neg = mant.replace(".", ""), mant.startswith("-")
    # New values
    new_mant = ".".join(filter(None, split(mant, 1 + (exp % 3) + neg)))
    new_exp = int(3 * math.floor(exp / 3))
    return NumComp(new_mant, new_exp)
def _to_eng_tuple(number):
    """
    Return tuple with mantissa and exponent of number formatted in engineering notation.

    :param number: Number
    :type  number: integer or float

    :rtype: tuple
    """
    # pylint: disable=W0141
    # Helper function: split integer and fractional part of mantissa
    #  + ljust ensures that integer part in engineering notation has
    #    at most 3 digits (say if number given is 1E4)
    #  + rstrip ensures that there is no empty fractional part
    split = lambda x, p: (x.ljust(3 + neg, "0")[:p], x[p:].rstrip("0"))
    # Convert number to scientific notation, a "constant" format
    mant, exp = to_scientific_tuple(number)
    mant, neg = mant.replace(".", ""), mant.startswith("-")
    # New values
    new_mant = ".".join(filter(None, split(mant, 1 + (exp % 3) + neg)))
    new_exp = int(3 * math.floor(exp / 3))
    return NumComp(new_mant, new_exp)
Return tuple with mantissa and exponent of number formatted in engineering notation.

    :param number: Number
    :type  number: integer or float

    :rtype: tuple