Metadata-Version: 2.4
Name: astpass
Version: 0.1.1
Summary: A collection of AST-based analysis and transformation passes
Home-page: https://github.com/habanero-lab/astpass
Author: Tong Zhou
Author-email: zt9465@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: ast_comments
Provides-Extra: test
Requires-Dist: numpy; extra == "test"
Requires-Dist: pytest; extra == "test"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# AST Transforms

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

## Installation

```bash
pip install astpass
```

## Usage

```python
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 ...
