Example #1
0
    def testFpStr(self):
        # should give siz decimal places if less than 1.
        # if more, give up to seven sig figs
        from _rl_accel import fp_str
        assert fp_str(1,2,3)=='1 2 3'
        assert fp_str(1) == '1'

        assert fp_str(595.275574) == '595.2756'
        assert fp_str(59.5275574) == '59.52756'
        assert fp_str(5.95275574) == '5.952756'
Example #2
0
            if sa<=1e-7: A('0')
            else:
                l = sa<=1 and 6 or min(max(0,(6-int(_log_10(sa)))),6)
                n = _fp_fmts[l]%i
                if l:
                    n = _tz_re.sub('',n)
                    try:
                        if n[-1]=='.': n = n[:-1]
                    except:
                        print i, n
                        raise
                A((n[0]!='0' or len(n)==1) and n or n[1:])
        return ' '.join(s)

#hack test for comma users
if ',' in fp_str(0.25):
    _FP_STR = fp_str
    def fp_str(*a):
        return _FP_STR(*a).replace(',','.')

def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0):
    """Dynamically imports possible packagized module, or raises ImportError"""
    normalize = lambda x: os.path.normcase(os.path.abspath(os.path.normpath(x)))
    path = map(normalize,sys.path)
    if baseDir:
        if not isSeqType(baseDir):
            tp = [baseDir]
        else:
            tp = filter(None,list(baseDir))
        for p in tp:
            p = normalize(p)
Example #3
0
                l = sa <= 1 and 6 or min(max(0, (6 - int(_log_10(sa)))), 6)
                n = _fp_fmts[l] % i
                if l:
                    n = _tz_re.sub("", n)
                    try:
                        if n[-1] == ".":
                            n = n[:-1]
                    except:
                        print i, n
                        raise
                A((n[0] != "0" or len(n) == 1) and n or n[1:])
        return string.join(s)


# hack test for comma users
if "," in fp_str(0.25):
    _FP_STR = fp_str

    def fp_str(*a):
        return string.replace(apply(_FP_STR, a), ",", ".")


def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0):
    """Dynamically imports possible packagized module, or raises ImportError"""
    normalize = lambda x: os.path.normcase(os.path.abspath(os.path.normpath(x)))
    path = map(normalize, sys.path)
    if baseDir:
        if not isSeqType(baseDir):
            tp = [baseDir]
        else:
            tp = filter(None, list(baseDir))