Skip to content

Conversation

@rhaegar325
Copy link
Collaborator

Fix TypeError in chunked write: Convert time_chunk to integer

Problem

When using chunked writing for large datasets, the write() method crashes with:

TypeError: 'float' object cannot be interpreted as an integer

This occurs because calculate_chunk_size_for_variable() returns float values for chunk sizes, but Python's range() function requires integer arguments.

Root Cause

In the chunked write loop (line 813), time_chunk is used directly in range():

for t_start in range(0, total_timesteps, time_chunk):  # time_chunk is float

Solution

Convert time_chunk to integer before using it in range():

time_chunk = int(chunk_sizes.get("time", self.ds.sizes["time"]))

@rhaegar325 rhaegar325 requested a review from rbeucher January 15, 2026 05:03
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.91%. Comparing base (0eb8d0e) to head (2f948e3).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
+ Coverage   52.02%   60.91%   +8.89%     
==========================================
  Files          18       18              
  Lines        2722     2848     +126     
==========================================
+ Hits         1416     1735     +319     
+ Misses       1306     1113     -193     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rbeucher rbeucher merged commit 1bc3063 into main Jan 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants