Problem
DifferenceInDifferences.predict() exists on the estimator, but it raises NotImplementedError. The method docstring currently describes prediction as if it were supported, while TODO.md lists predict() as a known limitation.
That can confuse users coming from sklearn-style estimators: the method is discoverable, but the supported post-estimation surface is actually results_.fitted_values for fitted training-data predictions.
Proposed behaviour
Clarify the current contract without implementing new prediction semantics:
- document that out-of-sample
predict() is currently unsupported;
- keep the method raising
NotImplementedError after fitting;
- point users to
results_.fitted_values for fitted training-data predictions;
- frame broader prediction support as pending a post-estimation result-object design.
Proposed scope
- Update the
DifferenceInDifferences.predict() docstring and error message.
- Add a regression test for the unsupported fitted-predict contract.
- Add a short API docs note under
DifferenceInDifferences.
- Do not implement prediction or change result-object semantics.
Validation
PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -q
PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject -q
PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py -q
PYTHONPATH=. DIFF_DIFF_BACKEND=python .venv-py39/bin/python -m pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -q
python -m ruff check diff_diff/estimators.py
git diff --check
Note: make -C docs html SPHINXOPTS="-W" is currently blocked on pre-existing tutorial 19 DID unknown-target warnings, which are addressed separately in PR #572.
Problem
DifferenceInDifferences.predict()exists on the estimator, but it raisesNotImplementedError. The method docstring currently describes prediction as if it were supported, whileTODO.mdlistspredict()as a known limitation.That can confuse users coming from sklearn-style estimators: the method is discoverable, but the supported post-estimation surface is actually
results_.fitted_valuesfor fitted training-data predictions.Proposed behaviour
Clarify the current contract without implementing new prediction semantics:
predict()is currently unsupported;NotImplementedErrorafter fitting;results_.fitted_valuesfor fitted training-data predictions;Proposed scope
DifferenceInDifferences.predict()docstring and error message.DifferenceInDifferences.Validation
PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -qPYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject -qPYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py -qPYTHONPATH=. DIFF_DIFF_BACKEND=python .venv-py39/bin/python -m pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -qpython -m ruff check diff_diff/estimators.pygit diff --checkNote:
make -C docs html SPHINXOPTS="-W"is currently blocked on pre-existing tutorial 19DIDunknown-target warnings, which are addressed separately in PR #572.