Skip to content

Commit

Permalink
Ignore row order in equality check
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Jan 24, 2025
1 parent fbc5d29 commit c7e3f47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
compatible with `strtobool`
- All arguments to `MetaRecommender.select_recommender` are now optional
- `MetaRecommender`s can now be composed of other `MetaRecommender`s
- For performance reasons, search space manipulation using `polars` is no longer
guaranteed to produce the same row order as the corresponding `pandas` operations

### Fixed
- Rare bug arising from degenerate `SubstanceParameter.comp_df` rows that caused
Expand Down
10 changes: 7 additions & 3 deletions tests/constraints/test_constraints_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_polars_product(constraints, parameters):
# Do Pandas product
df_pd = parameter_cartesian_prod_pandas(parameters)

# Assert equality of lengths before filtering
# Assert equality before filtering
assert_frame_equal(df_pl.to_pandas(), df_pd)

# Apply constraints
Expand All @@ -198,5 +198,9 @@ def test_polars_product(constraints, parameters):
_apply_constraint_filter_polars(ldf, constraints)[0].collect().to_pandas()
)

# Assert strict equality of two dataframes
assert_frame_equal(df_pl_filtered, df_pd_filtered)
# Assert order-agnostic equality of the two dataframes
cols = df_pd_filtered.columns.tolist()
assert_frame_equal(
df_pd_filtered.sort_values(cols).reset_index(drop=True),
df_pl_filtered.sort_values(cols).reset_index(drop=True),
)

0 comments on commit c7e3f47

Please sign in to comment.