Skip to content

Commit d555aa0

Browse files
committed
CLN: Remove unreachable code
1 parent b6e75db commit d555aa0

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

linearmodels/iv/model.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
OneWayClusteredWeightMatrix,
5151
)
5252
from linearmodels.iv.results import IVGMMResults, IVResults, OLSResults
53-
from linearmodels.panel.utility import InvalidFormulaError
5453
from linearmodels.shared.exceptions import IndexWarning, missing_warning
5554
from linearmodels.shared.hypotheses import InvalidTestStatistic, WaldTestStatistic
5655
from linearmodels.shared.linalg import has_constant, inv_sqrth
@@ -300,11 +299,6 @@ def predict(
300299
parser = IVFormulaParser(self.formula, data, eval_env=eval_env)
301300
exog = parser.exog
302301
endog = parser.endog
303-
if exog is None and exog is None:
304-
raise InvalidFormulaError(
305-
f"Parsed formula ({self.formula}) has no exog and no endog. One "
306-
f"of these must be included in the formula to make a prediction."
307-
)
308302
if all(a is None for a in (exog, endog, data)):
309303
raise ValueError("At least one of exog, endog, or data must be provided.")
310304
if exog is None:

linearmodels/panel/utility.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
__all__ = [
2525
"AbsorbingEffectError",
2626
"AbsorbingEffectWarning",
27-
"InvalidFormulaError",
2827
"_drop_singletons",
2928
"_py_drop_singletons",
3029
"_remove_node",
@@ -689,7 +688,3 @@ def generate_panel_data(
689688
clusters = concat([vc1_df, vc2_df], sort=False)
690689
data = concat([y_df, x_df], axis=1, sort=False)
691690
return PanelModelData(data, w_df, other_eff, clusters)
692-
693-
694-
class InvalidFormulaError(Exception):
695-
pass

linearmodels/tests/iv/test_formulas.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,27 @@ def test_predict_no_rhs(data, model_and_func):
416416
pred1 = res.predict(data=data)
417417
pred1.columns = pred0.columns
418418
assert_frame_equal(pred0, pred1)
419+
420+
421+
@pytest.mark.parametrize(
422+
"fmla",
423+
[
424+
"y ~ 1",
425+
"y ~ 1 + x3",
426+
"y ~ [x1 + x2 ~ 1 + z1 + z2 + z3]",
427+
"y ~ 1 + [x1 + x2 ~ z1 + z2 + z3]",
428+
],
429+
)
430+
def test_formula_single(data, model_and_func, fmla):
431+
model, func = model_and_func
432+
res = model.from_formula(fmla, data).fit()
433+
pred0 = res.predict()
434+
pred1 = res.predict(data=data)
435+
436+
mod2 = func(fmla, data)
437+
res2 = mod2.fit()
438+
pred2 = res2.predict(data=data)
439+
pred1.columns = pred0.columns
440+
pred2.columns = pred0.columns
441+
assert_frame_equal(pred1, pred2)
442+
assert_frame_equal(pred0, pred1)

0 commit comments

Comments
 (0)