def testSomePredicates(): #build table names = "int long float str object array".split() types = [ int, long, float, str, object, np.ndarray, ] formats = ["%3d", "%d", "%.3f", "%s", "%r", "'array%r' % (o.shape,)"] row1 = [1, 12323L, 1.0, "hi", {1: 1}, np.array((1, 2, 3))] row2 = [2, 22323L, 2.0, "hi2", [ 2, 3, ], np.array(((2, 3, 4), (1, 2, 3)))] row3 = [ 3, 32323L, 3.0, "hi3", (3, ), np.array(((3, 3, 4, 5), (1, 2, 3, 4))) ] rows = [row1, row2, row3] t = Table(names, types, formats, rows, "testtabelle", meta=dict(why=42)) tn = t.filter((t.int + t.float).inRange(-1, 2)) assert len(tn) == 1 assert tn.getValue(tn.rows[0], "int") == 1 tn = t.filter((t.float + t.int).inRange(-1, 2)) assert len(tn) == 1 assert tn.getValue(tn.rows[0], "int") == 1 tn = t.filter(t.float.approxEqual(1.0, t.int / 10)) tn._print() assert len(tn) == 1, len(tn) assert tn.getValue(tn.rows[0], "int") == 1
def testSomePredicates(): #build table names="int long float str object array".split() types = [int, long, float, str, object, np.ndarray,] formats = [ "%3d", "%d", "%.3f", "%s", "%r", "'array%r' % (o.shape,)" ] row1 = [ 1, 12323L, 1.0, "hi", { 1: 1 }, np.array((1,2,3)) ] row2 = [ 2, 22323L, 2.0, "hi2", [2,3,], np.array(((2,3,4),(1,2,3))) ] row3 = [ 3, 32323L, 3.0, "hi3", (3,) , np.array(((3,3,4,5),(1,2,3,4))) ] rows = [row1, row2, row3] t=Table(names, types, formats, rows, "testtabelle", meta=dict(why=42)) tn = t.filter((t.int+t.float).inRange(-1, 2)) assert len(tn) == 1 assert tn.getValue(tn.rows[0], "int") == 1 tn = t.filter((t.float+t.int).inRange(-1, 2)) assert len(tn) == 1 assert tn.getValue(tn.rows[0], "int") == 1 tn = t.filter(t.float.approxEqual(1.0, t.int/10)) tn._print() assert len(tn) == 1, len(tn) assert tn.getValue(tn.rows[0], "int") == 1