Skip to content

IllegalArgumentException: argument type mismatch in NDArray flattenRecursive Method #15

@ershadow786

Description

@ershadow786

Issue Description:

The NDArray.flatten() method throws an IllegalArgumentException:
argument type mismatch during execution. This occurs when attempting to flatten a multidimensional array of a certain type. The error originates from trying to set elements in the array via reflection in the Array.set() method.

The issue was encountered in the following test case:

@Test
void testFlatten() {
    // Test case setup with a multidimensional array
    NDArray<T> ndArray = numJ.array(new Integer[][]{{1, 2}, {3, 4}});
    NDArray<T> flattened = ndArray.flatten();
    
    // Assertions
    assertArrayEquals(new Integer[]{1, 2, 3, 4}, (Integer[]) flattened.getArray());
}

The stack trace points to a type mismatch error in the flattenRecursive() method:

java.lang.IllegalArgumentException: argument type mismatch
	at java.base/java.lang.reflect.Array.set(Native Method)
	at com.library.numj.NDArray.flattenRecursive(NDArray.java:264)
	...

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions