Skip to content
This repository was archived by the owner on Jul 2, 2021. It is now read-only.

Support keys assign in GetterDataset #571

Merged

Conversation

Hakuyume
Copy link
Member

@Hakuyume Hakuyume commented Apr 17, 2018

cherry-picked from #457

@Hakuyume Hakuyume mentioned this pull request Apr 17, 2018
for key in keys:
if isinstance(key, int):
key_index = key
if key_index >= len(self._keys):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

if key_index < 0:
    key_index += len(self._keys)
if key_index >= len(self._keys) or key_index < 0:
    raise IndexError('index {} is out of bounds for keys with size {}'.format(key, len(self._keys))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message would be similar to NumPy.

@yuyu2172 yuyu2172 added this to the v0.9 milestone Apr 18, 2018
@yuyu2172
Copy link
Member

LGTM

@yuyu2172 yuyu2172 merged commit e1302fa into chainer:master Apr 18, 2018
@Hakuyume Hakuyume deleted the support-keys-assign-in-getter-dataset branch April 18, 2018 07:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants