Table of Contents

Class UFuncOutputCastingError

Namespace
NumSharp
Assembly
NumSharp.dll

NumPy's _UFuncOutputCastingError: the loop's result cannot be cast to an output (out=) under the casting= rule (Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind').

public class UFuncOutputCastingError : UFuncCastingError, ISerializable, INumSharpException
Inheritance
UFuncOutputCastingError
Implements
Inherited Members

Remarks

A subclass of UFuncCastingError; it adds out_i. Footgun, NumPy's own: out_i is the operand's index among ALL operands (inputs first: np.add's output is 2), and that is the number the text prints for a ufunc with several outputs (np.modf's first output reads output 1).

Constructors

UFuncOutputCastingError(string, Exception)

Creates the error from a message and the exception that caused it, .NET's standard constructor every NumSharp exception has: the message is kept verbatim, ufunc, casting, from_ and to are null and out_i is 0.

public UFuncOutputCastingError(string message, Exception innerException)

Parameters

message string

The verbatim message.

innerException Exception

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

Remarks

Python has no such constructor (NumPy's _UFuncOutputCastingError takes the ufunc, the rule, the two dtypes and the index); for code that holds a text only. Footgun: out_i reads 0, a valid operand index, as the Unicode errors' start does when built from a message.

UFuncOutputCastingError(string, int, string, object, object, int)

NumPy's UFuncOutputCastingError(ufunc, casting, from, to, i), with the ufunc's output count NumPy reads off the ufunc object.

public UFuncOutputCastingError(string ufunc, int nout, string casting, object from_, object to, int i)

Parameters

ufunc string

The ufunc's name.

nout int

The ufunc's output count: the text names the operand's index only when it is not 1.

casting string

The rule (same_kind, …).

from_ object

The loop's result dtype.

to object

The output array's dtype.

i int

The output's index among all operands (inputs first).

Exceptions

ArgumentNullException

ufunc is null.

Properties

out_i

The index of the output that cannot be cast, among all operands (NumPy's out_i); 0 when the error was built from a message alone.

public int out_i { get; }

Property Value

int