Skip to content

Commit cc8f0f9

Browse files
committed
Remove deprecated positional arguments
1 parent b374abd commit cc8f0f9

File tree

15 files changed

+80
-123
lines changed

15 files changed

+80
-123
lines changed

econml/_ortho_learner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,8 @@ def _prefit(self, Y, T, *args, only_final=False, **kwargs):
543543

544544
super()._prefit(Y, T, *args, **kwargs)
545545

546-
@_deprecate_positional("X, W, and Z should be passed by keyword only. In a future release "
547-
"we will disallow passing X, W, and Z by position.", ['X', 'W', 'Z'])
548546
@BaseCateEstimator._wrap_fit
549-
def fit(self, Y, T, X=None, W=None, Z=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
547+
def fit(self, Y, T, *, X=None, W=None, Z=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
550548
cache_values=False, inference=None, only_final=False, check_input=True):
551549
"""
552550
Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.

econml/dml/_rlearner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ def _gen_ortho_learner_model_nuisance(self):
326326
def _gen_ortho_learner_model_final(self):
327327
return _ModelFinal(self._gen_rlearner_model_final())
328328

329-
@_deprecate_positional("X, and should be passed by keyword only. In a future release "
330-
"we will disallow passing X and W by position.", ['X', 'W'])
331-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
329+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
332330
cache_values=False, inference=None):
333331
"""
334332
Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.

econml/dml/causal_forest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,7 @@ def tune(self, Y, T, *, X=None, W=None,
704704
return self
705705

706706
# override only so that we can update the docstring to indicate support for `blb`
707-
708-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
709-
"we will disallow passing X and W by position.", ['X', 'W'])
710-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None,
707+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None,
711708
cache_values=False, inference='auto'):
712709
"""
713710
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).

econml/dml/dml.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,7 @@ def _gen_rlearner_model_final(self):
461461
return _FinalWrapper(self._gen_model_final(), self.fit_cate_intercept, self._gen_featurizer(), False)
462462

463463
# override only so that we can update the docstring to indicate support for `LinearModelFinalInference`
464-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
465-
"we will disallow passing X and W by position.", ['X', 'W'])
466-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
464+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
467465
cache_values=False, inference='auto'):
468466
"""
469467
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).
@@ -615,9 +613,7 @@ def _gen_model_final(self):
615613
return StatsModelsLinearRegression(fit_intercept=False)
616614

617615
# override only so that we can update the docstring to indicate support for `StatsModelsInference`
618-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
619-
"we will disallow passing X and W by position.", ['X', 'W'])
620-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
616+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
621617
cache_values=False, inference='auto'):
622618
"""
623619
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).
@@ -826,9 +822,7 @@ def _gen_model_final(self):
826822
n_jobs=self.n_jobs,
827823
random_state=self.random_state)
828824

829-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
830-
"we will disallow passing X and W by position.", ['X', 'W'])
831-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None,
825+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None,
832826
cache_values=False, inference='auto'):
833827
"""
834828
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).
@@ -1157,9 +1151,7 @@ def _gen_rlearner_model_final(self):
11571151

11581152
# override only so that we can update the docstring to indicate
11591153
# support for `GenericSingleTreatmentModelFinalInference`
1160-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
1161-
"we will disallow passing X and W by position.", ['X', 'W'])
1162-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
1154+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
11631155
cache_values=False, inference='auto'):
11641156
"""
11651157
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).

econml/dr/_drlearner.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,7 @@ def _gen_model_final(self):
455455
def _gen_ortho_learner_model_final(self):
456456
return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), self.multitask_model_final)
457457

458-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
459-
"we will disallow passing X and W by position.", ['X', 'W'])
460-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
458+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
461459
cache_values=False, inference='auto'):
462460
"""
463461
Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.
@@ -849,9 +847,7 @@ def _gen_model_final(self):
849847
def _gen_ortho_learner_model_final(self):
850848
return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False)
851849

852-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
853-
"we will disallow passing X and W by position.", ['X', 'W'])
854-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
850+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None,
855851
cache_values=False, inference='auto'):
856852
"""
857853
Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.
@@ -1144,9 +1140,7 @@ def _gen_model_final(self):
11441140
def _gen_ortho_learner_model_final(self):
11451141
return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False)
11461142

1147-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
1148-
"we will disallow passing X and W by position.", ['X', 'W'])
1149-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None,
1143+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None,
11501144
cache_values=False, inference='auto'):
11511145
"""
11521146
Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.
@@ -1440,9 +1434,7 @@ def _gen_model_final(self):
14401434
def _gen_ortho_learner_model_final(self):
14411435
return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False)
14421436

1443-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
1444-
"we will disallow passing X and W by position.", ['X', 'W'])
1445-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None,
1437+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None,
14461438
cache_values=False, inference='auto'):
14471439
"""
14481440
Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·).

econml/dynamic/dml/_dml.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,7 @@ def _strata(self, Y, T, X=None, W=None, Z=None,
540540
# Required for bootstrap inference
541541
return groups
542542

543-
@_deprecate_positional("X, and should be passed by keyword only. In a future release "
544-
"we will disallow passing X and W by position.", ['X', 'W'])
545-
def fit(self, Y, T, X=None, W=None, *, sample_weight=None, sample_var=None, groups,
543+
def fit(self, Y, T, *, X=None, W=None, sample_weight=None, sample_var=None, groups,
546544
cache_values=False, inference='auto'):
547545
"""Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`.
548546

econml/iv/nnet/_deepiv.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,8 @@ def __init__(self, *,
296296
self._second_stage_options = second_stage_options
297297
super().__init__()
298298

299-
@_deprecate_positional("X and Z should be passed by keyword only. In a future release "
300-
"we will disallow passing X and Z by position.", ['X', 'Z'])
301299
@BaseCateEstimator._wrap_fit
302-
def fit(self, Y, T, X, Z, *, inference=None):
300+
def fit(self, Y, T, *, X, Z, inference=None):
303301
"""Estimate the counterfactual model from data.
304302
305303
That is, estimate functions τ(·, ·, ·), ∂τ(·, ·).

econml/iv/sieve/_tsls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ def __init__(self, *,
208208
self._model_Y = LinearRegression(fit_intercept=False)
209209
super().__init__()
210210

211-
@_deprecate_positional("X, W, and Z should be passed by keyword only. In a future release "
212-
"we will disallow passing X, W, and Z by position.", ['X', 'W', 'Z'])
213211
@BaseCateEstimator._wrap_fit
214-
def fit(self, Y, T, Z, X=None, W=None, *, inference=None):
212+
def fit(self, Y, T, *, Z, X=None, W=None, inference=None):
215213
"""
216214
Estimate the counterfactual model from data, i.e. estimates functions τ(·, ·, ·), ∂τ(·, ·).
217215

econml/metalearners/_metalearners.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ def __init__(self, *,
4242
self.categories = categories
4343
super().__init__()
4444

45-
@_deprecate_positional("X should be passed by keyword only. In a future release "
46-
"we will disallow passing X by position.", ['X'])
4745
@BaseCateEstimator._wrap_fit
48-
def fit(self, Y, T, X, *, inference=None):
46+
def fit(self, Y, T, *, X, inference=None):
4947
"""Build an instance of TLearner.
5048
5149
Parameters
@@ -131,10 +129,8 @@ def __init__(self, *,
131129
self.categories = categories
132130
super().__init__()
133131

134-
@_deprecate_positional("X should be passed by keyword only. In a future release "
135-
"we will disallow passing X by position.", ['X'])
136132
@BaseCateEstimator._wrap_fit
137-
def fit(self, Y, T, X=None, *, inference=None):
133+
def fit(self, Y, T, *, X=None, inference=None):
138134
"""Build an instance of SLearner.
139135
140136
Parameters
@@ -240,10 +236,8 @@ def __init__(self, *,
240236
self.categories = categories
241237
super().__init__()
242238

243-
@_deprecate_positional("X should be passed by keyword only. In a future release "
244-
"we will disallow passing X by position.", ['X'])
245239
@BaseCateEstimator._wrap_fit
246-
def fit(self, Y, T, X, *, inference=None):
240+
def fit(self, Y, T, *, X, inference=None):
247241
"""Build an instance of XLearner.
248242
249243
Parameters
@@ -367,10 +361,8 @@ def __init__(self, *,
367361
self.categories = categories
368362
super().__init__()
369363

370-
@_deprecate_positional("X should be passed by keyword only. In a future release "
371-
"we will disallow passing X by position.", ['X'])
372364
@BaseCateEstimator._wrap_fit
373-
def fit(self, Y, T, X, *, inference=None):
365+
def fit(self, Y, T, *, X, inference=None):
374366
"""Build an instance of DomainAdaptationLearner.
375367
376368
Parameters

econml/orf/_ortho_forest.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,8 @@ def __init__(self,
250250
self.categories = categories
251251
super().__init__()
252252

253-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
254-
"we will disallow passing X and W by position.", ['X', 'W'])
255253
@BaseCateEstimator._wrap_fit
256-
def fit(self, Y, T, X, W=None, *, inference='auto'):
254+
def fit(self, Y, T, *, X, W=None, inference='auto'):
257255
"""Build an orthogonal random forest from a training set (Y, T, X, W).
258256
259257
Parameters
@@ -610,9 +608,7 @@ def _combine(self, X, W):
610608

611609
# Need to redefine fit here for auto inference to work due to a quirk in how
612610
# wrap_fit is defined
613-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
614-
"we will disallow passing X and W by position.", ['X', 'W'])
615-
def fit(self, Y, T, X, W=None, *, inference='auto'):
611+
def fit(self, Y, T, *, X, W=None, inference='auto'):
616612
"""Build an orthogonal random forest from a training set (Y, T, X, W).
617613
618614
Parameters
@@ -949,9 +945,7 @@ def __init__(self, *,
949945
batch_size=batch_size,
950946
random_state=self.random_state)
951947

952-
@_deprecate_positional("X and W should be passed by keyword only. In a future release "
953-
"we will disallow passing X and W by position.", ['X', 'W'])
954-
def fit(self, Y, T, X, W=None, *, inference='auto'):
948+
def fit(self, Y, T, *, X, W=None, inference='auto'):
955949
"""Build an orthogonal random forest from a training set (Y, T, X, W).
956950
957951
Parameters

0 commit comments

Comments
 (0)