insaf021 opened a new pull request, #355:
URL: https://github.com/apache/commons-math/pull/355
On master, with custom bases:
new HaltonSequenceGenerator(1, new int[] {1}, null).skipTo(1) //
never returns
new HaltonSequenceGenerator(1, new int[] {0}, null).skipTo(1) //
ArithmeticException: / by zero
new HaltonSequenceGenerator(1, new int[] {-2}, null).skipTo(1) //
[-0.5]
new HaltonSequenceGenerator(3, new int[] {2, 3}, null) // "3
out of [1, 40] range"
The constructor clones `bases` without looking at the values, and `get()`
decomposes the index with `while (index > 0) { ...; index /= base[i]; }`. A
base of 1 never reduces the index, so every point after the first spins
forever. A base of 0 divides by zero on the second point instead of failing at
construction, and a negative base gives coordinates outside the documented [0,
1] interval. No base below 2 is meaningful for a Halton sequence, so the
constructor now rejects it with `NumberIsTooSmallException`, after the existing
argument checks.
The dimension check in the same constructor reported `PRIMES.length` as the
upper bound, although the javadoc documents `[1, len]` with len the length of
`bases`. It now reports `bases.length`.
`HaltonSequenceGeneratorTest` gains `testConstructorInvalidBase` and an
upper-bound assertion in `testConstructor2`; both fail on master and pass with
the patch. `mvn clean install apache-rat:check checkstyle:check spotbugs:check
javadoc:javadoc -pl commons-math-legacy -am` is green on JDK 21 (3265 tests in
legacy; the only reruns are the randomised SimplexOptimizerTest cases).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]