def test_distinct_with_row_names(self): rows = ((1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, 'd')) table = Table(rows, self.column_names, self.column_types, row_names='three') new_table = table.distinct('one') self.assertRowNames(new_table, ['a', None])
def test_distinct_none(self): rows = ((1, 2, 'a'), (1, None, None), (1, 1, 'c'), (1, None, None)) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct() self.assertIsNot(new_table, table) self.assertColumnNames(new_table, self.column_names) self.assertColumnTypes(new_table, [Number, Number, Text]) self.assertRows(new_table, [rows[0], rows[1], rows[2]])
def test_distinct_func(self): rows = ((1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None)) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct(lambda row: (row['two'], row['three'])) self.assertIsNot(new_table, table) self.assertColumnNames(new_table, self.column_names) self.assertColumnTypes(new_table, [Number, Number, Text]) self.assertRows(new_table, [rows[0], rows[1], rows[2]])
def test_distinct_with_row_names(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, 'd') ) table = Table(rows, self.column_names, self.column_types, row_names='three') new_table = table.distinct('one') self.assertRowNames(new_table, ['a', None])
def test_distinct_column(self): rows = ((1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None)) table = Table(rows, self.columns) new_table = table.distinct('one') self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 2) self.assertSequenceEqual(new_table.rows[0], (1, 2, 'a')) self.assertSequenceEqual(new_table.rows[1], (2, None, None)) self.assertSequenceEqual(new_table.columns['one'], (1, 2))
def test_distinct_with_row_names(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, 'd') ) table = Table(rows, self.column_names, self.column_types, row_names='three') new_table = table.distinct('one') self.assertSequenceEqual(new_table.rows['a'], (1, 2, 'a')) self.assertSequenceEqual(new_table.row_names, ('a', None))
def test_distinct_with_row_names(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, 'd') ) table = Table(rows, self.columns, row_names='three') new_table = table.distinct('one') self.assertSequenceEqual(new_table.rows['a'], (1, 2, 'a')) self.assertSequenceEqual(new_table.row_names, ('a', None))
def test_distinct_func(self): rows = ((1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None)) table = Table(rows, self.columns) new_table = table.distinct(lambda row: (row['two'], row['three'])) self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 3) self.assertSequenceEqual(new_table.rows[0], (1, 2, 'a')) self.assertSequenceEqual(new_table.rows[1], (2, None, None)) self.assertSequenceEqual(new_table.rows[2], (1, 1, 'c')) self.assertSequenceEqual(new_table.columns['one'], (1, 2, 1))
def test_distinct_column(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None) ) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct('one') self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 2) self.assertSequenceEqual(new_table.rows[0], (1, 2, 'a')) self.assertSequenceEqual(new_table.rows[1], (2, None, None)) self.assertSequenceEqual(new_table.columns['one'], (1, 2))
def test_distinct_func(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None) ) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct(lambda row: (row['two'], row['three'])) self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 3) self.assertSequenceEqual(new_table.rows[0], (1, 2, 'a')) self.assertSequenceEqual(new_table.rows[1], (2, None, None)) self.assertSequenceEqual(new_table.rows[2], (1, 1, 'c')) self.assertSequenceEqual(new_table.columns['one'], (1, 2, 1))
def test_distinct_none(self): rows = ( (1, 2, 'a'), (1, None, None), (1, 1, 'c'), (1, None, None) ) table = Table(rows, self.columns) new_table = table.distinct() self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 3) self.assertSequenceEqual(new_table.rows[0], (1, 2, 'a')) self.assertSequenceEqual(new_table.rows[1], (1, None, None)) self.assertSequenceEqual(new_table.rows[2], (1, 1, 'c')) self.assertSequenceEqual(new_table.columns['one'], (1, 1, 1))
def test_distinct_column(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None) ) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct('one') self.assertIsNot(new_table, table) self.assertColumnNames(new_table, self.column_names) self.assertColumnTypes(new_table, [Number, Number, Text]) self.assertRows(new_table, [ rows[0], rows[1] ])
def test_distinct_func(self): rows = ( (1, 2, 'a'), (2, None, None), (1, 1, 'c'), (1, None, None) ) table = Table(rows, self.column_names, self.column_types) new_table = table.distinct(lambda row: (row['two'], row['three'])) self.assertIsNot(new_table, table) self.assertColumnNames(new_table, self.column_names) self.assertColumnTypes(new_table, [Number, Number, Text]) self.assertRows(new_table, [ rows[0], rows[1], rows[2] ])