Skip to content

Commit

Permalink
fix bug in KDTreeUtils unflatten()
Browse files Browse the repository at this point in the history
threw an ArrayIndexOutOfBoundsException for the following use-case:

// input: [1.0, 1.0, 1.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 1.0], dim=2

// the should-be result with the fix
deep: [[1.0, 1.0, 1.0, 0.0, 0.0], [1.0, 0.0, 0.5, 0.0, 1.0]]

// without the fix
java.lang.ArrayIndexOutOfBoundsException: 5
	at net.imglib2.kdtree.KDTreeUtils.unflatten(KDTreeUtils.java:229)
  • Loading branch information
StephanPreibisch authored and tpietzsch committed Oct 15, 2024
1 parent 7710e25 commit 58f18c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/kdtree/KDTreeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static double[][] unflatten( double[] positions, final int n )
for (int i = 0; i < positions.length; ++i )
{
final int d = i % n;
unflattened[ d ][ i / n + d ] = positions[ i ];
unflattened[ d ][ i / n ] = positions[ i ];
}
return unflattened;

Expand Down

0 comments on commit 58f18c6

Please sign in to comment.