Table of Contents

Class ValueError

Namespace
NumSharp
Assembly
NumSharp.dll

NumPy-compatible ValueError exception. Raised when an operation receives an argument with the right type but inappropriate value.

public class ValueError : ArgumentException, ISerializable, INumSharpException
Inheritance
ValueError
Implements
Derived
Inherited Members

Remarks

Mirrors Python's ValueError / numpy's ValueError for API compatibility. Common cases:

  • negative dimensions: "negative dimensions are not allowed"
  • invalid seed: "Seed must be between 0 and 2**32 - 1"
  • randint bounds: "high is out of bounds for int32"

Constructors

ValueError()

Creates the error with Python's text for a bare raise ValueError: an empty Message, as str(ValueError()) is '' (not .NET's ArgumentException default, "Value does not fall within the expected range.").

public ValueError()

Remarks

ToString() then starts with the class name alone, as Python's traceback prints a bare ValueError; prefer a message that names the refused value. The subclasses' parameterless forms (LinAlgError, UnicodeError) read the same.

ValueError(string)

Creates the error with NumPy's (or the port's) message.

public ValueError(string message)

Parameters

message string

The text, verbatim: Python's str() of the error.

ValueError(string, Exception)

Creates the error with a message and the exception that caused it: Python's raise ValueError(message) from innerException, the cause kept in InnerException as Python keeps it in cause.

public ValueError(string message, Exception innerException)

Parameters

message string

The text, verbatim: Python's str() of the error.

innerException Exception

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

ValueError(string, string)

Creates the error with a message and the .NET parameter it is about. Footgun: .NET appends " (Parameter '…')" to Message, so the text no longer equals NumPy's; use it only where no caller compares the message with Python's.

public ValueError(string message, string paramName)

Parameters

message string

The text.

paramName string

The name of the refused parameter, reported by ParamName.