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

Maybe change PadoDataset.__getitem__ exceptions #18

Open
ap-- opened this issue Sep 21, 2022 · 0 comments
Open

Maybe change PadoDataset.__getitem__ exceptions #18

ap-- opened this issue Sep 21, 2022 · 0 comments
Labels
🚧 refactor Requires refactoring / redesign

Comments

@ap--
Copy link
Contributor

ap-- commented Sep 21, 2022

We provide a Mapping[ImageId, PadoItem] interface with __getitem__ and __len__
in which we correctly (and intuitively) raise KeyError(image_id)

Now additionally we'd like to provide a Sequence[PadoItem] interface, again via __getitem__ and __len__ and again correctly (and to me intuitively) raise IndexError(int_idx)

If the two are merged (as it is now), the user must understand which Exception to catch when using either integer indexing or ImageId indexing (i.e. the Sequence interface or the Mapping interface).

While intuitive to some, this behavior might confuse people who haven't read the collections.abc module a few times. Which is why I believe there's value in separating the two interfaces explicity.

So maybe offer Mapping[ImageId, PadoItem] on the dataset, and Sequence[PadoItem] via a proxy attribute.

@ap-- ap-- added the 🚧 refactor Requires refactoring / redesign label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 refactor Requires refactoring / redesign
Projects
None yet
Development

No branches or pull requests

1 participant