Skip to content

Commit f1e7668

Browse files
committed
change force_all_finite to ensure_all_finite
1 parent 04cecf8 commit f1e7668

File tree

15 files changed

+80
-80
lines changed

15 files changed

+80
-80
lines changed

doubleml/data/base_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def from_arrays(
286286
elif not isinstance(force_all_d_finite, bool):
287287
raise TypeError("Invalid force_all_d_finite. " + "force_all_d_finite must be True, False or 'allow-nan'.")
288288

289-
x = check_array(x, ensure_2d=False, allow_nd=False, force_all_finite=force_all_x_finite)
290-
d = check_array(d, ensure_2d=False, allow_nd=False, force_all_finite=force_all_x_finite)
289+
x = check_array(x, ensure_2d=False, allow_nd=False, ensure_all_finite=force_all_x_finite)
290+
d = check_array(d, ensure_2d=False, allow_nd=False, ensure_all_finite=force_all_x_finite)
291291
y = column_or_1d(y, warn=True)
292292

293293
x = _assure_2d_array(x)

doubleml/did/did.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def _check_data(self, obj_dml_data):
201201
return
202202

203203
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
204-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
205-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
204+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
205+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
206206

207207
# nuisance g
208208
# get train indices for d == 0
@@ -372,8 +372,8 @@ def _sensitivity_element_est(self, preds):
372372
def _nuisance_tuning(
373373
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
374374
):
375-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
376-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
375+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
376+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
377377
# get train indices for d == 0 and d == 1
378378
smpls_d0, smpls_d1 = _get_cond_smpls(smpls, d)
379379

doubleml/did/did_binary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ def _preprocess_data(self, g_value, pre_t, eval_t):
429429
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
430430

431431
# Here: d is a binary treatment indicator
432-
x, y = check_X_y(self._x_data_subset, self._y_data_subset, force_all_finite=False)
433-
x, d = check_X_y(x, self._g_data_subset, force_all_finite=False)
432+
x, y = check_X_y(self._x_data_subset, self._y_data_subset, ensure_all_finite=False)
433+
x, d = check_X_y(x, self._g_data_subset, ensure_all_finite=False)
434434
# nuisance g
435435
# get train indices for d == 0
436436
smpls_d0, smpls_d1 = _get_cond_smpls(smpls, d)
@@ -570,8 +570,8 @@ def _score_elements(self, y, d, g_hat0, g_hat1, m_hat, p_hat):
570570
def _nuisance_tuning(
571571
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
572572
):
573-
x, y = check_X_y(self._x_data_subset, self._y_data_subset, force_all_finite=False)
574-
x, d = check_X_y(x, self._g_data_subset, force_all_finite=False)
573+
x, y = check_X_y(self._x_data_subset, self._y_data_subset, ensure_all_finite=False)
574+
x, d = check_X_y(x, self._g_data_subset, ensure_all_finite=False)
575575

576576
# get train indices for d == 0 and d == 1
577577
smpls_d0, smpls_d1 = _get_cond_smpls(smpls, d)

doubleml/did/did_cs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def _check_data(self, obj_dml_data):
212212
return
213213

214214
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
215-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
216-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
217-
x, t = check_X_y(x, self._dml_data.t, force_all_finite=False)
215+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
216+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
217+
x, t = check_X_y(x, self._dml_data.t, ensure_all_finite=False)
218218

219219
# THIS DIFFERS FROM THE PAPER due to stratified splitting this should be the same for each fold
220220
# nuisance estimates of the uncond. treatment prob.
@@ -547,9 +547,9 @@ def _sensitivity_element_est(self, preds):
547547
def _nuisance_tuning(
548548
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
549549
):
550-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
551-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
552-
x, t = check_X_y(x, self._dml_data.t, force_all_finite=False)
550+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
551+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
552+
x, t = check_X_y(x, self._dml_data.t, ensure_all_finite=False)
553553

554554
if scoring_methods is None:
555555
scoring_methods = {"ml_g": None, "ml_m": None}

doubleml/did/did_cs_binary.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ def _estimate_conditional_g(
435435
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
436436

437437
# Here: d is a binary treatment indicator
438-
x, y = check_X_y(X=self._x_data_subset, y=self._y_data_subset, force_all_finite=False)
439-
_, d = check_X_y(x, self._g_data_subset, force_all_finite=False) # (d is the G_indicator)
440-
_, t = check_X_y(x, self._t_data_subset, force_all_finite=False)
438+
x, y = check_X_y(X=self._x_data_subset, y=self._y_data_subset, ensure_all_finite=False)
439+
_, d = check_X_y(x, self._g_data_subset, ensure_all_finite=False) # (d is the G_indicator)
440+
_, t = check_X_y(x, self._t_data_subset, ensure_all_finite=False)
441441

442442
# THIS DIFFERS FROM THE PAPER due to stratified splitting this should be the same for each fold
443443
# nuisance estimates of the uncond. treatment prob.
@@ -621,9 +621,9 @@ def _score_elements(self, y, d, t, g_hat_d0_t0, g_hat_d0_t1, g_hat_d1_t0, g_hat_
621621
def _nuisance_tuning(
622622
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
623623
):
624-
x, y = check_X_y(X=self._x_data_subset, y=self._y_data_subset, force_all_finite=False)
625-
_, d = check_X_y(x, self._g_data_subset, force_all_finite=False) # (d is the G_indicator)
626-
_, t = check_X_y(x, self._t_data_subset, force_all_finite=False)
624+
x, y = check_X_y(X=self._x_data_subset, y=self._y_data_subset, ensure_all_finite=False)
625+
_, d = check_X_y(x, self._g_data_subset, ensure_all_finite=False) # (d is the G_indicator)
626+
_, t = check_X_y(x, self._t_data_subset, ensure_all_finite=False)
627627

628628
if scoring_methods is None:
629629
scoring_methods = {"ml_g": None, "ml_m": None}

doubleml/irm/apo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ def _get_weights(self):
208208
return weights, weights_bar
209209

210210
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
211-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
212-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
211+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
212+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
213213
dx = np.column_stack((d, x))
214214
# use the treated indicator to get the correct sample splits
215215
treated = self.treated
@@ -361,8 +361,8 @@ def _sensitivity_element_est(self, preds):
361361
def _nuisance_tuning(
362362
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
363363
):
364-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
365-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
364+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
365+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
366366
dx = np.column_stack((d, x))
367367
# use the treated indicator to get the correct sample splits
368368
treated = self.treated

doubleml/irm/cvar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ def _initialize_ml_nuisance_params(self):
204204
self._params = {learner: {key: [None] * self.n_rep for key in self._dml_data.d_cols} for learner in ["ml_g", "ml_m"]}
205205

206206
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
207-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
208-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
207+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
208+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
209209

210210
# initialize nuisance predictions, targets and models
211211
g_hat = {
@@ -330,8 +330,8 @@ def ipw_score(theta):
330330
def _nuisance_tuning(
331331
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
332332
):
333-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
334-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
333+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
334+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
335335

336336
if scoring_methods is None:
337337
scoring_methods = {"ml_g": None, "ml_m": None}

doubleml/irm/iivm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ def _check_data(self, obj_dml_data):
263263
return
264264

265265
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
266-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
267-
x, z = check_X_y(x, np.ravel(self._dml_data.z), force_all_finite=False)
268-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
266+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
267+
x, z = check_X_y(x, np.ravel(self._dml_data.z), ensure_all_finite=False)
268+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
269269

270270
# get train indices for z == 0 and z == 1
271271
smpls_z0, smpls_z1 = _get_cond_smpls(smpls, z)
@@ -448,9 +448,9 @@ def _score_elements(self, y, z, d, g_hat0, g_hat1, m_hat, r_hat0, r_hat1, smpls)
448448
def _nuisance_tuning(
449449
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
450450
):
451-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
452-
x, z = check_X_y(x, np.ravel(self._dml_data.z), force_all_finite=False)
453-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
451+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
452+
x, z = check_X_y(x, np.ravel(self._dml_data.z), ensure_all_finite=False)
453+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
454454

455455
# get train indices for z == 0 and z == 1
456456
smpls_z0, smpls_z1 = _get_cond_smpls(smpls, z)

doubleml/irm/irm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def _check_data(self, obj_dml_data):
261261
return
262262

263263
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
264-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
265-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
264+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
265+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
266266
# get train indices for d == 0 and d == 1
267267
smpls_d0, smpls_d1 = _get_cond_smpls(smpls, d)
268268
g0_external = external_predictions["ml_g0"] is not None
@@ -401,8 +401,8 @@ def _sensitivity_element_est(self, preds):
401401
def _nuisance_tuning(
402402
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
403403
):
404-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
405-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
404+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
405+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
406406
# get train indices for d == 0 and d == 1
407407
smpls_d0, smpls_d1 = _get_cond_smpls(smpls, d)
408408

doubleml/irm/lpq.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ def _initialize_ml_nuisance_params(self):
277277
}
278278

279279
def _nuisance_est(self, smpls, n_jobs_cv, external_predictions, return_models=False):
280-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
281-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
282-
x, z = check_X_y(x, np.ravel(self._dml_data.z), force_all_finite=False)
280+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
281+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
282+
x, z = check_X_y(x, np.ravel(self._dml_data.z), ensure_all_finite=False)
283283

284284
m_z = external_predictions["ml_m_z"] is not None
285285
m_d_d0 = external_predictions["ml_m_d_z0"] is not None
@@ -557,9 +557,9 @@ def ipw_score(theta):
557557
def _nuisance_tuning(
558558
self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv, search_mode, n_iter_randomized_search
559559
):
560-
x, y = check_X_y(self._dml_data.x, self._dml_data.y, force_all_finite=False)
561-
x, d = check_X_y(x, self._dml_data.d, force_all_finite=False)
562-
x, z = check_X_y(x, np.ravel(self._dml_data.z), force_all_finite=False)
560+
x, y = check_X_y(self._dml_data.x, self._dml_data.y, ensure_all_finite=False)
561+
x, d = check_X_y(x, self._dml_data.d, ensure_all_finite=False)
562+
x, z = check_X_y(x, np.ravel(self._dml_data.z), ensure_all_finite=False)
563563

564564
if scoring_methods is None:
565565
scoring_methods = {"ml_m_z": None, "ml_m_d_z0": None, "ml_m_d_z1": None, "ml_g_du_z0": None, "ml_g_du_z1": None}

0 commit comments

Comments
 (0)