offchain icon indicating copy to clipboard operation
offchain copied to clipboard

Added test coverage for batched_parmap

Open atapin opened this issue 7 months ago • 0 comments

Description

Added test coverage for batched_parmap function and improved its readability by simplifying the implementation. Also improved the performance by utilizing list.extend method instead of + concatenation. Extension modifies a list in place, instead of creating a new list by +

Motivation and Context

Currently batched_parmap has unnecessary cyclomatic complexity, because it has to check for trailing chunks of batches in case when size of args is not divisible by batch_size. Even though the check is implemented, this case is not covered by tests. Also, memory consumption of this function can be reduced by replacing list concatenation with list extension.

Fixes #104

How has this been tested?

I provided a unit test and ran all other tests.

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

atapin avatar Jul 04 '24 08:07 atapin