comic / evalutils

evalutils helps users create extensions for grand-challenge.org
https://grand-challenge.org
MIT License
23 stars 9 forks source link

Minor performance boost for edt32 by using a more optimal mask converting routine #308

Closed silvandeleemput closed 3 years ago

silvandeleemput commented 3 years ago

Closes #302

This PR essentially replaces one line in the edt32 method in stats.py:

 input = np.atleast_1d(np.where(input, 1, 0).astype(np.int8))

with:

input = np.atleast_1d(input != 0)

They essentially perform the same operation, but the latter is approximately 3x as fast. See also #302 for proof and benchmark. Also, the following nbytes check has the same number of bytes for dtype=np.int8 and dtype=np.bool, keeping the behavior for the rest of the method the same.

codecov[bot] commented 3 years ago

Codecov Report

Merging #308 (b7272e7) into master (82f3182) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #308   +/-   ##
=======================================
  Coverage   85.24%   85.24%           
=======================================
  Files          13       13           
  Lines         881      881           
  Branches      127      127           
=======================================
  Hits          751      751           
  Misses         87       87           
  Partials       43       43           
Impacted Files Coverage Δ
evalutils/stats.py 86.30% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 82f3182...b7272e7. Read the comment docs.

silvandeleemput commented 3 years ago

302 Experiments show that this is not worth the effort.