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

✨ Implement len function for XbatcherSlicerIterDataPipe #75

Merged
merged 2 commits into from
Nov 22, 2022

Conversation

weiji14
Copy link
Owner

@weiji14 weiji14 commented Nov 22, 2022

Allow the number of chips from XbatcherSlicer datapipes to be calculated directly using len()!

Not previously implemented (see #22 (comment)) because it was inefficient in xbatcher, but xbatcher v0.2.0 has implemented lazy batch generation (see xarray-contrib/xbatcher#112) so this should be performant enough now.

TODO:

  • Implement __len__ in XbatcherSlicer
  • Update tutorials that previously used list comprehension, to instead call len(dp_xbatcher) directly.

References:

Allow the number of chips from XbatcherSlicer datapipes to be calculated directly using `len()`! Not previously implemented because it was inefficient in xbatcher, but xbatcher v0.2.0 has implemented lazy batch generation so this should be performant enough now. Also fixed an incorrect intersphinx link to xbatcher.BatchGenerator in the docstring.
@weiji14 weiji14 added the feature New feature or request label Nov 22, 2022
@weiji14 weiji14 added this to the 0.6.0 milestone Nov 22, 2022
@weiji14 weiji14 self-assigned this Nov 22, 2022
Previously turned the datapipes into a list to get the length, now it's possible to avoid the intermediate list representation!
@weiji14 weiji14 marked this pull request as ready for review November 22, 2022 20:43
@weiji14 weiji14 merged commit a97cad9 into main Nov 22, 2022
@weiji14 weiji14 deleted the xbatcher-len branch November 22, 2022 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant