Skip to content

Commit f208c4a

Browse files
committed
Default.Cast: reformat and docs
1 parent 0832b22 commit f208c4a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/NumSharp.Core/Backends/Default/ArrayManipulation/Default.Cast.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public override NDArray Cast(NDArray nd, NPTypeCode dtype, bool copy)
1212
if (dtype == NPTypeCode.Empty)
1313
throw new ArgumentNullException(nameof(dtype));
1414

15-
NDArray clone() => new NDArray(nd.Storage.Clone());
16-
15+
//incase its an empty array
1716
if (nd.Shape.IsEmpty)
1817
{
1918
if (copy)
@@ -23,6 +22,7 @@ public override NDArray Cast(NDArray nd, NPTypeCode dtype, bool copy)
2322
return nd;
2423
}
2524

25+
//incase its a scalar
2626
if (nd.Shape.IsScalar)
2727
{
2828
var ret = NDArray.Scalar(nd.GetAtIndex(0), dtype);
@@ -33,6 +33,7 @@ public override NDArray Cast(NDArray nd, NPTypeCode dtype, bool copy)
3333
return nd;
3434
}
3535

36+
//incase its a (1,) shaped
3637
if (nd.Shape.size == 1 && nd.Shape.NDim == 1)
3738
{
3839
var ret = new NDArray(ArraySlice.Scalar(nd.GetAtIndex(0), dtype), Shape.Vector(1));
@@ -43,6 +44,7 @@ public override NDArray Cast(NDArray nd, NPTypeCode dtype, bool copy)
4344
return nd;
4445
}
4546

47+
//regular clone
4648
if (nd.GetTypeCode == dtype)
4749
{
4850
//casting not needed
@@ -65,6 +67,8 @@ public override NDArray Cast(NDArray nd, NPTypeCode dtype, bool copy)
6567
return nd;
6668
}
6769
}
70+
71+
NDArray clone() => nd.Clone();
6872
}
6973
}
7074
}

0 commit comments

Comments
 (0)