Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/gfdl/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,27 @@ def test_sklearn_api_conformance(estimator, check):
check(estimator)


@pytest.mark.parametrize("estimator", [
GFDLClassifier, EnsembleGFDLClassifier
])
def test_preserve_class_inputs(estimator):
# see: gh-111
clf = estimator(seed=0)
actual = clf.get_params()
expected = {"activation": "identity",
"hidden_layer_sizes": (100,),
"reg_alpha": None,
"rtol": None,
"seed": 0,
"voting": "soft",
"weight_scheme": "uniform",
"direct_links": True}
for k, v in actual.items():
if k in expected:
assert v == expected[k]
assert isinstance(v, type(expected[k]))
Comment on lines +458 to +461

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Shared expected dict silently skips class-specific params

The loop iterates over actual.items() and only validates a key when it appears in both actual and expected. Because the same dict is used for both estimators, direct_links (present in GFDLClassifier but not in EnsembleGFDLClassifier) and voting (present in EnsembleGFDLClassifier but not in GFDLClassifier) each sit as a "dead" entry in expected for the other estimator — they will never be reached in that estimator's test run. This means a reader scanning expected cannot tell which keys are actually validated for which estimator without checking both __init__ signatures. Consider using per-estimator expected dicts, or iterating over expected.items() and guarding with if k in actual, so that omissions are explicit rather than silent.



@pytest.mark.parametrize("reg_alpha, rtol, expected_acc, expected_roc", [
(0.1, 1e-15, 0.9083333333333333, 0.9893414717354735),
(None, 1e-15, 0.2222222222222222, 0.5518850599798965),
Expand Down
Loading