infer_purity
Infer the purity of functions.
Given the code of a module, this function infers the purity of the functions inside a module. It uses the PurityAnalyzer to determine the purity of the functions in a module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code |
str | None
|
The source code of the module. If None is provided, the package data must be provided (or else an exception is raised). |
required |
module_name |
str
|
The name of the module, by default "". |
''
|
path |
str | None
|
The path of the module, by default None. |
None
|
results |
dict[NodeID, dict[NodeID, PurityResult]] | None
|
The results of all previously analyzed modules. The key is the NodeID of the module, the value is a dictionary of the purity results of the functions in the module. After the analysis of the module, the results are saved in this dictionary. All imported modules are saved in this dictionary too for further runtime reduction. Is None if no results are available. |
None
|
package_data |
PackageData | None
|
The module data of all modules the package. If provided, the references are resolved with the package data, else the module data is collected first. It is used for the inference of the purity between modules in the package. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
purity_results |
dict[NodeID, dict[NodeID, PurityResult]]
|
The purity results of the functions in the module. The key is the NodeID of the module, the value is a dictionary of the purity results of the functions in the module. |