Evaluate a mutli-line expression element-wise, using NumPy broadcasting rules. This function is provided as a convience for porting code from `numexpr` 2.6 to the new release. In general new users are advised to use the :code:`NumExpr` class instead. Arguments ^^^^^^^^
(expr: str, name: str=None, lib: int=LIB_STD,
local_dict: Dict=None, global_dict: Dict=None, out: np.ndarray=None,
order: str='K', casting: int=CAST_SAFE, optimization: int=OPT_MODERATE,
library: int=LIB_STD, checks: int=CHECK_ALL, stackDepth: int=1)
| 210 | |
| 211 | # TODO: implement non-default casting, optimization, library, checks |
| 212 | def evaluate(expr: str, name: str=None, lib: int=LIB_STD, |
| 213 | local_dict: Dict=None, global_dict: Dict=None, out: np.ndarray=None, |
| 214 | order: str='K', casting: int=CAST_SAFE, optimization: int=OPT_MODERATE, |
| 215 | library: int=LIB_STD, checks: int=CHECK_ALL, stackDepth: int=1): |
| 216 | ''' |
| 217 | Evaluate a mutli-line expression element-wise, using NumPy broadcasting |
| 218 | rules. This function is provided as a convience for porting code from |
| 219 | `numexpr` 2.6 to the new release. In general new users are advised to use |
| 220 | the :code:`NumExpr` class instead. |
| 221 | |
| 222 | Arguments |
| 223 | ^^^^^^^^^ |
| 224 | |
| 225 | * :code:`expr`: expr is a string forming an expression, like :code:`c = 2*a + 3*b`. |
| 226 | |
| 227 | The values for :code:`a` and :code:`b` will by default be taken from the calling |
| 228 | function's frame (through use of :code:`sys._getframe()`). Alternatively, they |
| 229 | can be specifed using the :code:`local_dict` argument. |
| 230 | |
| 231 | Multi-line statements, or semi-colon seperated statements, are supported. |
| 232 | |
| 233 | Keyword Arguments |
| 234 | ^^^^^^^^^^^^^^^^^ |
| 235 | |
| 236 | :code:`name` : DEPRECATED |
| 237 | use wisdom functions instead. |
| 238 | |
| 239 | :code:`local_dict` : dictionary, optional |
| 240 | A dictionary that replaces the local operands in current frame. This is |
| 241 | generally required in Cython, as Cython does not populate the calling |
| 242 | frame variables according to Python standards. |
| 243 | |
| 244 | :code:`global_dict` : DEPRECATED |
| 245 | A dictionary that replaces the global operands in current frame. |
| 246 | Setting to {} can speed operations if you do not call globals. |
| 247 | global_dict was deprecated as there is little reason for the |
| 248 | user to maintain two dictionaries of arrays. |
| 249 | |
| 250 | :code:`out` : DEPRECATED |
| 251 | use assignment in expr (i.e. :code:`'out=a*b'`) instead. |
| 252 | |
| 253 | :code:`order:code:`: { :code:`'K'`}, optional |
| 254 | Controls the iteration order for operands. Currently only :code:`'K'` |
| 255 | (default NumPy array ordering) is supported in NumExpr3. |
| 256 | |
| 257 | :code:`casting:code:` : {:code:`CAST_SAFE`|:code:`'safe'`}, optional |
| 258 | |
| 259 | Controls what kind of data casting may occur when making a copy or |
| 260 | buffering. Explicit cast functions are also supported, see the user guide. |
| 261 | |
| 262 | :code:`optimization`: {:code:`OPT_MODERATE`}, optional |
| 263 | Controls what level of optimization the compiler will attempt to |
| 264 | perform on the expression to speed its execution. :code:`OPT_MODERATE` |
| 265 | performs simple optimizations, such as minimizing the number of temporary arrays |
| 266 | |
| 267 | :code:`library`: {:code:`LIB_STD`}, optional |
| 268 | Indicates which library to use for calculations. The library must |
| 269 | have been linked during the C-extension compilation, such that the |