internal NpyIndexes() { indexes = new NpyIndex[NpyDefs.NPY_MAXDIMS]; for (int i = 0; i < indexes.Length; i++) { indexes[i] = new NpyIndex(); } num_indexes = 0; num_newindexes = 0; }
public void NpyArray_Subscript_Test2() { int DataSize = 0; NPY_TYPES desiredType = NPY_TYPES.NPY_INT16; var BaseArray = Common.GetComplexArray3D(desiredType, ref DataSize, 5, 6, 8); //Console.WriteLine(DumpData.DumpArray(BaseArray, true)); NpyIndex[] indexes = new NpyIndex[3]; indexes[0] = new NpyIndex(); indexes[0].type = NpyIndexType.NPY_INDEX_SLICE; indexes[0].slice = new NpyIndexSlice() { start = 1, stop = 5, step = 1 }; indexes[1] = new NpyIndex(); indexes[1].type = NpyIndexType.NPY_INDEX_SLICE; indexes[1].slice = new NpyIndexSlice() { start = 1, stop = 2, step = 1 }; indexes[2] = new NpyIndex(); indexes[2].type = NpyIndexType.NPY_INDEX_SLICE; indexes[2].slice = new NpyIndexSlice() { start = 1, stop = 2, step = 1 }; var MappedArray = numpyAPI.NpyArray_Subscript(BaseArray, indexes, 3); //Console.WriteLine(DumpData.DumpArray(MappedArray, true)); npy_intp Sum = 1; for (int i = 0; i < MappedArray.nd; i++) { Sum *= MappedArray.dimensions[i]; } //MappedArray.descr.f.setitem(Sum, 99, MappedArray); Console.WriteLine(DumpData.DumpArray(BaseArray, false)); Console.WriteLine(DumpData.DumpArray(MappedArray, false)); //todo: this throws an exception because the index is out of range. Possibly our stride problem return; }
public void NpyArray_Subscript_Test1() { int DataSize = 0; NPY_TYPES desiredType = NPY_TYPES.NPY_INT32; var BaseArray = Common.GetSimpleArray(desiredType, ref DataSize); NpyIndex[] indexes = new NpyIndex[1]; indexes[0] = new NpyIndex(); indexes[0].slice = new NpyIndexSlice() { start = 1, stop = 5, step = 2 }; var MappedArray = numpyAPI.NpyArray_Subscript(BaseArray, indexes, 1); return; }