Skip to content

Commit

Permalink
Merge pull request #4754 from voxel51/bug/group-by-match
Browse files Browse the repository at this point in the history
Fix bug with group_by(..., match_expr=)
  • Loading branch information
brimoor authored Aug 30, 2024
2 parents dbdda14 + 76e4192 commit f8b89e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fiftyone/core/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ def _make_flat_pipeline(self, sample_collection):
)

if match_expr is not None:
pipeline.append({"$match": match_expr})
pipeline.append({"$match": {"$expr": match_expr}})

if sort_expr is not None:
order = -1 if self._reverse else 1
Expand Down
9 changes: 9 additions & 0 deletions tests/unittests/group_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,15 @@ def test_flatten(self):
)
self.assertListEqual(view.values("frame_number"), [1, 1])

@drop_datasets
def test_match_expr(self):
dataset = _make_group_by_dataset()

view = dataset.group_by(
"frame_number", flat=True, match_expr=(F().length() > 1)
)
self.assertDictEqual(view.count_values("frame_number"), {1: 2, 2: 2})

@drop_datasets
def test_group_by_group_dataset(self):
dataset = _make_group_by_group_dataset()
Expand Down

0 comments on commit f8b89e8

Please sign in to comment.