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

fix(iteration): prevent IntegerDivisionByZeroException with SETPOS #67

Merged

Conversation

jonasbadstuebner
Copy link
Contributor

Closes: #44

The problem is, if you go by month, it iterates over every day of every month, starting with January. In the provided example, no day of year in January (1-31) matches any date in the dateset, therefore dateIndices is empty and it throws a IntegerDivisionByZeroException when using dateIndices.length on the right hand side of the modulo operator in set_positions_list.dart.

final dateIndex = dateIndices[datePosition % dateIndices.length];

This PR fixes the problem by just moving on.

Signed-off-by: Jonas Badstübner <jonas.badstuebner@hetzner-cloud.de>
Copy link

codecov bot commented Jan 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f557fe9) 87.90% compared to head (e8fb5fa) 87.90%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #67   +/-   ##
=======================================
  Coverage   87.90%   87.90%           
=======================================
  Files          21       21           
  Lines        1281     1282    +1     
=======================================
+ Hits         1126     1127    +1     
  Misses        155      155           

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

@JonasWanke JonasWanke merged commit 1a33b23 into JonasWanke:main Jan 28, 2024
13 checks passed
@JonasWanke
Copy link
Owner

Thanks for this fix! It's published as part of v0.2.15

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.

Instance generation with SETPOS fails after generating some instances
2 participants