Pts.py
Pts.py is an experimental librar for for creative coding, visualization and play. It explores principles of visual composability in code. I started this series of explorations, first with an idea about a simple point (Pt, 2015), then an idea about connecting them, (Pts.js, 2017). Starting anew in Pts.py (2025), this is again both a software library and a speculative playground.
Install python
Pts.py requires Python 3.10+. If you're new to python and don't have 3.10+ (check your version with python --version), or you want to create a virtual environment, create it via conda or uv.
Option 1: setup with uv
Install uv and create a virtual environment:
uv venv .venv --python 3.11
source .venv/bin/activate # Windows: .venv\Scripts\activate
Option 2: setup with conda
First download and install miniconda
conda create --name my_env python=3.11
conda activate my_env
Get Pts.py
The simplest way is to install via pip install ptspy, or uv pip install ptspy if you're using uv.
To develop from source and run notebooks in this repo, first clone this repo and then set up with uv or pip.
Recommended reproducible setup with uv:
uv sync --extra dev
source .venv/bin/activate
If you also want the optional OpenGL stack:
uv sync --extra dev --extra opengl
source .venv/bin/activate
If you also want the optional cupy switching feature, first install the corresponding cupy package.
# if using Nvidia CUDA 12.x
uv pip install cupy-cuda12x
Equivalent pip setup:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -e '.[dev]'
Add the OpenGL extra if needed:
python -m pip install -e '.[dev,opengl]'
Run notebooks
To run a jupyter notebook in /notebooks, first add your venv to the list of kernels:
python -m ipykernel install --user --name=your_env_name --display-name "your_env_name"
Then start jupyter notebook, open a notebook and then select the correct kernel.
Note: mediapy is used in notebook for displaying videos. If getting BrokenPipe error in a conda env, install conda install ffmpeg
Quick start
After your environment is set up, start with the quick start guide, or browse the source notebooks on GitHub.
Testing
You can run the tests and lint the code via these commands.
# Run all tests
pytest
# Run specific test file
pytest tests/core/test_elements.py
# Run specific test function
pytest tests/core/test_elements.py::test_partial_optional_with_placeholder_allows_curry_and_fill
# Check code with ruff
ruff check .
# Format code with ruff
ruff format
# Type checking (pyright configured in pyrightconfig.json)
pyright
# Build package artifacts
python -m build
# Verify README / metadata render correctly for PyPI
twine check dist/*
# Visual regression tests
pytest tests/visual/ # Run visual tests
pytest tests/visual/ --update-groundtruth # Add/replace groundtruth files
pytest tests/visual/ --rebuild-groundtruth # Wipe and regenerate all groundtruth
pytest tests/visual/ --visual-tolerance=2 # Allow pixel tolerance (default: 0)
There is also a convenience script for the main test suites:
./tests.sh unit
./tests.sh visual
./tests.sh bench
./tests.sh all
Benchmark baselines
Use the benchmark mode in tests.sh to save and compare local performance baselines on the same machine.
# Run all benchmarks
./tests.sh bench
# Save a benchmark baseline with an automatic name
./tests.sh bench --save
# Compare against the latest compatible saved baseline
./tests.sh bench --compare
# Compare against a named baseline
./tests.sh bench --compare --with=barcelona_gpu_baseline
# Fail if mean performance regresses by more than 8%
./tests.sh bench --compare --threshold=8%
./tests.sh bench --compare --with=barcelona_gpu_baseline --threshold=8%
# Use a slower, more stable measurement mode for release verification
./tests.sh bench --save --precise
./tests.sh bench --compare --precise
./tests.sh bench --compare --precise --threshold=5%
Generate docs
To regenerate the API documentation (JSON + Markdown) from source docstrings:
./docs.sh
Notes on contribution
The best way to contribute to this project would be to try it out and give feedback. Please feel free to create an issue or contact me in social media. PRs are closed until this project reaches a stable milestone. See CONTRIBUTING.md for more.
Citation
If you use Pts.py in your research or creative work, please cite it as follows:
Ngan, W. (2026). Pts.py: Visual Thinking in Code [Computer software]. https://ptspy.org
BibTeX:
@software{ptspy2026,
author = {Ngan, William},
title = {Pts.py: Visual Thinking in Code},
year = {2026},
url = {https://ptspy.org},
repository = {https://github.com/williamngan/ptspy}
}
License
Copyright 2026-present William Ngan and contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Metadata
Release files for ptspy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ptspy-0.1.0.tar.gz | 3.6 MB | Without provenance | Details for ptspy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ptspy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ptspy-0.1.0-py3-none-any.whl |
Total release size: 3.7 MB
Release files / ptspy-0.1.0.tar.gz
| Download URL | ptspy-0.1.0.tar.gz |
|---|---|
| Size | 3.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7d4d42a3cd14439709c82d090c76ab07adfa58ab3f73eb2afdf21632ba9057a
|
|
BLAKE2b-256 checksum How to use checksums |
8fdb528f49c0042b148ef8154a4b9e7cfe38168136da657c697b151b291a4851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.4
|
Release files / ptspy-0.1.0-py3-none-any.whl
| Download URL | ptspy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 76.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
486f1f3d77271b260cd4f213c86c9fd6bfea84b2a11263f342317d39e5160183
|
|
BLAKE2b-256 checksum How to use checksums |
8cebf2b0b9991d582b26824188cc7e8d9f9b74adeddd9fcd9dee9b379b1e7c7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.4
|
Security for ptspy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.