Beispiel #1
0
def test_dtype_init_name(name):
    d = ts.dtype(name)
    d_attr = getattr(ts, name)
    assert d_attr.name == name
    assert d == d_attr
    assert d.name == name
    assert d.to_json() == name
Beispiel #2
0
def test_dtype_init_bfloat16():
    v = ts.bfloat16(1)
    t = type(v)
    assert ts.dtype(t) == ts.bfloat16
    assert ts.bfloat16.type is t
    assert ts.bfloat16(1) == 1
    assert ts.bfloat16(1.5) == 1.5
Beispiel #3
0
def test_dtype_init_type(name):
    t = getattr(np, name)
    d = ts.dtype(t)
    assert d.name == name
    assert d.type is t
    v = d(5)
    assert type(v) is t
    assert v == 5
Beispiel #4
0
def test_dtype_init_numpy_dtype(name):
    numpy_dtype = np.dtype(name)
    d = ts.dtype(numpy_dtype)
    assert d.name == name
    assert d.numpy_dtype == numpy_dtype
Beispiel #5
0
def test_dtype_init_bytes():
    assert ts.dtype(bytes) == ts.string
    assert ts.dtype(bytes).type is bytes
    assert ts.string.numpy_dtype == np.dtype("object")
    assert ts.string(b"hello") == b"hello"
    assert type(ts.string(b"hello")) is bytes
Beispiel #6
0
def test_dtype_init_str():
    assert ts.dtype(str) == ts.ustring
    assert ts.dtype(str).type is str
    assert ts.ustring.numpy_dtype == np.dtype("object")
    assert ts.ustring("hello") == "hello"
    assert type(ts.ustring("hello")) is str
Beispiel #7
0
def test_dtype_init_bool():
    assert ts.dtype(bool) == ts.bool
    assert ts.dtype(bool).type is np.bool_
    assert type(ts.bool(True)) is np.bool_
    assert ts.bool(True) == True
    assert ts.bool(False) == False