def test_compute_with_row_names(self): table = Table(self.rows, self.columns, row_names='three') new_table = table.compute([ (Formula(self.number_type, lambda r: r['two'] + r['three']), 'number'), (Formula(self.text_type, lambda r: (r['one'] or '-') + six.text_type(r['three'])), 'text') ]) self.assertSequenceEqual(new_table.rows[0], ('a', 2, 3, 4, 5, 'a3')) self.assertSequenceEqual(new_table.row_names, (3, 5, 4, 6))
def test_compute_creates_rows(self): table = Table(self.rows, self.columns) table2 = table.compute([(Formula(self.number_type, lambda r: r['one']), 'new2')]) table3 = table2.compute([(Formula(self.number_type, lambda r: r['one']), 'new3')]) self.assertIsNot(table.rows[0], table2.rows[0]) self.assertNotEqual(table.rows[0], table2.rows[0]) self.assertIsNot(table2.rows[0], table3.rows[0]) self.assertNotEqual(table2.rows[0], table3.rows[0]) self.assertSequenceEqual(table.rows[0], (1, 4, 'a'))
def test_compute_creates_rows(self): table = Table(self.rows, self.columns) table2 = table.compute([ (Formula(self.number_type, lambda r: r['one']), 'new2') ]) table3 = table2.compute([ (Formula(self.number_type, lambda r: r['one']), 'new3') ]) self.assertIsNot(table.rows[0], table2.rows[0]) self.assertNotEqual(table.rows[0], table2.rows[0]) self.assertIsNot(table2.rows[0], table3.rows[0]) self.assertNotEqual(table2.rows[0], table3.rows[0]) self.assertSequenceEqual(table.rows[0], (1, 4, 'a'))