Skip to content
Snippets Groups Projects

Fixed the plot slicing bug (see issue #) by changing the slice_closest...

Merged Anton Akhmerov requested to merge fix-plotting into master
1 file
+ 6
22
Compare changes
  • Side-by-side
  • Inline
+ 6
22
@@ -428,31 +428,15 @@ def slice_closest(slice_coord, direction, values_coord, tol=1e-12):
axis = np.arange(0, values_coord.shape[1], dtype=int)
axis = axis[np.logical_not(np.isin(axis, direction))]
ref_coord = values_coord[:, axis]
coord_sliced_dir = values_coord[:, direction]
def fun(val):
if len(direction) > 1:
dist = np.sqrt(np.sum(
(coord_sliced_dir - val) ** 2, axis=1))
map_ = (np.abs(
coord_sliced_dir
- coord_sliced_dir[np.argmin(dist)]) < tol)
map_ = map_[:, 0] * map_[:, 1]
else:
dist = np.abs(coord_sliced_dir - val)
map_ = (np.abs(
coord_sliced_dir
- coord_sliced_dir[np.argmin(dist)]) < tol)[:, 0]
if np.all(np.logical_not(map_)):
raise RuntimeError(
'No coordinate found for {c}'.format(val))
idx = np.arange(len(ref_coord), dtype=int)[map_]
return idx[KDTree(ref_coord[idx]).query(slice_coord)[1]]
full_slice_coord = np.empty((slice_coord.shape[0], values_coord.shape[1]), dtype=float)
full_slice_coord[:,axis] = slice_coord
full_slice_coord[:,direction] = val
return KDTree(values_coord).query(full_slice_coord)[1]#idx[KDTree(ref_coord[idx]).query(slice_coord)[1]]
return fun
Loading