Branch statement analysis and state decomposition for Python 3.8+
Project description
Python Branch Statement Analyzer
The purpose of this library is two-fold:
- Detect independent paths through a function and represent all paths as a fully-connected Kripke Structure.
- Instrument a function to preserve the states of the conditional variables for an execution of the function and augment the return value of the function with the conditional variable states.
Path detection
TODO
Instrumentation
TODO
Usage
Decomposition of a function into a condition tree is accomplished by calling
the BranchTree.from_function
static method like so:
def myfunc(x):
if x <= 10:
return x**2
else:
return x*2
tree = BranchTree.from_function(myfunc)
Conversion of the BranchTree into a Kripke Structure can be accomplished by
calling the BranchTree.into_kripke
method once the function has been analyzed.
A function can be instrumented using the instrument_function
decorator, which
will return another function that accepts the same inputs and returns a tuple
containing the return value of the function and the states of the conditional
variables.
@instrument_function
def myfunc(x):
if x <= 10:
return x**2
else:
return x*2
states, retval = myfunc(8)
Documentation
Documentation for this project can be found on Read the Docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for branch_statement_analyzer-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f770b9d85bb1958a643b5ad579b245b4eec49d1ec0c37966aa60b2e873631288 |
|
MD5 | de2b642c6a5c327a16cbe8dc23eceab4 |
|
BLAKE2b-256 | f82b541204b6e4cad51c1bd6d3654eda17ce91cece60b40597ebeaa7661c4cf2 |
Hashes for branch_statement_analyzer-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d98553c1b9443e790ee5d9f8329ec541d98a3f0011bbe25591afc3dee83daa55 |
|
MD5 | 827df73042e4c49367a3f3c869c723aa |
|
BLAKE2b-256 | 34b596a494a209ec6c314c44f4c30c1642601ea223c3a9bce4d183db913e4ecd |