Skip to content

Commit

Permalink
Update src/_imaging.c
Browse files Browse the repository at this point in the history
Un-inline the accumulative ternary expression in the second `for` loop, in favor of a more straightforward `if`.

Co-Authored-By: fish2000 <fish2000@users.noreply.github.com>
  • Loading branch information
radarhere and fish2000 committed Feb 6, 2019
1 parent 761ec74 commit 3ee9a4c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/_imaging.c
Expand Up @@ -1298,7 +1298,9 @@ _entropy(ImagingObject* self, PyObject* args)
fentropy = 0.0;
for (idx = 0; idx < length; idx++) {
p = (double)h->histogram[idx] / fsum;
fentropy += p != 0.0 ? (p * log(p) * M_LOG2E) : 0.0;
if (p != 0.0) {
fentropy += p * log(p) * M_LOG2E;
}
}

/* Finally, allocate a PyObject* for return */
Expand Down

0 comments on commit 3ee9a4c

Please sign in to comment.