diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py index e8735c3e335621de537b92db592145dead319003..37c45feb9f9c6589dd4b9eba45bc70852322c796 100644 --- a/modules/base/pymod/table.py +++ b/modules/base/pymod/table.py @@ -756,7 +756,7 @@ Statistics for column %(col)s args are unary callables returning true if the row should be included in the result and false if not. """ - filt_tab=Table(self.col_names, self.col_types) + filt_tab=Table(list(self.col_names), list(self.col_types)) for row in self.rows: matches=True for func in args: diff --git a/modules/base/tests/test_table.py b/modules/base/tests/test_table.py index a2128d8873ca0b145adff395d1f1741109b2ac80..cd11bd729623d9b5463f4cc8a67daf43a0f10cd6 100644 --- a/modules/base/tests/test_table.py +++ b/modules/base/tests/test_table.py @@ -315,6 +315,24 @@ class TestTable(unittest.TestCase): self.CompareColNames(tab, ['x']) self.CompareColTypes(tab, 'x', 'f') + def testTableFilterColNamesTypes(self): + """ + make sure the col_names and col_types are copied. + We don't want them to be referenced to the original table. + This leads to strange surprises. + """ + t = Table(['a', 'b'], 'ii') + t.AddRow([1,2]) + t.AddRow([2,3]) + t.AddRow([2,3]) + t.AddRow([3,3]) + t.AddRow([4,3]) + t.AddRow([5,3]) + filt = t.Filter(a=2) + filt.AddCol('c', 'i') + self.assertEqual(len(t.col_names), 2) + self.assertEqual(len(t.col_types), 2) + def testTableInitMultiColMultiValueNonEmpty(self): ''' table with two column and four rows: