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

RTDC_Hierarchy: Slicing of non-scalar features not working #128

Closed
maxschloegel opened this issue May 25, 2021 · 3 comments · Fixed by #131
Closed

RTDC_Hierarchy: Slicing of non-scalar features not working #128

maxschloegel opened this issue May 25, 2021 · 3 comments · Fixed by #131
Labels

Comments

@maxschloegel
Copy link
Contributor

Expected Behavior:

ds_c["image"][slice(start,stop,step)] returns slice of image array of child dataset ds_c between indices start and stop

Actual Behavior:

Attempt to get a slice of non-scalar features throws warning and only returns feature-entry of index start: ds_c["image"][start]

Warning:

venv/lib/python3.8/site-packages/dclab/rtdc_dataset/fmt_hierarchy.py:384: 
FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated;
use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index,
`arr[np.array(seq)]`, which will result either in an error or a different result.

Steps to reproduce the Behavior:

import dclab
filepath = 'path/to/file'
ds = dclab.new_dataset(filepath)
ds_c = dclab.new_dataset(ds)
ds_c["image"][:]
@paulmueller
Copy link
Member

Originally, slicing of image/contour/mask, etc. was not implemented because it was never necessary until now.

I am labeling this as a bug though, because the warning is definitely misleading.

@maxschloegel
Copy link
Contributor Author

While working on this issue I discovered that slicing on the contour-feature does not work the same way as it does for the other non-scalar features.
I assume this is due to the contour-data being managed via the dclab.features.contour.LazyContourList. When slicing, this lazylist returns None for every event that has not been explicitly called before.
As this seems to be a feature and not a bug, I propose to only implement slicing for the features mask,image,image_bg and trace of hierarchy-datasets and not for the contour-feature.

@paulmueller
Copy link
Member

Sounds good to me. I also don't see any application where anyone would need slicing of contours. For the sake of clarity, I would still suggest to raise a NotImplementedError if anyone tries to pass anything other than an integer value when trying to access a contour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants