montepy.types module#

Functions:

greater_than(minimum[, equality])

A higher-order function for use with args_checked to enforce a value being greater than a value.

less_than(maximum[, equality])

A higher-order function for use with args_checked to enforce a value being less than a value.

negative(func_name, name, x)

A higher-order function to be used with args_checked to ensure a value is negative, i.e., \(x\lt 0\).

non_negative(func_name, name, x)

A higher-order function to be used with args_checked to ensure a value is non-negative, i.e., \(x\geq 0\).

non_positive(func_name, name, x)

A higher-order function to be used with args_checked to ensure a value is non-positive, i.e., \(x\leq 0\).

positive(func_name, name, x)

A higher-order function to be used with args_checked to ensure a value is positive, i.e., \(x\gt 0\).

montepy.types.greater_than(minimum: Real, equality: bool = False)#

A higher-order function for use with args_checked to enforce a value being greater than a value.

Examples

This can be used to annotate a value

import numbers
import typing
from montepy.utilities import *

@args_checked
def foo(a: typing.Annotated[numbers.Real, greater_than(5)]):
    pass
Parameters:
  • minimum (Real) – The minimum value to be tested against.

  • equality (bool) – if true test for \(x\geq m\) rather than \(x\gt m\)

montepy.types.less_than(maximum: Real, equality=False)#

A higher-order function for use with args_checked to enforce a value being less than a value.

Examples

This can be used to annotate a value

import numbers
import typing
from montepy.utilities import *

@args_checked
def foo(a: typing.Annotated[numbers.Real, less_than(5)]):
    pass
Parameters:
  • maximum (Real) – The maximum value to be tested against.

  • equality (bool) – if true test for \(x\leq m\) rather than \(x\lt m\)

montepy.types.negative(func_name, name, x)#

A higher-order function to be used with args_checked to ensure a value is negative, i.e., \(x\lt 0\).

Example

from numbers import Real
from typing import Annotated
from montepy.utilities import *

@args_checked
def foo(a: Annotated[Real, negative]):
    pass
montepy.types.non_negative(func_name, name, x)#

A higher-order function to be used with args_checked to ensure a value is non-negative, i.e., \(x\geq 0\).

Example

from numbers import Real
from typing import Annotated
from montepy.utilities import *

@args_checked
def foo(a: Annotated[Real, non_negative]):
    pass
montepy.types.non_positive(func_name, name, x)#

A higher-order function to be used with args_checked to ensure a value is non-positive, i.e., \(x\leq 0\).

Example

from numbers import Real
from typing import Annotated
from montepy.utilities import *

@args_checked
def foo(a: Annotated[Real, non_positive]):
    pass
montepy.types.positive(func_name, name, x)#

A higher-order function to be used with args_checked to ensure a value is positive, i.e., \(x\gt 0\).

Example

from numbers import Real
from typing import Annotated
from montepy.utilities import *

@args_checked
def foo(a: Annotated[Real, positive]):
    pass
montepy.types.NegativeInt(*args, **kwargs)#

An integer that is negative, i.e., a member of the set \(\mathbb{Z}_{\lt0}\).

alias of Annotated[Integral, <function negative at 0x79aefb9c93a0>]

montepy.types.NegativeReal(*args, **kwargs)#

A real number that is negative, i.e., a member of the set \(\mathbb{R}_{\gt0}\).

alias of Annotated[Real, <function negative at 0x79aefb9c93a0>]

montepy.types.NonNegativeInt(*args, **kwargs)#

An integer that is negative, i.e., a member of the set \(\mathbb{Z}_{\geq0}\).

alias of Annotated[Integral, <function non_negative at 0x79aefb9c9580>]

montepy.types.NonNegativeReal(*args, **kwargs)#

A real number that is not negative, i.e., a member of the set \(\mathbb{R}_{\geq0}\).

alias of Annotated[Real, <function non_negative at 0x79aefb9c9580>]

montepy.types.PositiveInt(*args, **kwargs)#

An integer that is positive, i.e., a member of the set \(\mathbb{Z}_{\gt0}\).

alias of Annotated[Integral, <function positive at 0x79aefb9c9440>]

montepy.types.PositiveReal(*args, **kwargs)#

A real number that is positive, i.e., a member of the set \(\mathbb{R}_{\gt0}\).

alias of Annotated[Real, <function positive at 0x79aefb9c9440>]