ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
preprocessor.numpy_constructor_mixin.NumpyConstructorMixin Class Reference
Inheritance diagram for preprocessor.numpy_constructor_mixin.NumpyConstructorMixin:
[legend]

Protected Member Functions

 _record_numpy_import (self, node)
 _numpy_constructor_name (self, node)
 _bind_numpy_constructor_call (self, node)
 _bind_numpy_parameters (self, name, node)
 _spell_numpy_constructor_call (self, name, node, bound)
 _is_pure_numpy_argument (cls, node)
 _unpacked_linspace_call (self, node)
 _split_linspace_retstep (self, node)
 _retstep_bound_arguments (self, call)

Static Protected Member Functions

 _bind_arange_stop (node, bound)
 _reads_unpacked_target (node, bound)
 _linspace_step (bound, div)

Static Protected Attributes

dict _NUMPY_CONSTRUCTOR_SIGNATURES
dict _NUMPY_REQUIRED_PARAMS

Detailed Description

Spell a NumPy constructor call in the one form the frontend reads.

The frontend reads the leading value parameters of a constructor
positionally and the others as keywords. Binding them here gives every
reader the same call; a call CPython rejects raises its TypeError when it
runs, after its arguments are evaluated.

Member Function Documentation

◆ _bind_arange_stop()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._bind_arange_stop ( node,
bound )
staticprotected
`arange(n)` is `arange(0, n)`: a lone start given by position is the stop.

◆ _bind_numpy_constructor_call()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._bind_numpy_constructor_call ( self,
node )
protected
Rewrite a NumPy constructor call to its canonical form in place.

Returns the call lowered to a raising expression when its arguments
do not bind, and None otherwise.

◆ _bind_numpy_parameters()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._bind_numpy_parameters ( self,
name,
node )
protected

◆ _is_pure_numpy_argument()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._is_pure_numpy_argument ( cls,
node )
protected

◆ _linspace_step()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._linspace_step ( bound,
div )
staticprotected

◆ _numpy_constructor_name()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._numpy_constructor_name ( self,
node )
protected

◆ _reads_unpacked_target()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._reads_unpacked_target ( node,
bound )
staticprotected
Whether start or stop reads a name the unpacking rebinds: the step,
computed after the array, would read the rebound name.

◆ _record_numpy_import()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._record_numpy_import ( self,
node )
protected
Remember the names a module binds to numpy and its constructors.

◆ _retstep_bound_arguments()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._retstep_bound_arguments ( self,
call )
protected
The bound arguments of a `retstep=True` call whose step can be
computed here: constant num and endpoint, start and stop safe to read
twice. None otherwise.

◆ _spell_numpy_constructor_call()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._spell_numpy_constructor_call ( self,
name,
node,
bound )
protected

◆ _split_linspace_retstep()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._split_linspace_retstep ( self,
node )
protected
`a, s = np.linspace(..., retstep=True)` as `a = np.linspace(...)`
followed by `s = step`, the step NumPy returns: (stop - start) / div,
or NaN when div, num - 1 with the endpoint and num without it, is not
positive. Only for arguments that are safe to read twice.

◆ _unpacked_linspace_call()

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._unpacked_linspace_call ( self,
node )
protected
The linspace call of `a, s = np.linspace(...)`, or None.

Member Data Documentation

◆ _NUMPY_CONSTRUCTOR_SIGNATURES

preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._NUMPY_CONSTRUCTOR_SIGNATURES
staticprotected
Initial value:
= {
"arange": (("start", "stop", "step", "dtype"), 3, ("device", "like")),
"linspace":
(("start", "stop", "num", "endpoint", "retstep", "dtype", "axis"), 3, ("device", )),
"full": (("shape", "fill_value", "dtype", "order"), 2, ("device", "like")),
"zeros": (("shape", "dtype", "order"), 1, ("device", "like")),
"ones": (("shape", "dtype", "order"), 1, ("device", "like")),
"eye": (("N", "M", "k", "dtype", "order"), 2, ("device", "like")),
"identity": (("n", "dtype"), 1, ("like", )),
"array": (("object", "dtype"), 1, ("copy", "order", "subok", "ndmin", "like")),
}

◆ _NUMPY_REQUIRED_PARAMS

dict preprocessor.numpy_constructor_mixin.NumpyConstructorMixin._NUMPY_REQUIRED_PARAMS
staticprotected
Initial value:
= {
"linspace": ("start", "stop"),
"full": ("shape", "fill_value"),
"zeros": ("shape", ),
"ones": ("shape", ),
"eye": ("N", ),
"identity": ("n", ),
"array": ("object", ),
}

The documentation for this class was generated from the following file: