(
self,
expr: str,
uservars: dict[str, Any] | None = None,
**kwargs,
)
| 146 | """ |
| 147 | |
| 148 | def __init__( |
| 149 | self, |
| 150 | expr: str, |
| 151 | uservars: dict[str, Any] | None = None, |
| 152 | **kwargs, |
| 153 | ) -> None: |
| 154 | |
| 155 | self.append_mode = False |
| 156 | """The append mode for user-provided output containers.""" |
| 157 | self.maindim = 0 |
| 158 | """Common main dimension for inputs in expression.""" |
| 159 | self.names: list[str] = [] |
| 160 | """The names of variables in expression (list).""" |
| 161 | self.out: ContainerType | None = None |
| 162 | """The user-provided container (if any) for the expression outcome.""" |
| 163 | self.o_start: int | None = None |
| 164 | """The start range selection for the user-provided output.""" |
| 165 | self.o_stop: int | None = None |
| 166 | """The stop range selection for the user-provided output.""" |
| 167 | self.o_step: int | None = None |
| 168 | """The step range selection for the user-provided output.""" |
| 169 | self.shape: tuple[int, ...] | None = None |
| 170 | """Common shape for the arrays in expression.""" |
| 171 | self.start, self.stop, self.step = (None,) * 3 |
| 172 | self.start: int | None = None |
| 173 | """The start range selection for the input.""" |
| 174 | self.stop: int | None = None |
| 175 | """The stop range selection for the input.""" |
| 176 | self.step: int | None = None |
| 177 | """The step range selection for the input.""" |
| 178 | self.values: list = [] |
| 179 | """The values of variables in expression (list).""" |
| 180 | |
| 181 | self._compiled_expr: ne.interpreter.NumExpr | None = None |
| 182 | """The compiled expression.""" |
| 183 | self._single_row_out: np.ndarray | None = None |
| 184 | """A sample of the output with just a single row.""" |
| 185 | |
| 186 | # First, get the signature for the arrays in expression |
| 187 | vars_ = self._required_expr_vars(expr, uservars) |
| 188 | context = ne.necompiler.getContext(kwargs) |
| 189 | self.names, _ = ne.necompiler.getExprNames(expr, context) |
| 190 | |
| 191 | # Raise a ValueError in case we have unsupported objects |
| 192 | for name, var in vars_.items(): |
| 193 | if type(var) in (int, float, str): |
| 194 | continue |
| 195 | if not isinstance(var, (tb.Leaf, tb.Column)): |
| 196 | if hasattr(var, "dtype"): |
| 197 | # Quacks like a NumPy object |
| 198 | continue |
| 199 | raise TypeError("Unsupported variable type: %r" % var) |
| 200 | objname = var.__class__.__name__ |
| 201 | if objname not in ("Array", "CArray", "EArray", "Column"): |
| 202 | raise TypeError("Unsupported variable type: %r" % var) |
| 203 | |
| 204 | # NumPy arrays to be copied? (we don't need to worry about |
| 205 | # PyTables objects, as the reads always return contiguous and |
nothing calls this directly
no test coverage detected