Skip to content

Commit 304d88f

Browse files
committed
Merge branch 'main' into 0.9.X
2 parents dddee3b + 92b057d commit 304d88f

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

doubleml/rdd/_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ def _is_rdrobust_available():
66
rdrobust = importlib.import_module("rdrobust")
77
return rdrobust
88
except ImportError:
9-
msg = (
10-
"rdrobust is not installed. "
11-
"Please install it using 'pip install DoubleML[rdd]'")
12-
raise ImportError(msg)
9+
return None

doubleml/rdd/rdd.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ def __init__(self,
108108
fs_kernel="triangular",
109109
**kwargs):
110110

111+
if rdrobust is None:
112+
msg = ("rdrobust is not installed. "
113+
"Please install it using 'pip install DoubleML[rdd]'")
114+
raise ImportError(msg)
115+
111116
self._check_data(obj_dml_data, cutoff)
112117
self._dml_data = obj_dml_data
113118

doubleml/rdd/tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def _predict_dummy(data: DoubleMLData, cutoff, alpha, n_rep, p, fs_specification
3838
dml_rdflex.fit(n_iterations=1)
3939
ci_manual = dml_rdflex.confint(level=1-alpha)
4040

41+
if rdrobust is None:
42+
msg = ("rdrobust is not installed. "
43+
"Please install it using 'pip install DoubleML[rdd]'")
44+
raise ImportError(msg)
45+
4146
rdrobust_model = rdrobust.rdrobust(
4247
y=data.y,
4348
x=data.s,

doubleml/rdd/tests/test_rdd_classifier.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
)
2222
dml_data = dml.DoubleMLData(df, y_col='y', d_cols='d', s_col='score')
2323

24-
dml_rdflex = RDFlex(dml_data, ml_g=LogisticRegression(), ml_m=LogisticRegression(), fuzzy=True)
25-
2624

2725
@pytest.mark.ci_rdd
2826
def test_rdd_classifier():
27+
dml_rdflex = RDFlex(dml_data, ml_g=LogisticRegression(), ml_m=LogisticRegression(), fuzzy=True)
2928
dml_rdflex.fit()

doubleml/rdd/tests/test_rdd_default_values.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
)
1919
dml_data = dml.DoubleMLData(df, y_col='y', d_cols='d', s_col='score')
2020

21-
dml_rdflex = RDFlex(dml_data, ml_g=Lasso(), ml_m=LogisticRegression())
22-
2321

2422
def _assert_resampling_default_settings(dml_obj):
2523
assert dml_obj.n_folds == 5
@@ -32,4 +30,5 @@ def _assert_resampling_default_settings(dml_obj):
3230

3331
@pytest.mark.ci_rdd
3432
def test_rdd_defaults():
33+
dml_rdflex = RDFlex(dml_data, ml_g=Lasso(), ml_m=LogisticRegression())
3534
_assert_resampling_default_settings(dml_rdflex)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pytest
22
from unittest.mock import patch
33

4-
from doubleml.rdd._utils import _is_rdrobust_available
4+
import doubleml as dml
55

66

7+
@pytest.mark.ci
78
def test_rdrobust_import_error():
8-
with patch('importlib.import_module', side_effect=ImportError):
9+
with patch('doubleml.rdd.rdd.rdrobust', None):
910
msg = r"rdrobust is not installed. Please install it using 'pip install DoubleML\[rdd\]'"
1011
with pytest.raises(ImportError, match=msg):
11-
_is_rdrobust_available()
12+
dml.rdd.RDFlex(None, None)

doubleml/rdd/tests/test_rdd_return_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
)
1919
dml_data = dml.DoubleMLData(df, y_col='y', d_cols='d', s_col='score')
2020

21-
dml_rdflex = RDFlex(dml_data, ml_g=Lasso(), ml_m=LogisticRegression())
22-
2321

2422
def _assert_return_types(dml_obj):
2523
assert isinstance(dml_obj.n_folds, int)
@@ -52,5 +50,7 @@ def _assert_return_types_after_fit(dml_obj):
5250

5351
@pytest.mark.ci_rdd
5452
def test_rdd_returntypes():
53+
dml_rdflex = RDFlex(dml_data, ml_g=Lasso(), ml_m=LogisticRegression())
54+
5555
_assert_return_types(dml_rdflex)
5656
_assert_return_types_after_fit(dml_rdflex)

0 commit comments

Comments
 (0)