Enhance dumper comparator with tensor unifier and location finder (#12623)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user