Skip to content

Commit

Permalink
Ensure that complement offset is always integer (renatahodovan#35)
Browse files Browse the repository at this point in the history
Use integer division when computing its value instead of casting it
to int when used.
  • Loading branch information
akosthekiss authored Jul 14, 2023
1 parent ef59596 commit 63668bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions picire/dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __call__(self, config):
elif len(subsets) < len(config):
# No interesting configuration is found but it is still not the finest splitting, start new iteration.
next_subsets = self._split(subsets)
complement_offset = (complement_offset * len(next_subsets)) / len(subsets)
complement_offset = (complement_offset * len(next_subsets)) // len(subsets)
subsets = next_subsets

logger.info('\tIncreased granularity')
Expand Down Expand Up @@ -121,7 +121,7 @@ def _reduce_config(self, run, subsets, complement_offset):
config_id = (f'r{run}', f's{i}')
config_set = subsets[i]
else:
i = int((-i - 1 + complement_offset) % n)
i = (-i - 1 + complement_offset) % n
config_id = (f'r{run}', f'c{i}')
config_set = [c for si, s in enumerate(subsets) for c in s if si != i]
i = -i - 1
Expand Down
2 changes: 1 addition & 1 deletion picire/parallel_dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _reduce_config(self, run, subsets, complement_offset):
config_id = (f'r{run}', f's{i}')
config_set = subsets[i]
else:
i = int((-i - 1 + complement_offset) % n)
i = (-i - 1 + complement_offset) % n
config_id = (f'r{run}', f'c{i}')
config_set = [c for si, s in enumerate(subsets) for c in s if si != i]
i = -i - 1
Expand Down

0 comments on commit 63668bb

Please sign in to comment.