Table of Contents

Class IncorrectSizeException

Namespace
NumSharp
Assembly
NumSharp.dll

Raised when an array that is not of size 1 is read as one scalar: item() with NumPy's text (can only convert an array of size 1 to a Python scalar), and np.asscalar and the scalar conversions in Converts with NumSharp's own (Unable to convert NDArray to scalar because size is not 1.).

public class IncorrectSizeException : NumSharpException, ISerializable, INumSharpException
Inheritance
IncorrectSizeException
Implements
Inherited Members

Remarks

Footgun: NumPy raises a ValueError for these failures, but this type derives from NumSharpException only, so a catch (ValueError) ported from Python's except ValueError misses it; catch this type, NumSharpException, or INumSharpException.

Constructors

IncorrectSizeException(string)

Creates the exception with the message as given (NumPy's text where a NumPy function is mirrored).

public IncorrectSizeException(string message)

Parameters

message string

The message, kept verbatim.

IncorrectSizeException(string, Exception)

Creates the exception with the message and the exception that caused it, .NET's standard constructor every NumSharp exception has (Python's raise ... from innerException).

public IncorrectSizeException(string message, Exception innerException)

Parameters

message string

The message, kept verbatim.

innerException Exception

The exception that led to this one, or null for none.