Skip to content

types

Classes:

Attributes:

  • MaskLike

    Type alias for anything that can resolve to a mask.

MaskLike module-attribute

MaskLike = Union[
    VideoNode,
    Callable[[VideoNode, VideoNode], VideoNode],
    EdgeDetectLike,
    RidgeDetectLike,
    GeneralMask,
    str,
]

Type alias for anything that can resolve to a mask.

Coordinates

Bases: tuple[int, ...], CustomEnum

Methods:

Attributes:

CORNERS class-attribute instance-attribute

CORNERS = (1, 0, 1, 0, 0, 1, 0, 1)

DIAMOND class-attribute instance-attribute

DIAMOND = (0, 1, 0, 1, 1, 0, 1, 0)

HORIZONTAL class-attribute instance-attribute

HORIZONTAL = (0, 0, 0, 1, 1, 0, 0, 0)

RECTANGLE class-attribute instance-attribute

RECTANGLE = (1, 1, 1, 1, 1, 1, 1, 1)

VERTICAL class-attribute instance-attribute

VERTICAL = (0, 1, 0, 0, 0, 0, 1, 0)

from_iter classmethod

from_iter(iter: int) -> Coordinates
Source code in vsmasktools/types.py
43
44
45
@classmethod
def from_iter(cls, iter: int) -> Coordinates:
    return cls.DIAMOND if (iter % 3) != 1 else cls.RECTANGLE

from_param classmethod

from_param(value: Any, func_except: FuncExcept | None = None) -> Self

Return the enum value from a parameter.

Parameters:

  • value

    (Any) –

    Value to instantiate the enum class.

  • func_except

    (FuncExcept | None, default: None ) –

    Exception function.

Returns:

  • Self

    Enum value.

Raises:

Source code in jetpytools/enums/base.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@classmethod
def from_param(cls, value: Any, func_except: FuncExcept | None = None) -> Self:
    """
    Return the enum value from a parameter.

    Args:
        value: Value to instantiate the enum class.
        func_except: Exception function.

    Returns:
        Enum value.

    Raises:
        NotFoundEnumValue: Variable not found in the given enum.
    """
    func_except = func_except or cls.from_param

    try:
        return cls(value)
    except (ValueError, TypeError):
        pass

    if isinstance(func_except, tuple):
        func_name, var_name = func_except
    else:
        func_name, var_name = func_except, repr(cls)

    raise NotFoundEnumValueError(
        'The given value for "{var_name}" argument must be a valid {enum_name}, not "{value}"!\n'
        "Valid values are: [{readable_enum}].",
        func_name,
        var_name=var_name,
        enum_name=cls,
        value=value,
        readable_enum=(f"{name} ({value!r})" for name, value in cls.__members__.items()),
        reason=value,
    ) from None

from_xxpand_mode classmethod

from_xxpand_mode(xxpand_mode: XxpandMode, iter: int = 1) -> Coordinates
Source code in vsmasktools/types.py
47
48
49
50
51
52
@classmethod
def from_xxpand_mode(cls, xxpand_mode: XxpandMode, iter: int = 1) -> Coordinates:
    if xxpand_mode == XxpandMode.LOSANGE or (xxpand_mode is XxpandMode.ELLIPSE and iter % 3 != 1):
        return cls.DIAMOND

    return cls.RECTANGLE

XxpandMode

Bases: CustomEnum

Expand/inpand mode

Methods:

  • from_param

    Return the enum value from a parameter.

Attributes:

ELLIPSE class-attribute instance-attribute

ELLIPSE = object()

Elliptical shape

LOSANGE class-attribute instance-attribute

LOSANGE = object()

Diamond shape

RECTANGLE class-attribute instance-attribute

RECTANGLE = object()

Rectangular shape

from_param classmethod

from_param(value: Any, func_except: FuncExcept | None = None) -> Self

Return the enum value from a parameter.

Parameters:

  • value

    (Any) –

    Value to instantiate the enum class.

  • func_except

    (FuncExcept | None, default: None ) –

    Exception function.

Returns:

  • Self

    Enum value.

Raises:

Source code in jetpytools/enums/base.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@classmethod
def from_param(cls, value: Any, func_except: FuncExcept | None = None) -> Self:
    """
    Return the enum value from a parameter.

    Args:
        value: Value to instantiate the enum class.
        func_except: Exception function.

    Returns:
        Enum value.

    Raises:
        NotFoundEnumValue: Variable not found in the given enum.
    """
    func_except = func_except or cls.from_param

    try:
        return cls(value)
    except (ValueError, TypeError):
        pass

    if isinstance(func_except, tuple):
        func_name, var_name = func_except
    else:
        func_name, var_name = func_except, repr(cls)

    raise NotFoundEnumValueError(
        'The given value for "{var_name}" argument must be a valid {enum_name}, not "{value}"!\n'
        "Valid values are: [{readable_enum}].",
        func_name,
        var_name=var_name,
        enum_name=cls,
        value=value,
        readable_enum=(f"{name} ({value!r})" for name, value in cls.__members__.items()),
        reason=value,
    ) from None