Print the mean, min, max, median, std, and size of a numpy array Parameters: val (bool) -- if print the values of the numpy array shp (bool) -- if print the shape of the numpy array
(x, val=True, shp=False)
| 67 | |
| 68 | |
| 69 | def print_numpy(x, val=True, shp=False): |
| 70 | """Print the mean, min, max, median, std, and size of a numpy array |
| 71 | |
| 72 | Parameters: |
| 73 | val (bool) -- if print the values of the numpy array |
| 74 | shp (bool) -- if print the shape of the numpy array |
| 75 | """ |
| 76 | x = x.astype(np.float64) |
| 77 | if shp: |
| 78 | print('shape,', x.shape) |
| 79 | if val: |
| 80 | x = x.flatten() |
| 81 | print('mean = %3.3f, min = %3.3f, max = %3.3f, median = %3.3f, std=%3.3f' % ( |
| 82 | np.mean(x), np.min(x), np.max(x), np.median(x), np.std(x))) |
| 83 | |
| 84 | |
| 85 | def mkdirs(paths): |