Skip to content

Commit

Permalink
Use pandas iloc values for chunks and splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow committed Dec 1, 2024
1 parent 5fd9e6d commit 4d59040
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/src/utils/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _set_chunk_attributes(self) -> None:
if self.chunk:
chunk_start_idx, chunk_end_idx = self.chunk.split("-")
self.chunk_start_idx = int(chunk_start_idx)
self.chunk_end_idx = int(chunk_end_idx) + 1
self.chunk_end_idx = int(chunk_end_idx)
self.chunk_size = self.chunk_end_idx - self.chunk_start_idx

def _subset_origins(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions data/src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ def split_range(
chunk_size = math.ceil(n / n_chunks)
for i in range(n // chunk_size):
start = i * chunk_size
end = ((i + 1) * chunk_size) - 1
end = (i + 1) * chunk_size
chunk_ranges.append((start, end))
else:
n_chunks_small = max(1, math.ceil(n / min_chunk_size))
for i in range(n_chunks_small):
start = i * min_chunk_size
end = min((i + 1) * min_chunk_size - 1, n - 1)
end = min((i + 1) * min_chunk_size, n)
chunk_ranges.append((start, end))

if chunk_ranges[-1][1] < n:
start, _ = chunk_ranges[-1]
chunk_ranges[-1] = (start, n - 1)
chunk_ranges[-1] = (start, n)

return chunk_ranges

Expand Down

0 comments on commit 4d59040

Please sign in to comment.