Skip to content

Commit 31716d7

Browse files
committed
Shape: Removed all uses of Array.Empty<int>
1 parent fcb6361 commit 31716d7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/NumSharp.Core/View/Shape.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ public bool IsRecursive
7777
/// <summary>
7878
/// Singleton instance of a <see cref="Shape"/> that represents a scalar.
7979
/// </summary>
80-
public static readonly Shape Scalar = new Shape(Array.Empty<int>());
80+
public static readonly Shape Scalar = new Shape(new int[0]);
8181

8282
/// <summary>
8383
/// Create a new scalar shape
8484
/// </summary>
8585
[MethodImpl(MethodImplOptions.AggressiveInlining)]
86-
internal static Shape NewScalar() => new Shape(Array.Empty<int>());
86+
internal static Shape NewScalar() => new Shape(new int[0]);
8787

8888
/// <summary>
8989
/// Create a new scalar shape
9090
/// </summary>
9191
[MethodImpl(MethodImplOptions.AggressiveInlining)]
92-
internal static Shape NewScalar(ViewInfo viewInfo) => new Shape(Array.Empty<int>()) {ViewInfo = viewInfo};
92+
internal static Shape NewScalar(ViewInfo viewInfo) => new Shape(new int[0]) {ViewInfo = viewInfo};
9393

9494
/// <summary>
9595
/// Create a new scalar shape
9696
/// </summary>
9797
[MethodImpl(MethodImplOptions.AggressiveInlining)]
98-
internal static Shape NewScalar(ViewInfo viewInfo, BroadcastInfo broadcastInfo) => new Shape(Array.Empty<int>()) {ViewInfo = viewInfo, BroadcastInfo = broadcastInfo};
98+
internal static Shape NewScalar(ViewInfo viewInfo, BroadcastInfo broadcastInfo) => new Shape(new int[0]) {ViewInfo = viewInfo, BroadcastInfo = broadcastInfo};
9999

100100
/// <summary>
101101
/// Create a shape that represents a vector.
@@ -278,7 +278,7 @@ public Shape(params int[] dims)
278278
{
279279
if (dims == null)
280280
{
281-
strides = dims = dimensions = Array.Empty<int>();
281+
strides = dims = dimensions = new int[0];
282282
}
283283
else
284284
{
@@ -977,7 +977,7 @@ public static int[] GetAxis(int[] dims, int axis)
977977
throw new ArgumentNullException(nameof(dims));
978978

979979
if (dims.Length == 0)
980-
return Array.Empty<int>();
980+
return new int[0];
981981

982982
if (axis <= -1) axis = dims.Length - 1;
983983
if (axis >= dims.Length)
@@ -1116,7 +1116,7 @@ public Shape Slice(params Slice[] input_slices)
11161116
public static explicit operator int(Shape shape) => shape.Size;
11171117
public static explicit operator Shape(int dim) => Shape.Vector(dim);
11181118

1119-
public static explicit operator (int, int)(Shape shape) => shape.dimensions.Length == 2 ? (shape.dimensions[0], shape.dimensions[1]) : (0, 0); //TODO! this should return (0,0) but rather (dim[0], dim[1]) regardless of size.
1119+
public static explicit operator (int, int)(Shape shape) => shape.dimensions.Length == 2 ? (shape.dimensions[0], shape.dimensions[1]) : (0, 0);
11201120
public static implicit operator Shape((int, int) dims) => Shape.Matrix(dims.Item1, dims.Item2);
11211121

11221122
public static explicit operator (int, int, int)(Shape shape) => shape.dimensions.Length == 3 ? (shape.dimensions[0], shape.dimensions[1], shape.dimensions[2]) : (0, 0, 0);

0 commit comments

Comments
 (0)