Skip to content

Commit fb93e7a

Browse files
committed
Added NDArray[Slice[]] and NDArray[string]
1 parent 87ba41f commit fb93e7a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/NumSharp.Core/Selection/NDArray.Indexing.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ public NDArray this[params NDArray<int>[] selection]
3838
}
3939
}
4040

41+
42+
/// <summary>
43+
/// Slice the array with Python slice notation like this: ":, 2:7:1, ..., np.newaxis"
44+
/// </summary>
45+
/// <param name="slice">A string containing slice notations for every dimension, delimited by comma</param>
46+
/// <returns>A sliced view</returns>
47+
public NDArray this[string slice]
48+
{
49+
get => new NDArray(Storage.GetView(Slice.ParseSlices(slice)));
50+
set => Storage.GetView(Slice.ParseSlices(slice)).SetData(value);
51+
}
52+
53+
54+
/// <summary>
55+
/// Slice the array with Python slice notation like this: ":, 2:7:1, ..., np.newaxis"
56+
/// </summary>
57+
/// <param name="slice">A string containing slice notations for every dimension, delimited by comma</param>
58+
/// <returns>A sliced view</returns>
59+
public NDArray this[params Slice[] slice]
60+
{
61+
get => new NDArray(Storage.GetView(slice));
62+
set => Storage.GetView(slice).SetData(value);
63+
}
4164
/// <summary>
4265
/// Used to perform selection based on indices, equivalent to nd[NDArray[]].
4366
/// </summary>

0 commit comments

Comments
 (0)