Skip to main content

Branch statement analysis and state decomposition for Python 3.8+

Project description

Python Branch Statement Analyzer

Documentation Status

The purpose of this library is two-fold:

  1. Detect independent paths through a function and represent all paths as a fully-connected Kripke Structure.
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

branch_statement_analyzer-1.0.0.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

branch_statement_analyzer-1.0.0-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page