diff --git a/numpy/NumpyDotNet/Scalar.cs b/numpy/NumpyDotNet/Scalar.cs index b41d4b7ea..df4b5bbcc 100644 --- a/numpy/NumpyDotNet/Scalar.cs +++ b/numpy/NumpyDotNet/Scalar.cs @@ -2080,7 +2080,21 @@ public ScalarFloat64(Double value) { } public ScalarFloat64(IConvertible value) { - this.value = Convert.ToSingle(value); + this.value = Convert.ToDouble(value); + } + + public ScalarFloat64(ndarray value) { + if (value.ndim == 0) { + object v = ((dtype)dtype).ToScalar(value); + if (v is IConvertible) { + this.value = Convert.ToDouble((IConvertible)v); + } else { + throw new ArgumentTypeException( + String.Format("Unable to convert array of {0} to double", value.Dtype.ToString())); + } + } else { + throw new ArgumentTypeException("Only 0-d arrays can be converted to scalars"); + } } public override object dtype { diff --git a/numpy/NumpyDotNet/ndarray.cs b/numpy/NumpyDotNet/ndarray.cs index 406e507bc..2ffcb1629 100644 --- a/numpy/NumpyDotNet/ndarray.cs +++ b/numpy/NumpyDotNet/ndarray.cs @@ -2072,7 +2072,7 @@ internal long Length { } } - internal static object ArrayReturn(ndarray a) { + public static object ArrayReturn(ndarray a) { if (a.ndim == 0) { return a.Dtype.ToScalar(a); } else {