Enhance dumper comparator with tensor unifier and location finder (#12623)

This commit is contained in:
fzyzcjy
2025-11-14 17:34:08 +08:00
committed by GitHub
parent ace27c0c01
commit 821fb060c3
2 changed files with 167 additions and 27 deletions
+10 -2
View File
@@ -72,12 +72,20 @@ def find_row(df, conditions: Dict[str, Any]):
functools.reduce(
lambda a, b: a & b,
[
pl.col(col) == _cast_to_polars_dtype(conditions[col], df.schema[col])
(
pl.col(col)
== _cast_to_polars_dtype(conditions[col], df.schema[col])
if conditions[col] is not None
else pl.col(col).is_null()
)
for col in conditions.keys()
if col in df.columns
],
)
)
assert len(df_sub) <= 1
if len(df_sub) > 1:
print(f"find_row find ambiguous results: {df_sub=}")
return None
return df_sub.to_dicts()[0] if len(df_sub) > 0 else None