Skip to main content

A collection of AST-based analysis and transformation passes

Project description

AST Transforms

A collection of Python AST-based code analysis and transformations.

Installation

pip install astpass

Usage

import ast
import numpy as np
from astpass.passes import shape_analysis

# Setup inputs
tree = ast.parse("a + 1")
runtime_vals = {"a": np.random.randn(3, 4)}

# Run static shape analysis
shape_info = shape_analysis.analyze(tree, runtime_vals)

# Print analysis results
for node, shape in shape_info.items():
    print(ast.unparse(node), shape)

##### Should print #####
# a (3, 4)
# 1 ()
# a + 1 (3, 4)

Passes

  • shape_analysis – returns a dictionary where each node is mapped to a shape.
  • vector_op_to_loop - transforms 1D array expressions into explicit loops.
  • To add more ...

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

astpass-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

astpass-0.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file astpass-0.1.0.tar.gz.

File metadata

  • Download URL: astpass-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for astpass-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af95462023282bda1eb9b3ce7a83e3296d3628d54b78125d5c72c4a4e6e0fc89
MD5 ec59249c2634bb38f88e47e9fb573d85
BLAKE2b-256 0fa758d39b26e420be75142cf9e8a70bd6ef7ed88358daf90530cf0ef43488bf

See more details on using hashes here.

File details

Details for the file astpass-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: astpass-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for astpass-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efcab1a4ad70179d09bf6bd4077b48ea51e27ea8c1e4de873a2e2266359d0d09
MD5 7b0dfc01e582a6336a94b946817f8142
BLAKE2b-256 a1fc8c5b544a9c59a79a19717a766613782c3e151027affb10c553a2ebed0fa0

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