@@ -138,76 +138,78 @@ def test_to_dict(self):
138138 )
139139 adequacy_metric = causal_test_case .measure_adequacy (self .df , bootstrap_size = 10 )
140140
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- },
141+ expected_dict = {
142+ "kurtosis" : {"test_input" : 0.0 },
143+ "passing" : 10 ,
144+ "successful" : 10 ,
145+ "results" : {
146+ "effect_estimate" : {
147+ 0 : - 2.220446049250313e-16 ,
148+ 1 : - 1.1102230246251565e-16 ,
149+ 2 : 7.632783294297951e-17 ,
150+ 3 : 5.551115123125783e-17 ,
151+ 4 : 6.938893903907228e-17 ,
152+ 5 : 5.551115123125783e-17 ,
153+ 6 : 4.163336342344337e-17 ,
154+ 7 : - 1.6653345369377348e-16 ,
155+ 8 : 3.469446951953614e-17 ,
156+ 9 : - 1.3877787807814457e-16 ,
157+ },
158+ "ci_low" : {
159+ 0 : - 7.771553129157294e-16 ,
160+ 1 : - 2.279269223868238e-16 ,
161+ 2 : - 1.8906584687236155e-16 ,
162+ 3 : - 1.57411847966069e-16 ,
163+ 4 : - 3.27696708597398e-17 ,
164+ 5 : 2.3327440223904727e-17 ,
165+ 6 : - 6.643195454332691e-19 ,
166+ 7 : - 3.158788196765981e-16 ,
167+ 8 : - 1.878128765814627e-16 ,
168+ 9 : - 3.348328858540416e-16 ,
169+ },
170+ "ci_high" : {
171+ 0 : 3.3306610306566683e-16 ,
172+ 1 : 5.8823174617924694e-18 ,
173+ 2 : 3.4172151275832057e-16 ,
174+ 3 : 2.6843415042858463e-16 ,
175+ 4 : 1.7154754893788438e-16 ,
176+ 5 : 8.769486223861093e-17 ,
177+ 6 : 8.393104639232001e-17 ,
178+ 7 : - 1.718808771094884e-17 ,
179+ 8 : 2.57201815620535e-16 ,
180+ 9 : 5.727712969775247e-17 ,
181+ },
182+ "test_index" : {0 : 0 , 1 : 1 , 2 : 2 , 3 : 3 , 4 : 4 , 5 : 5 , 6 : 6 , 7 : 7 , 8 : 8 , 9 : 9 },
183+ "passed" : {
184+ 0 : True ,
185+ 1 : True ,
186+ 2 : True ,
187+ 3 : True ,
188+ 4 : True ,
189+ 5 : True ,
190+ 6 : True ,
191+ 7 : True ,
192+ 8 : True ,
193+ 9 : True ,
194+ },
195+ "var" : {
196+ 0 : "test_input" ,
197+ 1 : "test_input" ,
198+ 2 : "test_input" ,
199+ 3 : "test_input" ,
200+ 4 : "test_input" ,
201+ 5 : "test_input" ,
202+ 6 : "test_input" ,
203+ 7 : "test_input" ,
204+ 8 : "test_input" ,
205+ 9 : "test_input" ,
209206 },
210207 },
208+ }
209+ # Use json_normalize to avoid rounding errors
210+ pd .testing .assert_frame_equal (
211+ pd .json_normalize (expected_dict ).round (2 ),
212+ pd .json_normalize (adequacy_metric .to_dict (include_results = True )).round (2 ),
211213 )
212214
213215 def test_dag_adequacy_dependent (self ):
0 commit comments