@@ -127,6 +127,89 @@ def test_data_adequacy_group_by(self):
127127 self .assertEqual (adequacy_metric .passing , 32 , f"Expected passing 32 not { adequacy_metric .passing } " )
128128 self .assertEqual (adequacy_metric .successful , 100 , f"Expected successful 100 not { adequacy_metric .successful } " )
129129
130+ def test_to_dict (self ):
131+ estimator = LinearRegressionEstimator (
132+ treatment_variable = "test_input" , outcome_variable = "test_output" , adjustment_set = set ()
133+ )
134+ causal_test_case = CausalTestCase (
135+ expected_causal_effect = NoEffect (atol = 1e-10 ),
136+ effect_measure = "coefficient" ,
137+ estimator = estimator ,
138+ )
139+ adequacy_metric = causal_test_case .measure_adequacy (self .df , bootstrap_size = 10 )
140+
141+ self .assertEqual (
142+ adequacy_metric .to_dict (include_results = True ),
143+ {
144+ "kurtosis" : {"test_input" : 0.0 },
145+ "passing" : 10 ,
146+ "successful" : 10 ,
147+ "results" : {
148+ "effect_estimate" : {
149+ 0 : - 2.220446049250313e-16 ,
150+ 1 : - 1.1102230246251565e-16 ,
151+ 2 : 7.632783294297951e-17 ,
152+ 3 : 5.551115123125783e-17 ,
153+ 4 : 6.938893903907228e-17 ,
154+ 5 : 5.551115123125783e-17 ,
155+ 6 : 4.163336342344337e-17 ,
156+ 7 : - 1.6653345369377348e-16 ,
157+ 8 : 3.469446951953614e-17 ,
158+ 9 : - 1.3877787807814457e-16 ,
159+ },
160+ "ci_low" : {
161+ 0 : - 7.771553129157294e-16 ,
162+ 1 : - 2.279269223868238e-16 ,
163+ 2 : - 1.8906584687236155e-16 ,
164+ 3 : - 1.57411847966069e-16 ,
165+ 4 : - 3.27696708597398e-17 ,
166+ 5 : 2.3327440223904727e-17 ,
167+ 6 : - 6.643195454332691e-19 ,
168+ 7 : - 3.158788196765981e-16 ,
169+ 8 : - 1.878128765814627e-16 ,
170+ 9 : - 3.348328858540416e-16 ,
171+ },
172+ "ci_high" : {
173+ 0 : 3.3306610306566683e-16 ,
174+ 1 : 5.8823174617924694e-18 ,
175+ 2 : 3.4172151275832057e-16 ,
176+ 3 : 2.6843415042858463e-16 ,
177+ 4 : 1.7154754893788438e-16 ,
178+ 5 : 8.769486223861093e-17 ,
179+ 6 : 8.393104639232001e-17 ,
180+ 7 : - 1.718808771094884e-17 ,
181+ 8 : 2.57201815620535e-16 ,
182+ 9 : 5.727712969775247e-17 ,
183+ },
184+ "test_index" : {0 : 0 , 1 : 1 , 2 : 2 , 3 : 3 , 4 : 4 , 5 : 5 , 6 : 6 , 7 : 7 , 8 : 8 , 9 : 9 },
185+ "passed" : {
186+ 0 : True ,
187+ 1 : True ,
188+ 2 : True ,
189+ 3 : True ,
190+ 4 : True ,
191+ 5 : True ,
192+ 6 : True ,
193+ 7 : True ,
194+ 8 : True ,
195+ 9 : True ,
196+ },
197+ "var" : {
198+ 0 : "test_input" ,
199+ 1 : "test_input" ,
200+ 2 : "test_input" ,
201+ 3 : "test_input" ,
202+ 4 : "test_input" ,
203+ 5 : "test_input" ,
204+ 6 : "test_input" ,
205+ 7 : "test_input" ,
206+ 8 : "test_input" ,
207+ 9 : "test_input" ,
208+ },
209+ },
210+ },
211+ )
212+
130213 def test_dag_adequacy_dependent (self ):
131214 causal_test_case = CausalTestCase (
132215 estimator = LinearRegressionEstimator (
0 commit comments