Metadata-Version: 2.4
Name: lispyn
Version: 0.33.0a1
Summary: A new way to write and run machine-learning experiments with Hy, PyTorch and Jupyter.
Author: Eduardo J. Barrios
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/edujbarrios/lispyn
Project-URL: Repository, https://github.com/edujbarrios/lispyn
Project-URL: Issues, https://github.com/edujbarrios/lispyn/issues
Project-URL: Documentation, https://github.com/edujbarrios/lispyn/blob/main/supported_macros/README.md
Keywords: lisp,hy,jupyter,pytorch,notebooks,machine-learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: hy<2.0,>=1.0
Requires-Dist: nbformat<6,>=5.8
Requires-Dist: packaging>=23
Requires-Dist: nbclient<1,>=0.9
Requires-Dist: ipykernel>=6
Requires-Dist: matplotlib>=3.8
Provides-Extra: notebook
Requires-Dist: nbclient<1,>=0.9; extra == "notebook"
Requires-Dist: ipykernel>=6; extra == "notebook"
Provides-Extra: data
Requires-Dist: pandas>=2; extra == "data"
Provides-Extra: vision
Requires-Dist: torch; extra == "vision"
Requires-Dist: torchvision; extra == "vision"
Requires-Dist: pillow; extra == "vision"
Provides-Extra: audio
Requires-Dist: torch; extra == "audio"
Requires-Dist: torchaudio; extra == "audio"
Requires-Dist: torchcodec; extra == "audio"
Provides-Extra: text
Requires-Dist: torch; extra == "text"
Provides-Extra: peft
Requires-Dist: peft>=0.15; extra == "peft"
Requires-Dist: transformers<5,>=4.45; extra == "peft"
Provides-Extra: plots
Requires-Dist: matplotlib>=3.8; extra == "plots"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: nbclient<1,>=0.9; extra == "dev"
Requires-Dist: ipykernel>=6; extra == "dev"
Dynamic: license-file

# Lispyn

**Write research experiments in Hy (Lisp for Python) and run them directly or as standard Jupyter notebooks.**

Lispyn provides macros for **PyTorch, NumPy, pandas and Matplotlib** while keeping your Python libraries and models.

[![PyPI version](https://img.shields.io/pypi/v/lispyn?label=PyPI%20version)](https://pypi.org/project/lispyn/) [![CI on main](https://github.com/edujbarrios/lispyn/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/edujbarrios/lispyn/actions/workflows/tests.yml?query=branch%3Amain) [![Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)

## Why use it for research?

**Less boilerplate.** For example, [the real PyTorch quickstart](examples/quickstart.hy) uses a macro to create separate train, validation and held-out test subsets:

```hy
(setv [training validation held-out]
  (train-val-test dataset :validation-fraction 0.25
    :test-fraction 0.25 :seed seed))
```

**Catch invalid data early.** [The runnable NumPy/pandas example](examples/validate_inputs.hy) checks shape and finite values without writing a manual validation loop:

```hy
(require lispyn.macros [assert-finite assert-shape])
(import numpy :as np)
(import pandas :as pd)

(setv features (np.array [[1.0 2.0] [3.0 4.0]]))
(assert-shape features [2 2] :name "features")
(assert-finite features :name "features")
```

**One source, three modes.** The same [hello.hy](examples/hello.hy) can run in a terminal, become an unexecuted notebook, or produce a notebook with saved outputs. See the three commands below.

**Inspectable research artifacts.** The [quickstart](examples/quickstart.hy) renders a report from actual PyTorch training results, which can be reviewed in the [executed notebook](example_generated_notebooks/quickstart_executed.ipynb):

```hy
(require lispyn.macros [report-run narrate metric-table])
(import lispyn.training [evaluate-metrics])
(report-run run :title "PyTorch baseline · recorded metrics")
```

These examples help organize research; Lispyn cannot guarantee reproducibility or scientific validity.

## Install

```bash
pip install lispyn
```

Hy, Jupyter execution and Matplotlib are included. NumPy is available through Matplotlib; for pandas install `pip install "lispyn[data]"`. **PyTorch is installed separately** for your [CPU/GPU setup](https://pytorch.org/get-started/locally/).

## How it works: three ways to run Hy

Get the [hello.hy example](examples/hello.hy) (no dataset, no PyTorch):

```bash
git clone https://github.com/edujbarrios/lispyn.git
cd lispyn
```

**1. Run the Hy file** — terminal output, no notebook:

```bash
lispyn run examples/hello.hy
```

**2. Generate a Jupyter notebook** — `hello.ipynb`, **Nothing is executed**:

```bash
lispyn build examples/hello.hy -o hello.ipynb
```

**3. Generate and execute the notebook** — `hello-executed.ipynb` **saves the executed cells** and outputs:

```bash
lispyn execute examples/hello.hy -o hello-executed.ipynb
```

Check for `2 + 3 + 5 = 10` and `Lispyn checks passed!`. Building compiles Hy into ordinary Python/Markdown notebook cells without executing it. **Only compile trusted Hy:** macros are not sandboxed.

## All macros and examples

**[Full reference: 51 macros, arguments, dependencies and Hy examples](supported_macros/README.md)** — grouped by PyTorch, Matplotlib, pandas, NumPy, notebook authoring and research reporting.

More runnable sources: [PyTorch quickstart](examples/quickstart.hy) (try `lispyn execute examples/quickstart.hy`), [data profiles](examples/data_profiles.hy) and [input assertions](examples/validate_inputs.hy). A cloned repository also offers `pip install -r requirements.txt` for an optional full research environment.

*Created by Eduardo J. Barrios · [Apache-2.0](LICENSE) · [Citation](CITATION.cff) · Experimental alpha software.*
