Table of Contents

Class ZeroDivisionError

Namespace
NumSharp
Assembly
NumSharp.dll

Python's ZeroDivisionError: a division or modulo whose divisor is zero, raised where Python's scalar arithmetic raises it. NumSharp raises it where NumPy does: np.average over weights that sum to zero (Weights sum to zero, can't be normalized), np.fft.fftfreq with d=0 (float division by zero), the object-dtype and polynomial paths that compute with Python scalars (division by zero, integer division or modulo by zero, complex division by zero).

public class ZeroDivisionError : ArithmeticError, ISerializable, INumSharpException
Inheritance
ZeroDivisionError
Implements
Inherited Members

Remarks

Array division never raises it: NumPy's ufuncs divide by zero into inf / nan (floats) or 0 (integers), and so do NumSharp's. It comes only from code that NumPy runs on Python scalars.

A subclass of ArithmeticError; footgun: NOT .NET's DivideByZeroException, which a catch (DivideByZeroException) written for older NumSharp expects. Catch ZeroDivisionError, or ArithmeticException for both.

Constructors

ZeroDivisionError()

Creates the error with Python's text for a bare raise ZeroDivisionError: an empty Message, as str(ZeroDivisionError()) is '' (NumPy's polynomial division by a zero series raises exactly this).

public ZeroDivisionError()

Remarks

ToString() then starts with the class name alone, as Python's traceback prints a bare ZeroDivisionError.

ZeroDivisionError(string)

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

public ZeroDivisionError(string message)

Parameters

message string

The text, verbatim: Python's str() of the error (float division by zero).

ZeroDivisionError(string, Exception)

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

public ZeroDivisionError(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 (a .NET DivideByZeroException, for example), or null for none.