Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a problem where linked selections were resulting in repeated columns #6336

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions holoviews/element/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ def _get_index_selection(self, index, index_cols):
self._index_skip = True
if not index:
return None, None, None
ds = self.clone(kdims=index_cols, new_type=Dataset)
clone_vdims = [vdim.name for vdim in self.vdims if vdim.name not in index_cols]
cols = clone_vdims + index_cols
ds = self.clone(kdims=index_cols, vdims=clone_vdims, new_type=Dataset)
if len(index_cols) == 1:
index_dim = index_cols[0]
vals = dim(index_dim).apply(ds.iloc[index], expanded=False)
vals = dim(index_dim).apply(ds.iloc[index, cols], expanded=False)
if vals.dtype.kind == 'O' and all(isinstance(v, np.ndarray) for v in vals):
vals = [v for arr in vals for v in util.unique_iterator(arr)]
expr = dim(index_dim).isin(list(util.unique_iterator(vals)))
else:
get_shape = dim(self.dataset.get_dimension(index_cols[0]), np.shape)
index_cols = [dim(self.dataset.get_dimension(c), np.ravel) for c in index_cols]
vals = dim(index_cols[0], util.unique_zip, *index_cols[1:]).apply(
ds.iloc[index], expanded=True, flat=True
ds.iloc[index, cols], expanded=True, flat=True
)
contains = dim(index_cols[0], util.lzip, *index_cols[1:]).isin(vals, object=True)
expr = dim(contains, np.reshape, get_shape)
Expand Down