示例#1
0
def test_kwargs():
    source = '''
    train model l2: 0.5 alpha: 0.01
    '''
    assert parse(source) == [
        Call(Ident('train'), [
            Ident('model'),
            BinarySlurp([Ident('l2'), Ident(':'),
                         Float(0.5)]),
            BinarySlurp([Ident('alpha'),
                         Ident(':'), Float(0.01)]),
        ])
    ]
示例#2
0
def test_float_sigil():
    source = r'''
    10 + 3.0i
    '''
    assert parse(source) == [
        BinarySlurp([Int(10), Ident('+'), Float(3.0, 'i')])
    ]
示例#3
0
def test_float_trailing_underscore():
    source = '''
    x = 3_000_000.000_000_
    '''
    assert parse(source) == [
        BinarySlurp([Ident('x'), Ident('='),
                     Float(3000000.0)])
    ]
示例#4
0
def test_bigfloat_underscore():
    source = '''
    x = 3_00.0e1_0
    '''
    assert parse(source) == [
        BinarySlurp([Ident('x'), Ident('='),
                     Float(300e10)])
    ]
示例#5
0
def test_bigfloat_small():
    source = '''
    x = 3.0e-10
    '''
    assert parse(source) == [
        BinarySlurp([Ident('x'), Ident('='),
                     Float(3e-10)])
    ]
示例#6
0
def test_float():
    source = '''
    x = 3.0
    '''
    assert parse(source) == [BinarySlurp([Ident('x'), Ident('='), Float(3.0)])]