@@ -140,6 +140,7 @@ def test_dml_blp_defaults():
140140 random_signal = np .random .normal (0 , 1 , size = (n ,))
141141
142142 blp = dml .DoubleMLBLP (random_signal , random_basis )
143+ assert blp .blp_omega is None
143144 blp .fit ()
144145
145146 assert np .allclose (blp .blp_omega [:, :, 0 ], blp .blp_model [0 ].cov_HC0 , rtol = 1e-9 , atol = 1e-4 )
@@ -151,6 +152,7 @@ def test_dml_blp_defaults():
151152def test_doubleml_exception_blp ():
152153 random_basis = pd .DataFrame (np .random .normal (0 , 1 , size = (2 , 3 )))
153154 signal = np .array ([1 , 2 ])
155+ signal_mismatch = np .array ([1 , 2 , 3 ])
154156
155157 msg = "The signal must be of np.ndarray type. Signal of type <class 'int'> was passed."
156158 with pytest .raises (TypeError , match = msg ):
@@ -161,6 +163,9 @@ def test_doubleml_exception_blp():
161163 msg = "The basis must be of DataFrame type. Basis of type <class 'int'> was passed."
162164 with pytest .raises (TypeError , match = msg ):
163165 dml .DoubleMLBLP (orth_signal = signal , basis = 1 )
166+ msg = "The number of observations in signal and basis does not match. Got 3 and 2."
167+ with pytest .raises (ValueError , match = msg ):
168+ dml .DoubleMLBLP (orth_signal = signal_mismatch , basis = random_basis )
164169 msg = "Invalid pd.DataFrame: Contains duplicate column names."
165170 with pytest .raises (ValueError , match = msg ):
166171 dml .DoubleMLBLP (orth_signal = signal , basis = pd .DataFrame (np .array ([[1 , 2 ], [4 , 5 ]]), columns = ["a_1" , "a_1" ]))
@@ -186,6 +191,9 @@ def test_doubleml_exception_blp():
186191 msg = "The number of bootstrap replications must be positive. 0 was passed."
187192 with pytest .raises (ValueError , match = msg ):
188193 dml_blp_confint .confint (random_basis , n_rep_boot = 0 )
194+ msg = "The basis must be of DataFrame type. Basis of type <class 'int'> was passed."
195+ with pytest .raises (TypeError , match = msg ):
196+ dml_blp_confint .confint (basis = 1 )
189197 msg = "Invalid basis: DataFrame has to have the exact same number and ordering of columns."
190198 with pytest .raises (ValueError , match = msg ):
191199 dml_blp_confint .confint (basis = pd .DataFrame (np .array ([[1 ], [4 ]]), columns = ["a_1" ]))
0 commit comments