Skip to content

Commit 818427d

Browse files
author
dotchris90
committed
Feat : Add dtype check
1 parent 4294e05 commit 818427d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/NumSharp.Core/Math/NdArray.Convolve.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public NDArray Convolve(NDArray numSharpArray2, string mode = "full" )
2424
if (shape.NDim > 1)
2525
throw new IncorrectShapeException();
2626

27-
var numSharpReturn = new NDArray(this.dtype);
27+
var numSharpReturn = new NDArray(typeof(double));
2828

2929
double[] np1 = this.Storage.GetData<double>();
3030
double[] np2 = numSharpArray2.Storage.GetData<double>();

src/NumSharp.Core/NDStorage.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ public static NDStorage CreateByShapeAndType(Type dtype,Shape shape)
6464
}
6565
public static NDStorage CreateByArray(Array values)
6666
{
67-
Type dtype = values.GetType().GetElementType();
68-
67+
Type dtype = null;
68+
69+
if ( !values.GetType().GetElementType().IsArray )
70+
dtype = values.GetType().GetElementType();
71+
else
72+
throw new IncorrectShapeException();
73+
6974
int[] dims = new int[values.Rank];
7075

7176
for (int idx = 0; idx < dims.Length;idx++)
@@ -74,6 +79,8 @@ public static NDStorage CreateByArray(Array values)
7479
var storage = NDStorage.CreateByShapeAndType(dtype,new Shape(dims));
7580
storage.values = Array.CreateInstance(dtype,values.Length);
7681

82+
storage.SetData(values);
83+
7784
return storage;
7885
}
7986
/// <summary>

0 commit comments

Comments
 (0)