This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_perceptual_axis_center_in_figure_space(fig, ax): | |
| xs = ax.get_xlim() | |
| if ax.get_xscale() == 'log': | |
| xs = np.log10(xs) | |
| c_x = sum(xs) / 2 | |
| c_x = 10**c_x | |
| else: | |
| c_x = sum(xs) / 2 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from pathlib import Path | |
| import h5py | |
| def resolve_name(f, name_ref): | |
| return ''.join([chr(i) for i in f[name_ref]]) | |
| def flat(x): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def extract(idxs, target): | |
| trailing_shape = target.shape[idxs.shape[1]:] | |
| flat_idxs = np.ravel_multi_index(idxs.T, target.shape[:idxs.shape[1]]) | |
| result_shape = (idxs.shape[0], ) + trailing_shape | |
| return target.reshape([-1, *trailing_shape])[flat_idxs].reshape(result_shape) |
NewerOlder