Skip to content

Commit

Permalink
show duplicates on non-unique query (#73)
Browse files Browse the repository at this point in the history
* show duplicates on non-unique query

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update filefinder/_filefinder.py

Remove comment

Co-authored-by: Mathias Hauser <[email protected]>

* Update filefinder/_filefinder.py

Co-authored-by: Mathias Hauser <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Mathias Hauser <[email protected]>
  • Loading branch information
3 people authored Feb 7, 2024
1 parent 10cd2e6 commit 6b89335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ __pycache__

.pytest_cache/

# development scripts
devel/*

# C extensions
*.so

Expand Down
4 changes: 3 additions & 1 deletion filefinder/_filefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ def find(self, keys=None, *, _allow_empty=False, **keys_kwargs):
len_all = len(fc.df)
len_unique = len(fc.combine_by_key().unique())

msg = "This query leads to non-unique metadata. Please adjust your query."
if len_all != len_unique:
duplicated = fc.df[fc.df.duplicated()]
msg = f"This query leads to non-unique metadata. Please adjust your query.\nFirst five duplicates:\n{duplicated.head()}"

raise ValueError(msg)

return fc
Expand Down

0 comments on commit 6b89335

Please sign in to comment.