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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file branch_statement_analyzer-1.0.0.tar.gz.

File metadata

  • Download URL: branch_statement_analyzer-1.0.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Linux/5.15.0-67-generic

File hashes

Hashes for branch_statement_analyzer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f770b9d85bb1958a643b5ad579b245b4eec49d1ec0c37966aa60b2e873631288
MD5 de2b642c6a5c327a16cbe8dc23eceab4
BLAKE2b-256 f82b541204b6e4cad51c1bd6d3654eda17ce91cece60b40597ebeaa7661c4cf2

See more details on using hashes here.

File details

Details for the file branch_statement_analyzer-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for branch_statement_analyzer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d98553c1b9443e790ee5d9f8329ec541d98a3f0011bbe25591afc3dee83daa55
MD5 827df73042e4c49367a3f3c869c723aa
BLAKE2b-256 34b596a494a209ec6c314c44f4c30c1642601ea223c3a9bce4d183db913e4ecd

See more details on using hashes here.

Supported by

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