Conditions | 1 |
Total Lines | 91 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | """ |
||
88 | def display_basic_stats(self): |
||
89 | """Display basic statistics of array""" |
||
90 | pstr_list = [] |
||
91 | |||
92 | # Heading for Section |
||
93 | |||
94 | pstr_struct_header1 = '\033[1m' + "Basic Statistics " + '\033[0m' |
||
95 | pstr_struct_header2 = '' |
||
96 | |||
97 | pstr_list.append(pstr_struct_header1) |
||
98 | pstr_list.append(pstr_struct_header2) |
||
99 | |||
100 | # Mean and Standard Deviation |
||
101 | |||
102 | pstr_meanstdhead = ( |
||
103 | "{0:^15}" |
||
104 | "{1:^15}" |
||
105 | ).format("Mean", "Std Dev") |
||
106 | pstr_meanstdhead = ( |
||
107 | "{0:^{self.col_width}}" |
||
108 | ).format(pstr_meanstdhead, self=self) |
||
109 | pstr_list.append(pstr_meanstdhead) |
||
110 | |||
111 | pstr_meanstdstat = ( |
||
112 | "{self.mean:^15.{self.precision}}" |
||
113 | "{self.std:^15.{self.precision}}" |
||
114 | ).format(self=self) |
||
115 | pstr_meanstdstat = ( |
||
116 | "{0:^{self.col_width}}" |
||
117 | ).format(pstr_meanstdstat, self=self) |
||
118 | pstr_list.append(pstr_meanstdstat) |
||
119 | |||
120 | pstr_list.append("") |
||
121 | |||
122 | # Three point statistics |
||
123 | |||
124 | pstr_3pthead = ( |
||
125 | "{0:^10}" |
||
126 | "{1:^10}" |
||
127 | "{2:^10}" |
||
128 | "{3:^10}" |
||
129 | "{4:^10}" |
||
130 | ).format('Min', '1Q', 'Median', '3Q', 'Max') |
||
131 | pstr_3pthead = ( |
||
132 | "{0:^{self.col_width}}" |
||
133 | ).format(pstr_3pthead, self=self) |
||
134 | pstr_list.append(pstr_3pthead) |
||
135 | |||
136 | pstr_3ptstat = ( |
||
137 | "{self.min:^10.{self.precision}}" |
||
138 | "{self.firstquartile:^10.{self.precision}}" |
||
139 | "{self.median:^10.{self.precision}}" |
||
140 | "{self.thirdquartile:^10.{self.precision}}" |
||
141 | "{self.max:^10.{self.precision}}" |
||
142 | ).format(self=self) |
||
143 | pstr_3ptstat = ( |
||
144 | "{0:^{self.col_width}}" |
||
145 | ).format(pstr_3ptstat, self=self) |
||
146 | pstr_list.append(pstr_3ptstat) |
||
147 | |||
148 | pstr_list.append("") |
||
149 | |||
150 | # Confidence Levels |
||
151 | |||
152 | pstr_clhead = ( |
||
153 | "{0:^10}" |
||
154 | "{1:^10}" |
||
155 | "{2:^10}" |
||
156 | "{3:^10}" |
||
157 | "{4:^10}" |
||
158 | "{5:^10}" |
||
159 | ).format('-99 CL', '-95 CL', '-68 CL', '+68 CL', '+95 CL', '+99 CL') |
||
160 | pstr_clhead = ( |
||
161 | "{0:^{self.col_width}}" |
||
162 | ).format(pstr_clhead, self=self) |
||
163 | pstr_list.append(pstr_clhead) |
||
164 | |||
165 | pstr_clstat = ( |
||
166 | "{self.cl_99[0]:^10.{self.precision}}" |
||
167 | "{self.cl_95[0]:^10.{self.precision}}" |
||
168 | "{self.cl_68[0]:^10.{self.precision}}" |
||
169 | "{self.cl_68[1]:^10.{self.precision}}" |
||
170 | "{self.cl_95[1]:^10.{self.precision}}" |
||
171 | "{self.cl_99[1]:^10.{self.precision}}" |
||
172 | ).format(self=self) |
||
173 | pstr_clstat = ( |
||
174 | "{0:^{self.col_width}}" |
||
175 | ).format(pstr_clstat, self=self) |
||
176 | pstr_list.append(pstr_clstat) |
||
177 | |||
178 | return pstr_list |
||
179 | |||
308 |