Table of Contents

Class DTypePromotionError

Namespace
NumSharp
Assembly
NumSharp.dll

numpy.exceptions.DTypePromotionError — raised when two (or more) DTypes have no common DType, i.e. np.promote_types / np.result_type cannot find a dtype that can hold every input (NEP 42's common_dtype protocol returned NotImplemented in both directions).

public class DTypePromotionError : TypeError, ISerializable, INumSharpException
Inheritance
DTypePromotionError
Implements
Inherited Members

Remarks

Derives from TypeError exactly as NumPy's does (DTypePromotionError(TypeError)), so a catch (TypeError) written for NumPy 1.x code keeps working. The two message shapes are NumPy's verbatim texts from common_dtype.c:

  • The DTypes <class 'numpy.dtypes.DateTime64DType'> and <class 'numpy.dtypes.Float64DType'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`. (the pairwise PyArray_CommonDType)
  • The DType %S could not be promoted by %S. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (%S, …) (the sequence reduction PyArray_PromoteDTypeSequence)

Constructors

DTypePromotionError()

Creates the error with Python's text for a bare raise DTypePromotionError: an empty Message, as str(np.exceptions.DTypePromotionError()) is ''.

public DTypePromotionError()

Remarks

Prefer one of NumPy's two texts listed on the class: they name the DTypes that found no common DType.

DTypePromotionError(string)

Creates the error with NumPy's message.

public DTypePromotionError(string message)

Parameters

message string

The text NumPy raises, verbatim (The DTypes ... do not have a common DType. ...).

DTypePromotionError(string, Exception)

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

public DTypePromotionError(string message, Exception innerException)

Parameters

message string

The text NumPy raises, verbatim.

innerException Exception

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