Skip to content

InvalidTypeError(target_name, expected, given) Source

Bases: NumdaplotError

Raised when a setting or an argument receives a value of the wrong type, such as a number for Region rows.

A class given in place of an object, such as ndp.Sum in place of ndp.Sum(), gets a message naming the parentheses.

Added in version 0.1.0

Parameters:

  • target_name (str)

    What received the value, such as "Region rows".

  • expected (str)

    What it accepts, such as "an Index, a Range or None".

  • given (object)

    The rejected value.

Attributes:

  • target_name

    What received the value.

  • expected

    What it accepts.

  • given

    The rejected value.

Examples:

import numdaplot as ndp

try:
    ndp.Region(rows=0)
except ndp.InvalidTypeError as error:
    print(error)
# Region rows expects an Index, a Range, a First, a Last or None, got 0.
try:
    ndp.Array.from_list([1, 2]).compute(ndp.Sum)
except ndp.InvalidTypeError as error:
    print(error)
# ndp.Sum is a class, use ndp.Sum() instead.