Skip to content

Commit

Permalink
Fixed issue with scorer test
Browse files Browse the repository at this point in the history
  • Loading branch information
AKuederle committed Oct 24, 2024
1 parent 67475b4 commit 0ed4cd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_pipelines/test_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ def test_scorer_calls_final_agg(self):
mock_final_agg = Mock()
scorer = Scorer(mock_score_func, final_aggregator=mock_final_agg)
pipe = DummyOptimizablePipeline()
scorer(pipeline=pipe, dataset=DummyDataset())
ds = DummyDataset()
scorer(pipeline=pipe, dataset=ds)

assert mock_final_agg.call_count == 1
# final aggregator gets called with the previous agg values, the single values, the pipeline and the dataset
assert mock_final_agg.call_args[0][0] == 1
assert mock_final_agg.call_args[0][1] == [1] * len(DummyDataset())
assert mock_final_agg.call_args[0][2] == pipe
assert mock_final_agg.call_args[0][3] == DummyDataset()
assert mock_final_agg.call_args[0][3] == ds


class TestScorer:
Expand Down
4 changes: 4 additions & 0 deletions tpcp/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ def __repr__(self) -> str:
def __eq__(self, other):
if not isinstance(other, type(self)):
return False
# Note: This fails, if you compare a dataset, for which the index was already generated with an identical one
# for which `index` was not called yet.
# This might be a bit unexpected, but I consider this correct behaviour and I don't want to trigger the
# index creation here, as this might be costly.
return custom_hash(self.get_params()) == custom_hash(other.get_params())

def _repr_html_(self) -> str:
Expand Down

0 comments on commit 0ed4cd5

Please sign in to comment.