Closed dmbates closed 9 months ago
any(xl .≤ x .≤ xu)
I much prefer this style.
You mean:
all(xl .≤ x .≤ xu)
not any(xl .≤ x .≤ xu)
.
You have to realize that:
all(xl .≤ x .≤ xu)
implies creating, at least, one temporary array while check_bounds
avoids that.check_bounds
, which is supposed to return true
, avoids branching to allow for loop-vectorization. This is not the case of all
, any
, etc.check_bounds
can be modified to check the sizes.Nevertheless, such optimizations are irrelevant for test code and I have modified check_bounds
as suggested in commit 2c756f3203ee5870725d5aad0002a4ce121be6da. Thanks for the suggestion.
This is a very minor stylistic point but the
check_bounds
function intest/runtests.jl
could be written
These are equivalent except that the
any
version will short-circuit as soon as it finds a bounds violation. In other words, it is equivalent toPerhaps more important is that
zip
doesn't fail if the lengths ofxl
,x
, andxu
don't all match; it uses the shortest length. Theall
version throwsDimensionMismatch
in such a case.