Class AssertionError
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Exception that corresponds to Python's AssertionError, raised where NumPy's own code ends in an
assert or in typing.assert_never for an argument it does not handle.
public class AssertionError : NumSharpException, ISerializable, INumSharpException
- Inheritance
-
AssertionError
- Implements
- Inherited Members
Remarks
NumPy raises it from library code, not as part of a documented contract, so a caller that ports NumPy code
sees it only where NumPy's validation is an exhaustive match: np.pad's dict pad_width
matches each width against int and a 2-tuple of ints and sends anything else to
typing.assert_never ("Expected code to be unreachable, but got: 1.5").
It derives from NumSharpException like the other Python-named house types, NOT from ArgumentException: Python's AssertionError is no ValueError / TypeError, so a handler for the argument errors does not catch it.
A port of Python's bare assert condition throws new AssertionError(): its message is empty, exactly
as str() of the AssertionError a failed bare assert raises, so error texts compared with
Python's match.
Constructors
AssertionError()
Creates the exception with Python's text for a failed bare assert: an empty
Message, as str(AssertionError()) is ''.
public AssertionError()
Remarks
ToString() then starts with the class name alone, as Python's traceback prints a
bare AssertionError. Pass a message wherever the failure has something to say: an empty one tells a
reader of the log nothing.
AssertionError(string)
Creates the exception with NumPy's message.
public AssertionError(string message)
Parameters
messagestringThe text NumPy raises, verbatim.
AssertionError(string, Exception)
Creates the exception with NumPy's message and the exception that caused it.
public AssertionError(string message, Exception innerException)