@@ -102,14 +102,20 @@ def print_coefficients(self, round_to=None) -> None:
102102 ... "progressbar": False
103103 ... }),
104104 ... )
105- >>> result.print_coefficients(round_to=1) # doctest: +NUMBER
105+ >>> result.print_coefficients(round_to=1)
106106 Model coefficients:
107- Intercept 1, 94% HDI [1, 1]
108- post_treatment[T.True] 1, 94% HDI [0.9, 1]
109- group 0.2, 94% HDI [0.09, 0.2]
110- group:post_treatment[T.True] 0.5, 94% HDI [0.4, 0.6]
111- sigma 0.08, 94% HDI [0.07, 0.1]
107+ Intercept 1, 94% HDI [1, 1]
108+ post_treatment[T.True] 1, 94% HDI [0.9, 1]
109+ group 0.2, 94% HDI [0.09, 0.2]
110+ group:post_treatment[T.True] 0.5, 94% HDI [0.4, 0.6]
111+ sigma 0.08, 94% HDI [0.07, 0.1]
112112 """
113+
114+ def print_row (max_label_length , name , coeff_samples , round_to ):
115+ formatted_name = f" { name : <{max_label_length }} "
116+ formatted_val = f"{ round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
117+ print (f" { formatted_name } { formatted_val } " )
118+
113119 print ("Model coefficients:" )
114120 coeffs = az .extract (self .idata .posterior , var_names = "beta" )
115121
@@ -118,16 +124,12 @@ def print_coefficients(self, round_to=None) -> None:
118124
119125 for name in self .labels :
120126 coeff_samples = coeffs .sel (coeffs = name )
121- print (
122- f" { name : <{max_label_length }} \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
123- )
127+ print_row (max_label_length , name , coeff_samples , round_to )
124128
125129 # Add coefficient for measurement std
126130 coeff_samples = az .extract (self .model .idata .posterior , var_names = "sigma" )
127131 name = "sigma"
128- print (
129- f" { name : <{max_label_length }} \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
130- )
132+ print_row (max_label_length , name , coeff_samples , round_to )
131133
132134
133135class PrePostFit (ExperimentalDesign , PrePostFitDataValidator ):
@@ -163,13 +165,13 @@ class PrePostFit(ExperimentalDesign, PrePostFitDataValidator):
163165 ... }
164166 ... ),
165167 ... )
166- >>> result.summary(round_to=1) # doctest: +NUMBER
168+ >>> result.summary(round_to=1)
167169 ==================================Pre-Post Fit==================================
168170 Formula: actual ~ 0 + a + g
169171 Model coefficients:
170- a 0.6, 94% HDI [0.6, 0.6]
171- g 0.4, 94% HDI [0.4, 0.4]
172- sigma 0.8, 94% HDI [0.6, 0.9]
172+ a 0.6, 94% HDI [0.6, 0.6]
173+ g 0.4, 94% HDI [0.4, 0.4]
174+ sigma 0.8, 94% HDI [0.6, 0.9]
173175 """
174176
175177 def __init__ (
@@ -1184,10 +1186,10 @@ class PrePostNEGD(ExperimentalDesign, PrePostNEGDDataValidator):
11841186 Results:
11851187 Causal impact = 2, $CI_{94%}$[2, 2]
11861188 Model coefficients:
1187- Intercept -0.5, 94% HDI [-1, 0.2]
1188- C(group)[T.1] 2, 94% HDI [2, 2]
1189- pre 1, 94% HDI [1, 1]
1190- sigma 0.5, 94% HDI [0.5, 0.6]
1189+ Intercept -0.5, 94% HDI [-1, 0.2]
1190+ C(group)[T.1] 2, 94% HDI [2, 2]
1191+ pre 1, 94% HDI [1, 1]
1192+ sigma 0.5, 94% HDI [0.5, 0.6]
11911193 """
11921194
11931195 def __init__ (
0 commit comments