util ¶
Classes:
-
ExprVars–A helper class for generating variable names used in RPN expressions.
ExprVars ¶
ExprVars(
stop: SupportsIndex | ExprVars | HoldsVideoFormat | VideoFormatLike,
/,
*,
expr_src: bool = False,
)
ExprVars(
start: SupportsIndex,
stop: SupportsIndex,
step: SupportsIndex | None = 1,
/,
*,
expr_src: bool = False,
)
ExprVars(
start_stop: SupportsIndex | ExprVars | HoldsVideoFormat | VideoFormatLike,
stop: SupportsIndex | None = None,
step: SupportsIndex | None = None,
/,
*,
expr_src: bool = False,
)
Bases: Sequence[str], Iterator[str]
A helper class for generating variable names used in RPN expressions.
Initialize an ExprVars instance.
Parameters:
-
(start_stop¶SupportsIndex | ExprVars | HoldsVideoFormat | VideoFormatLike) –A start index or an object from which to infer the number of variables (e.g., video format).
-
(stop¶SupportsIndex | None, default:None) –Stop index (exclusive). Required only if
start_stopis a numeric start value. -
(step¶SupportsIndex | None, default:None) –Step size for iteration. Default to 1.
-
(expr_src¶bool, default:False) –Whether to use
srcXnaming or use alphabetic variables.
Raises:
-
CustomIndexError–If
startis negative orstopis not greater thanstart. -
CustomTypeError–If invalid types are provided.
Methods:
-
cycle–An infinite generator of variable names, looping through
EXPR_VARSthen continuing withsrcXstyle. -
get_var–Get a variable name for a specific index.
Attributes:
-
curr(int) –Current index in iteration.
-
expr_src(bool) –If True, variables are named as
src0,src1, etc. Otherwise, "x", "y", "z", "a" and so on. -
start(int) –Starting index for variable generation (inclusive).
-
step(int) –Step size for iteration.
-
stop(int) –Ending index for variable generation (exclusive).
Source code in vsexprtools/util.py
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
expr_src instance-attribute ¶
If True, variables are named as src0, src1, etc. Otherwise, "x", "y", "z", "a" and so on.
cycle classmethod ¶
An infinite generator of variable names, looping through EXPR_VARS then continuing with srcX style.
Returns:
Source code in vsexprtools/util.py
174 175 176 177 178 179 180 181 182 183 | |
get_var classmethod ¶
get_var(value: SupportsIndex) -> str
Get a variable name for a specific index.
Parameters:
-
(value¶SupportsIndex) –Index to convert to variable name.
Returns:
-
str–The variable name.
Raises:
-
CustomIndexError–If the index is negative.
Source code in vsexprtools/util.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |