Skip to content

Commit

Permalink
fix: Allow consecutive calls to Table.group_by, closes #765
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 4, 2023
1 parent 9176808 commit 66222ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.7.2
-----

* Fix consecutive calls to :meth:`.Table.group_by`. (#765)

1.7.1 - Jan 4, 2023
-------------------

Expand Down
7 changes: 6 additions & 1 deletion agate/tableset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ def _proxy(self, method_name, *args, **kwargs):
tables = []

for key, table in self.items():
tables.append(getattr(table, method_name)(*args, **kwargs))
result = getattr(table, method_name)(*args, **kwargs)
if isinstance(result, TableSet):
for table in result.values():
tables.append(table)
else:
tables.append(result)

return self._fork(
tables,
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

autodoc_default_options = {
'members': None,
'member-order': 'bysource',
'show-inheritance': True,
}

Expand Down
5 changes: 5 additions & 0 deletions tests/test_table/test_group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ def test_group_by_bad_column(self):

with self.assertRaises(KeyError):
table.group_by('bad')

def test_group_by_twice(self):
table = Table(self.rows, self.column_names, self.column_types)

repr(table.group_by('one').group_by('two'))

0 comments on commit 66222ec

Please sign in to comment.