Skip to content

InvalidBinWidthError(width) Source

Bases: NumdaplotError

Raised when a BinWidth is 0 or negative, or a duration beyond a day.

Such a width would never cover the values, or be wider than every time of day.

Added in version 0.1.0

Parameters:

  • width (float | timedelta)

    The rejected width.

Attributes:

  • width

    The rejected width.

Examples:

import numdaplot as ndp

try:
    ndp.BinWidth(-5.0)
except ndp.InvalidBinWidthError as error:
    print(error)
# Expected a bin width above 0, got -5.0.
from datetime import timedelta
try:
    ndp.BinWidth(timedelta(days=2))
except ndp.InvalidBinWidthError as error:
    print(error)
# Expected a bin width above 0 and at most 1 day, got 2 days, 0:00:00.