def test_numbers(): x = symbol('x', 'real') y = symbol('y', 'int') for expr in [x + 1, x - 1, x * 1, x + y, x - y, x / y, x * y + x + y, x**y, x**2, 2**x, x % 5, -x, sin(x), cos(x ** 2), exp(log(y))]: assert expr.dshape == dshape('real') assert eval(str(expr)).isidentical(expr) assert (-y).dshape == dshape('int')
def test_numbers(): x = symbol("x", "real") y = symbol("y", "int") for expr in [ x + 1, x - 1, x * 1, x + y, x - y, x / y, x * y + x + y, x ** y, x ** 2, 2 ** x, x % 5, -x, sin(x), cos(x ** 2), exp(log(y)), ]: assert expr.dshape == dshape("real") assert eval(str(expr)).isidentical(expr) assert (-y).dshape == dshape("int")
def test_neg_dshape_unsigned(): y = symbol('y', 'uint32') assert (-y).dshape == dshape('int32')
def test_relationals(): x = symbol('x', 'real') for expr in [x < 1, x > 1, x == 1, x != 1, x <= 1, x >= 1, ~b]: assert expr.dshape == dshape('bool') assert eval(str(expr)).isidentical(expr)
def test_neg_dshape_unsigned(): y = symbol("y", "uint32") assert (-y).dshape == dshape("int32")
def test_scalar_field(): x = symbol('x', '{name: string, amount: int64, when: datetime}') assert 'amount' in dir(x) assert x.amount.dshape == dshape('int64')
def test_relationals(): x = symbol("x", "real") for expr in [x < 1, x > 1, x == 1, x != 1, x <= 1, x >= 1, ~b]: assert expr.dshape == dshape("bool") assert eval(str(expr)).isidentical(expr)
def test_scalar_projection(): x = symbol("x", "{name: string, amount: int64, when: datetime}") assert x[["amount", "when"]].dshape == dshape("{amount: int64, when: datetime}")
def test_scalar_field(): x = symbol("x", "{name: string, amount: int64, when: datetime}") assert "amount" in dir(x) assert x.amount.dshape == dshape("int64")
def test_scalar_name_dtype(): x = symbol("x", "int64") assert x._name == "x" assert x.dshape == dshape("int64")
def test_arithmetic_dshape_inference(): x = symbol("x", "int") y = symbol("y", "int") assert (x + y).dshape == dshape("int")
def test_arithmetic_dshape_inference(): x = symbol('x', 'int') y = symbol('y', 'int') assert (x + y).dshape == dshape('int')
def test_scalar_name_dtype(): x = symbol('x', 'int64') assert x._name == 'x' assert x.dshape == dshape('int64')
def test_relationals(): x = Symbol('x', 'real') for expr in [x < 1, x > 1, x == 1, x != 1, x <= 1, x >= 1, ~x]: assert expr.dshape == dshape('bool') assert eval(str(expr)) == expr
def test_scalar_projection(): x = symbol('x', '{name: string, amount: int64, when: datetime}') assert x[['amount', 'when']].dshape == \ dshape('{amount: int64, when: datetime}')