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 | self.ci_99 = np.float_( |
||
89 | np.percentile(self.filt_data, np.array([0.5, 99.5]))) |
||
90 | self.ci_95 = np.float_( |
||
91 | np.percentile(self.filt_data, np.array([2.5, 97.5]))) |
||
92 | self.ci_68 = np.float_( |
||
93 | np.percentile(self.filt_data, np.array([16.0, 84.0]))) |
||
94 | |||
95 | def display_basic_stats_new(self): |
||
96 | """Display Basic Statistics""" |
||
97 | pstr_list = [] |
||
98 | |||
99 | pstr_struct_header1 = "Basic Statistics " |
||
100 | pstr_struct_header2 = '' |
||
101 | |||
102 | pstr_list.append(pstr_struct_header1) |
||
103 | pstr_list.append(pstr_struct_header2) |
||
104 | |||
105 | template_str = ( |
||
106 | " {0:^10} " |
||
107 | " {1:>8} " |
||
108 | " {2:<10} " |
||
109 | " {3:>8} " |
||
110 | " {4:<10} " |
||
111 | ) |
||
112 | |||
113 | tmp_data = [ |
||
114 | [ |
||
115 | "Mean:", "{self.mean:.{self.precision}}".format(self=self), |
||
116 | "", |
||
117 | "Std Dev:", "{self.std:.{self.precision}}".format(self=self) |
||
118 | ], |
||
119 | ["Min:", "1Q:", "Median:", "3Q:", "Max:"], |
||
120 | [ |
||
121 | "{self.min: .{self.precision}}".format(self=self), |
||
122 | "{self.firstquartile: .{self.precision}}".format(self=self), |
||
123 | "{self.median: .{self.precision}}".format(self=self), |
||
124 | "{self.thirdquartile: .{self.precision}}".format(self=self), |
||
125 | "{self.max: .{self.precision}}".format(self=self), |
||
126 | ], |
||
127 | ['-99 CI:', '-95 CI:', '-68 CI:', '+68 CI:', '+95 CI:', '+99 CI:'], |
||
128 | [ |
||
129 | "{self.ci_99[0]: .{self.precision}}".format(self=self), |
||
130 | "{self.ci_95[0]: .{self.precision}}".format(self=self), |
||
131 | "{self.ci_68[0]: .{self.precision}}".format(self=self), |
||
132 | "{self.ci_68[1]: .{self.precision}}".format(self=self), |
||
133 | "{self.ci_95[1]: .{self.precision}}".format(self=self), |
||
134 | "{self.ci_99[1]: .{self.precision}}".format(self=self), |
||
135 | ], |
||
136 | ] |
||
137 | |||
138 | n_tmp_data = len(tmp_data) |
||
139 | |||
140 | num_rows_in_cols = [len(i) for i in tmp_data] |
||
141 | num_rows = np.max(num_rows_in_cols) |
||
142 | |||
143 | for i in range(n_tmp_data): |
||
144 | tmp_col = tmp_data[i] |
||
145 | for j in range(num_rows_in_cols[i], num_rows): |
||
146 | tmp_col.append("") |
||
147 | |||
148 | for i in range(num_rows): |
||
149 | pstr_list.append( |
||
150 | template_str.format( |
||
151 | tmp_data[0][i], |
||
152 | tmp_data[1][i], |
||
153 | tmp_data[2][i], |
||
154 | tmp_data[3][i], |
||
155 | tmp_data[4][i], |
||
156 | ) |
||
157 | ) |
||
158 | |||
159 | return pstr_list |
||
160 | |||
161 | def display_struct(self): |
||
162 | """Display information about array structure""" |
||
163 | |||
164 | pstr_list = [] |
||
165 | |||
166 | # pstr_struct_header0 = "................." |
||
167 | # Commenting out Ansi Coloured Version |
||
168 | # pstr_struct_header1 = '\033[1m' + "Array Structure " + '\033[0m' |
||
169 | pstr_struct_header1 = "Array Structure " |
||
170 | pstr_struct_header2 = " " |
||
171 | |||
172 | # pstr_list.append(pstr_struct_header0) |
||
173 | pstr_list.append(pstr_struct_header1) |
||
174 | pstr_list.append(pstr_struct_header2) |
||
175 | |||
176 | pstr_n_dim = ( |
||
177 | "Number of Dimensions:\t" |
||
178 | "{self.ndim}").format( |
||
179 | self=self) |
||
306 |