def test_simple_table(): t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])}) t.rename_column('a', 'c') assert t.keys == ['c', 'b']
def setup(self): self.a = np.arange(10, dtype=np.double) self.b = np.arange(5, 15, dtype=np.double) self.table_a = Table({'a': self.a, 'b': self.a}) self.table_b = Table({'b': self.b})
def test_simple_table(): t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])}) assert t.to_dict()['a'][2] == 3 assert np.all(t.index == np.ones((2, 3), dtype=np.uint8))
def test_mul(): t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])}) assert np.all((t.a * t.a).values == np.array([1, 4, 9]))
def test_add(): t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])}) assert np.all((t.a + t.a).values == np.array([2, 4, 6]))
def test_column_assign(): t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])}) t['a'][0] = 0 assert np.all(t.a.values == np.array([0, 2, 3]))
def test_filter_1(): a = np.arange(10, dtype=np.double) table_a = Table({'a': a, 'b': a}) assert np.all( table_a.filter(table_a.a > 5).a.values == np.array([6, 7, 8, 9]))
def test_filter_2(): a = np.arange(10, dtype=np.double) table_a = Table({'a': a, 'b': a}) assert np.all( table_a.filter((table_a.a > 5) & (table_a.b <= 6)).a.values == np.array([6]))