internal void AddCSharpTuple(CSharpTuple CSTuple) { IsAdvancedIndexing = true; indexes[num_indexes].type = NpyIndexType.NPY_INDEX_SLICE; NpyIndexSlice IndexSlice = new NpyIndexSlice() { start = (npy_intp)CSTuple.index1, stop = CSTuple.index2 != null ? (npy_intp)CSTuple.index2 + 1 : (npy_intp)CSTuple.index1 + 1, step = CSTuple.index3 != null ? (npy_intp)CSTuple.index3 : 1, }; indexes[num_indexes].slice = IndexSlice; ++num_indexes; }
internal void AddIndex(ISlice slice) { npy_intp step; bool negativeStep; npy_intp start; npy_intp stop; bool hasStop; // Find the step if (slice.Step == null) { step = (npy_intp)1; negativeStep = false; } else { step = ConvertSliceValue(slice.Step); negativeStep = (step < 0); } // Find the start if (slice.Start == null) { start = (npy_intp)(negativeStep ? -1 : 0); } else { start = ConvertSliceValue(slice.Start); } // Find the stop if (slice.Stop == null) { hasStop = false; stop = 0; } else { hasStop = true; stop = ConvertSliceValue(slice.Stop); } // Write the type int offset = num_indexes * sizeof(npy_intp); if (!hasStop) { indexes[num_indexes].type = NpyIndexType.NPY_INDEX_SLICE_NOSTOP; NpyIndexSliceNoStop IndexSliceNoStop = new NpyIndexSliceNoStop() { start = start, step = step, }; indexes[num_indexes].slice_nostop = IndexSliceNoStop; } else { indexes[num_indexes].type = NpyIndexType.NPY_INDEX_SLICE; NpyIndexSlice IndexSlice = new NpyIndexSlice() { start = start, stop = stop, step = step, }; indexes[num_indexes].slice = IndexSlice; } ++num_indexes; }