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.1.tar.gz (16.2 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.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: astpass-0.1.1.tar.gz
  • Upload date:
  • Size: 16.2 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.1.tar.gz
Algorithm Hash digest
SHA256 4eb727e8f5278526f2ff217cd2570eb78fbc346d46388f7425b309f826117121
MD5 0b1f3279f0fe9ceb86adc5d8ef09b921
BLAKE2b-256 a426eba1864d96c090bd60328d142c576020fb8e41d88d193a9676d5139dbce3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: astpass-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ae8f104d51f50ba80b2dfd16cf1ff627bc7a61a69ab3120caac5ddad20e9cf
MD5 cf915d436359f2f32593e868199528e0
BLAKE2b-256 5cd3d9a92dec11cf4c00464869a15f3706bc19b502ce9e11124a5bb554d517a9

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