Skip to content

NDArray Does Not Support String Data Type #17

@ershadow786

Description

@ershadow786

The current implementation of NDArray in NumJ does not support the String data type, limiting its flexibility to work with text data. The enum representing supported data types omits String, which means that arrays of String values cannot be created or manipulated using the NDArray class.

Proposed Solution: Add support for the String data type in NumJ by updating the enum to include String and modifying the relevant methods in NDArray to handle text-based arrays.

Issue raised during ,writing following Unit test case

 <T> void testArrayCreationWithShape(T value, int expectedShape, DType dType) throws Exception {
        NumJ<T> numJ = new NumJ<>();
        int[] shape = {expectedShape, expectedShape};

        NDArray<T> result = numJ.array(value, shape, 2, dType);

        assertNotNull(result);
        assertEquals(2, result.ndim());
        assertArrayEquals(shape, result.shape().stream().mapToInt(Integer::intValue).toArray());
    }

    static Stream<Arguments> shapeProvider() {
        return Stream.of(
                Arguments.of(1, 2, DType.INT32),
                Arguments.of(3.14, 3, DType.FLOAT64),
                Arguments.of("a", 4, DType.STR)
        );
    }

Metadata

Metadata

Assignees

Labels

ResolvedbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Resolved Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions