Skip to content

Commit

Permalink
Fix iterator increment (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Jun 12, 2024
1 parent ece2c27 commit d756abe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# HDMF Changelog

## HDMF 3.14.2 (???)

### Bug fixes
- Fix iterator increment causing an extra +1 added after the end of completion. @CodyCBakerPhD [#1128](https://github.com/hdmf-dev/hdmf/pull/1128)



## HDMF 3.14.1 (June 6, 2024)

### Bug fixes
Expand Down
10 changes: 7 additions & 3 deletions src/hdmf/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,18 @@ def __next__(self):
:returns: DataChunk object with the data and selection of the current buffer.
:rtype: DataChunk
"""
if self.display_progress:
self.progress_bar.update(n=1)
try:
buffer_selection = next(self.buffer_selection_generator)

# Only update after successful iteration
if self.display_progress:
self.progress_bar.update(n=1)

return DataChunk(data=self._get_data(selection=buffer_selection), selection=buffer_selection)
except StopIteration:
# Allow text to be written to new lines after completion
if self.display_progress:
self.progress_bar.write("\n") # Allows text to be written to new lines after completion
self.progress_bar.write("\n")
raise StopIteration

def __reduce__(self) -> Tuple[Callable, Iterable]:
Expand Down

0 comments on commit d756abe

Please sign in to comment.