Skip to content

GetData<>() returning wrong values from NDarray #60

@volgaone

Description

@volgaone

Hello,
I am facing a problem with getting the values back from an NDarray into a c# array. I can manipulate the NDarrays entirely satisfactory, but GetData<>() method returns me values as if they belonged to an original, continuous array. Let me demonstrate:

[Test]
        public void TestNDarray()
        {
            var n = np.array(new float[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } });
            var row0 = n[0]; //extract 1st row
            var row0Data = row0.GetData<float>(); //this is correct - {1,2,3} 
            var col1 = n[":,1"]; //extract 1st column - NDarray is [2 5 8] as expected
            var col1Data = col1.GetData();//this is wrong - {2,3,4}
        }

I dug a bit into the code of public T[] GetData<T>() and it does check whether the array is contiguous... Maybe the mistake is there? But alas, col1 does correctly indicate that it is not a contiguous array - so GetData() should take that into account?
image

Has anyone faced a similar issue? I am really stuck at this point - I have tried everything I can think of...
Thanks
Dmitry

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions