Example #1
0
    def test(self):
        dtype = jt.NanoString
        t = time.time()
        n = 1000000
        for i in range(n):
            dtype("float")
        t = (time.time() - t)/n
        # t is about 0.01 for 100w loop
        # 92ns one loop
        print("nanostring time", t)
        assert t < [1.5e-7, 1.7e-7][mid], t

        assert (jt.hash("asdasd") == 4152566416)
        assert str(jt.NanoString("float"))=="float32"
        assert jt.NanoString("float")=="float32"
Example #2
0
    def test_type(self):
        import numpy as np
        assert str(jt.NanoString(float)) == "float"
        assert str(jt.NanoString(np.float)) == "float"
        assert str(jt.NanoString(np.float32)) == "float32"
        assert str(jt.NanoString(np.float64)) == "float64"
        assert str(jt.NanoString(np.int8)) == "int8"
        assert str(jt.NanoString(np.array([1, 2, 3]).dtype)) == "int64"

        def get_error_str(call):
            es = ""
            try:
                call()
            except Exception as e:
                es = str(e)
            return es

        e = get_error_str(lambda: jt.code([
            1,
        ], {}, [1], cpu_header=""))
        assert "help(jt.ops.code)" in e
        assert "cpu_header=str" in e
        e = get_error_str(lambda: jt.NanoString([1, 2, 3], f**k=1))
        assert "f**k=int" in str(e)
        assert "(list, )" in str(e)
Example #3
0
 def test_array_dtype(self):
     a = jt.array([1, 2, 3], dtype=jt.NanoString("float32"))
     a = jt.array([1, 2, 3], dtype=jt.float32)