Class NumSharpException
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
public class NumSharpException : Exception, ISerializable, INumSharpException
- Inheritance
-
NumSharpException
- Implements
- Derived
- Inherited Members
Constructors
NumSharpException()
Initializes a new instance of the Exception class.
public NumSharpException()
NumSharpException(string)
Initializes a new instance of the Exception class with a specified error message.
public NumSharpException(string message)
Parameters
messagestringThe message that describes the error.
NumSharpException(string, Exception)
Initializes a new instance of the Exception class with a specified error message and a reference to the inner exception that is the cause of this exception.
public NumSharpException(string message, Exception innerException)
Parameters
messagestringThe error message that explains the reason for the exception.
innerExceptionExceptionThe exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
Methods
ThrowIfNotWriteable(Shape, string)
The single writeability gate for every in-place write in the library — the indexing
setters, NDArray.fill, put / place / putmask / put_along_axis, the ufunc
out= routes, copyto, the matmul / clip / cumsum / fft out= paths, the
real/imag setters and shuffle all funnel through here (NumPy's
PyArray_FailUnlessWriteable). It raises when the destination is NOT writeable —
most importantly a broadcast view (any stride-0 axis reports
IsWriteable == false), so an attempted write through shared
broadcast memory is REFUSED here rather than silently corrupting every element that
aliases the same buffer.
public static void ThrowIfNotWriteable(Shape shape, string name = "assignment destination")
Parameters
shapeShapeThe destination shape to check for writeability.
namestringThe array's name in the error message (default: "assignment destination"). This is load-bearing, not cosmetic: NumPy words the read-only message per operation ("output array", "put: output array", "WRITEBACKIFCOPY base", "array", …) and the differential-fuzz error-parity gate compares the message VERBATIM, so each caller must pass the exact spelling NumPy uses for that operation.
Remarks
Raises NumPy's exact exception — type AND message — ValueError: {name} is
read-only, so Python code ported as except ValueError catches it and the
oracle's error-parity tier passes without an excuse. ValueError derives
from ArgumentException and implements
INumSharpException, so a handler catching either of those still works;
a handler that caught NumSharpException specifically for a read-only
write must switch to ValueError.
Exceptions
- ValueError
If the shape is not writeable.
ThrowReadOnly(string)
Throws the read-only failure unconditionally, in NumPy's exact
ValueError: {name} is read-only form. Split out from
ThrowIfNotWriteable(Shape, string) and marked non-inlining so the common
writeable-fast-path stays inlineable while the throw (cold) does not bloat callers.
[DoesNotReturn]
public static void ThrowReadOnly(string name = "assignment destination")
Parameters
namestringThe array's name in the message; see ThrowIfNotWriteable(Shape, string) for why the spelling must match NumPy's per-operation wording.
Exceptions
- ValueError
Always — this method never returns.