From 5ba857cd5d4371abfb7d7009ac929664f26703cf Mon Sep 17 00:00:00 2001 From: veni-vidi-vici-dormivi Date: Wed, 7 Feb 2024 10:36:22 +0100 Subject: [PATCH] show duplicates on non-unique query --- .gitignore | 3 +++ filefinder/_filefinder.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d0f1579..74201ba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ __pycache__ .pytest_cache/ +# development scripts +devel/* + # C extensions *.so diff --git a/filefinder/_filefinder.py b/filefinder/_filefinder.py index 1fdbc1c..b444b91 100644 --- a/filefinder/_filefinder.py +++ b/filefinder/_filefinder.py @@ -115,8 +115,11 @@ 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." + #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.\n Head of duplicates: \n {duplicated.head()}" + raise ValueError(msg) return fc