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 | """ |
||
74 | def display_basic_stats(self): |
||
75 | """Display basic statistics of array""" |
||
76 | pstr_list = [] |
||
77 | |||
78 | # Heading for Section |
||
79 | |||
80 | pstr_struct_header1 = '\033[1m' + "Basic Statistics " + '\033[0m' |
||
81 | pstr_struct_header2 = '' |
||
82 | |||
83 | pstr_list.append(pstr_struct_header1) |
||
84 | pstr_list.append(pstr_struct_header2) |
||
85 | |||
86 | # Mean and Standard Deviation |
||
87 | |||
88 | pstr_meanstdhead = ( |
||
89 | "{0:^15}" |
||
90 | "{1:^15}" |
||
91 | ).format("Mean", "Std Dev") |
||
92 | pstr_meanstdhead = ( |
||
93 | "{0:^{self.col_width}}" |
||
94 | ).format(pstr_meanstdhead, self=self) |
||
95 | pstr_list.append(pstr_meanstdhead) |
||
96 | |||
97 | pstr_meanstdstat = ( |
||
98 | "{self.mean:^15.{self.precision}}" |
||
99 | "{self.std:^15.{self.precision}}" |
||
100 | ).format(self=self) |
||
101 | pstr_meanstdstat = ( |
||
102 | "{0:^{self.col_width}}" |
||
103 | ).format(pstr_meanstdstat, self=self) |
||
104 | pstr_list.append(pstr_meanstdstat) |
||
105 | |||
106 | pstr_list.append("") |
||
107 | |||
108 | # Three point statistics |
||
109 | |||
110 | pstr_3pthead = ( |
||
111 | "{0:^10}" |
||
112 | "{1:^10}" |
||
113 | "{2:^10}" |
||
114 | "{3:^10}" |
||
115 | "{4:^10}" |
||
116 | ).format('Min,', '1Q', 'Median', '3Q', 'Max') |
||
117 | pstr_3pthead = ( |
||
118 | "{0:^{self.col_width}}" |
||
119 | ).format(pstr_3pthead, self=self) |
||
120 | pstr_list.append(pstr_3pthead) |
||
121 | |||
122 | pstr_3ptstat = ( |
||
123 | "{self.min:^10.{self.precision}}" |
||
124 | "{self.firstquartile:^10.{self.precision}}" |
||
125 | "{self.median:^10.{self.precision}}" |
||
126 | "{self.thirdquartile:^10.{self.precision}}" |
||
127 | "{self.max:^10.{self.precision}}" |
||
128 | ).format(self=self) |
||
129 | pstr_3ptstat = ( |
||
130 | "{0:^{self.col_width}}" |
||
131 | ).format(pstr_3ptstat, self=self) |
||
132 | pstr_list.append(pstr_3ptstat) |
||
133 | |||
134 | pstr_list.append("") |
||
135 | |||
136 | # Confidence Levels |
||
137 | |||
138 | pstr_clhead = ( |
||
139 | "{0:^10}" |
||
140 | "{1:^10}" |
||
141 | "{2:^10}" |
||
142 | "{3:^10}" |
||
143 | "{4:^10}" |
||
144 | "{5:^10}" |
||
145 | ).format('-99 CL', '-95 CL', '-68 CL', '+68 CL', '+95 CL', '+99 CL') |
||
146 | pstr_clhead = ( |
||
147 | "{0:^{self.col_width}}" |
||
148 | ).format(pstr_clhead, self=self) |
||
149 | pstr_list.append(pstr_clhead) |
||
150 | |||
151 | pstr_clstat = ( |
||
152 | "{self.cl_99[0]:^10.{self.precision}}" |
||
153 | "{self.cl_95[0]:^10.{self.precision}}" |
||
154 | "{self.cl_68[0]:^10.{self.precision}}" |
||
155 | "{self.cl_68[1]:^10.{self.precision}}" |
||
156 | "{self.cl_95[1]:^10.{self.precision}}" |
||
157 | "{self.cl_99[1]:^10.{self.precision}}" |
||
158 | ).format(self=self) |
||
159 | pstr_clstat = ( |
||
160 | "{0:^{self.col_width}}" |
||
161 | ).format(pstr_clstat, self=self) |
||
162 | pstr_list.append(pstr_clstat) |
||
163 | |||
164 | return pstr_list |
||
165 | |||
294 |