copy-and-mutate for Equinox modules: a context manager for ergonomic, in-place-feeling edits of frozen Equinox modules.
Project description
eqx-cam
Copy-and-mutate for Equinox modules.
An Equinox port of copy_and_mutate from jax_dataclasses by Brent Yi. See Attribution.
Equinox modules are frozen dataclasses. Editing a deeply nested field normally
means threading replacement values back out through eqx.tree_at (or nested
dataclasses.replace) calls. copy_and_mutate can often be more convenient.
It just yields a temporarily mutable copy so you can just change whatever
you need and get back your eqx.Module.
import jax
import equinox as eqx
from eqx_cam import copy_and_mutate
model = eqx.nn.MLP(2, 2, 8, 2, key=jax.random.key(0))
with copy_and_mutate(model) as m:
m.layers[0].weight = m.layers[0].weight.at[0, 0].set(1.0)
# `model` is unchanged; `m` is a normal frozen Equinox module.
Attribution
This package is an independent reimplementation of the copy_and_mutate
context manager from jax_dataclasses
by Brent Yi, adapted to target equinox.Module rather than
jax_dataclasses pytree dataclasses. The idea of temporarily unfreezing a pytree
came directly from that project.
Development
uv sync # install with dev dependencies
uv run pytest # run the test suite
uv run ruff check # lint
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eqx_cam-0.1.0.tar.gz.
File metadata
- Download URL: eqx_cam-0.1.0.tar.gz
- Upload date:
- Size: 41.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddae36113bafc3caa1a2b7227d9e9d09d643adbfa380b35bc118c66646afe93e
|
|
| MD5 |
e166b4f1f17936843ae70fdec1975cb8
|
|
| BLAKE2b-256 |
c27856c54866fab60e1468d500ceee4db10da668a9c3dcf686822fbad482815b
|
Provenance
The following attestation bundles were made for eqx_cam-0.1.0.tar.gz:
Publisher:
publish.yml on mishmish66/eqx-cam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eqx_cam-0.1.0.tar.gz -
Subject digest:
ddae36113bafc3caa1a2b7227d9e9d09d643adbfa380b35bc118c66646afe93e - Sigstore transparency entry: 1931314764
- Sigstore integration time:
-
Permalink:
mishmish66/eqx-cam@303eb1cf770494e9cb07418a905c3d4ab8f5d8fa -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mishmish66
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@303eb1cf770494e9cb07418a905c3d4ab8f5d8fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file eqx_cam-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eqx_cam-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
440604dd00b85219f5597df63009a3118cbd6d13ff9694e97170ec0b7eb2671d
|
|
| MD5 |
8cc8207dcee4a746cf76638cdf72ca15
|
|
| BLAKE2b-256 |
a3c46f2580a8d771b095b8e4850b6f53785114fa7ffc465ffb63ffe1397c5430
|
Provenance
The following attestation bundles were made for eqx_cam-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mishmish66/eqx-cam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eqx_cam-0.1.0-py3-none-any.whl -
Subject digest:
440604dd00b85219f5597df63009a3118cbd6d13ff9694e97170ec0b7eb2671d - Sigstore transparency entry: 1931314827
- Sigstore integration time:
-
Permalink:
mishmish66/eqx-cam@303eb1cf770494e9cb07418a905c3d4ab8f5d8fa -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mishmish66
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@303eb1cf770494e9cb07418a905c3d4ab8f5d8fa -
Trigger Event:
push
-
Statement type: