def test_table_proxy(ms): """ Base table proxy test """ tp = TableProxy(pt.table, ms, ack=False, readonly=False) tq = TableProxy(pt.taql, f"SELECT UNIQUE ANTENNA1 FROM '{ms}'") assert_liveness(2, 1) assert tp.nrows().result() == 10 assert tq.nrows().result() == 3 # Different tokens assert tokenize(tp) != tokenize(tq) del tp, tq assert_liveness(0, 0)
def _ant1_factory(ms): proxy = TableProxy(pt.table, ms, ack=False, readonly=False) nrows = proxy.nrows().result() name = 'ant1' row_chunk = 2 layers = {} chunks = [] for c, sr in enumerate(range(0, nrows, row_chunk)): er = min(sr + row_chunk, nrows) chunk_size = er - sr chunks.append(chunk_size) layers[(name, c)] = (proxy.getcol, "ANTENNA1", sr, chunk_size) # Create array graph = HighLevelGraph.from_collections(name, layers, []) ant1 = da.Array(graph, name, (tuple(chunks), ), dtype=np.int32) # Evaluate futures return ant1.map_blocks(lambda f: f.result(), dtype=ant1.dtype)