Skip to content

chore: bump jaxtyping to 0.3.4 and drop numpy workaround#67

Merged
charlesbmi merged 3 commits into
mainfrom
chore/jaxtyping-0.3.4
Jun 15, 2026
Merged

chore: bump jaxtyping to 0.3.4 and drop numpy workaround#67
charlesbmi merged 3 commits into
mainfrom
chore/jaxtyping-0.3.4

Conversation

@charlesbmi

@charlesbmi charlesbmi commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Bump jaxtyping from >=0.2.36 to >=0.3.4
  • Remove the explicit numpy>=1.25.0 core dependency that was only needed as a workaround for jaxtyping#360

jaxtyping v0.3.4 includes the fix from patrick-kidger/jaxtyping#361, so mach can import without numpy installed in the base environment. Numpy remains available via optional extras (e.g. uff).

Test plan

  • CI passes
  • uvx --with mach --python 3.12 python -c "import mach" works without numpy in the base install

Made with Cursor

jaxtyping 0.3.4 no longer crashes when numpy is absent, so the explicit
numpy pin added for issue #360 is no longer needed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@qodo-code-review

qodo-code-review Bot commented Jun 15, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0)

Grey Divider


Action required

1. Lockfile dependency drift ✓ Resolved 🐞 Bug ☼ Reliability
Description
pyproject.toml now requires jaxtyping>=0.3.4 and drops core numpy, but uv.lock still records
the old requirements, so uv sync --frozen / uv lock --locked will fail or install the previous
dependency set.
Code

pyproject.toml[R31-35]

dependencies = [
    "array-api-compat>=1.11.0",
    "einops>=0.8.0",
-    "jaxtyping>=0.2.36",
-    # TODO: remove numpy dependency once jaxtyping no longer implicitly depends on numpy
-    # https://github.com/patrick-kidger/jaxtyping/issues/360
-    "numpy>=1.25.0",
+    "jaxtyping>=0.3.4",
]
Evidence
The repository explicitly uses the lockfile for dependency installation and validation; the current
uv.lock still encodes the old base requirements (including core numpy and older jaxtyping
constraint/version), which contradicts the new pyproject.toml requirements.

pyproject.toml[31-35]
uv.lock[1231-1241]
uv.lock[1671-1684]
.github/actions/setup-python-env/action.yml[17-28]
Makefile[38-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pyproject.toml` was updated (bumped `jaxtyping`, removed core `numpy`), but `uv.lock` was not regenerated. This breaks frozen installs (`uv sync --frozen`) and locked checks (`uv lock --locked`), and can cause CI/dev to keep using the old dependency set.

### Issue Context
- CI uses `uv sync --frozen`, which requires `uv.lock` to match `pyproject.toml`.
- The repo Makefile enforces lock consistency via `uv lock --locked`.

### Fix Focus Areas
- uv.lock[1231-1241]
- uv.lock[1671-1684]
- pyproject.toml[31-35]
- .github/actions/setup-python-env/action.yml[17-28]
- Makefile[38-60]

### What to change
1. Run `uv lock` (or `uv lock --upgrade-package jaxtyping` if preferred) to regenerate `uv.lock`.
2. Ensure the regenerated lock:
  - reflects `jaxtyping>=0.3.4`
  - no longer lists `numpy` as an unconditional base requirement
3. Commit the updated `uv.lock`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Vis extra missing numpy ✓ Resolved 🐞 Bug ≡ Correctness
Description
After dropping core numpy, mach._vis fails to import because it unconditionally imports numpy,
but the vis optional dependency set does not include numpy (so pip install mach-beamform[vis]
is insufficient).
Code

pyproject.toml[R31-35]

dependencies = [
    "array-api-compat>=1.11.0",
    "einops>=0.8.0",
-    "jaxtyping>=0.2.36",
-    # TODO: remove numpy dependency once jaxtyping no longer implicitly depends on numpy
-    # https://github.com/patrick-kidger/jaxtyping/issues/360
-    "numpy>=1.25.0",
+    "jaxtyping>=0.3.4",
]
Evidence
The vis extra currently installs matplotlib/colorcet only, while mach._vis imports numpy
unconditionally; removing numpy from core dependencies makes mach-beamform[vis] insufficient to
import mach._vis.

pyproject.toml[31-35]
pyproject.toml[40-49]
src/mach/_vis.py[5-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`src/mach/_vis.py` imports `numpy` at module import time, but after removing `numpy` from core dependencies, installing `mach-beamform[vis]` does not install `numpy`. This causes `import mach._vis` (and anything that imports it) to fail with `ModuleNotFoundError: numpy`.

### Issue Context
`mach._vis` already provides a helpful install hint for missing `matplotlib`, but missing `numpy` will now be the failure mode in a base environment without numpy.

### Fix Focus Areas
- pyproject.toml[40-49]
- src/mach/_vis.py[5-12]
- pyproject.toml[31-35]

### What to change
- Add `numpy>=1.25.0` (or an appropriate minimum) to `[project.optional-dependencies].vis`.
- (Optional hardening) Wrap the `import numpy as np` in a `try/except ImportError` and raise a targeted message similar to the existing matplotlib guidance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Examples extra missing numpy 🐞 Bug ≡ Correctness
Description
After removing core numpy, importing mach.io.must (and mach.io.uff) will fail with
ModuleNotFoundError for numpy/scipy unless users also install the uff extra. The
project.optional-dependencies.examples extra does not include numpy/scipy (or
mach-beamform[uff]), so pip install mach-beamform[examples] is no longer sufficient for example
I/O usage.
Code

pyproject.toml[R31-35]

dependencies = [
    "array-api-compat>=1.11.0",
    "einops>=0.8.0",
-    "jaxtyping>=0.2.36",
-    # TODO: remove numpy dependency once jaxtyping no longer implicitly depends on numpy
-    # https://github.com/patrick-kidger/jaxtyping/issues/360
-    "numpy>=1.25.0",
+    "jaxtyping>=0.3.4",
]
Evidence
The PR removes core numpy, but mach.io.must/mach.io.uff still import numpy/scipy
unconditionally; meanwhile the examples extra does not include numpy/scipy whereas the uff
extra does, so installing only [examples] can no longer run example I/O code.

pyproject.toml[31-60]
src/mach/io/must.py[1-8]
src/mach/io/uff.py[8-13]
examples/doppler.py[48-61]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Core `numpy` was removed, but some example-facing modules (`mach.io.must`, `mach.io.uff`) still import `numpy`/`scipy` at module import time. As a result, users who install `mach-beamform[examples]` can still hit `ModuleNotFoundError` when running examples or using example I/O helpers.

## Issue Context
- `pyproject.toml` core deps no longer include `numpy`.
- `mach.io.must` imports `numpy` and `scipy.io` at import time.
- `mach.io.uff` imports `numpy` and `scipy.signal` at import time.
- The `examples` extra does not install `numpy`/`scipy` (while `uff` does).

## Fix Focus Areas
- pyproject.toml[31-60]
- src/mach/io/must.py[1-10]
- src/mach/io/uff.py[8-15]

### Suggested implementation direction
1) Update `[project.optional-dependencies].examples` to include either:
  - `mach-beamform[uff]` (preferred for consistency), or
  - explicit `numpy` + `scipy` requirements.
2) (Optional but recommended) Add `try/except ImportError` guards around `numpy`/`scipy` imports in `mach/io/must.py` and `mach/io/uff.py`, raising an error that clearly instructs `pip install mach-beamform[uff]` (or `[all]`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Update uv.lock after jaxtyping bump.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread pyproject.toml
Comment thread pyproject.toml
Comment on lines 31 to 35
dependencies = [
"array-api-compat>=1.11.0",
"einops>=0.8.0",
"jaxtyping>=0.2.36",
# TODO: remove numpy dependency once jaxtyping no longer implicitly depends on numpy
# https://github.com/patrick-kidger/jaxtyping/issues/360
"numpy>=1.25.0",
"jaxtyping>=0.3.4",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Vis extra missing numpy 🐞 Bug ≡ Correctness

After dropping core numpy, mach._vis fails to import because it unconditionally imports numpy,
but the vis optional dependency set does not include numpy (so pip install mach-beamform[vis]
is insufficient).
Agent Prompt
### Issue description
`src/mach/_vis.py` imports `numpy` at module import time, but after removing `numpy` from core dependencies, installing `mach-beamform[vis]` does not install `numpy`. This causes `import mach._vis` (and anything that imports it) to fail with `ModuleNotFoundError: numpy`.

### Issue Context
`mach._vis` already provides a helpful install hint for missing `matplotlib`, but missing `numpy` will now be the failure mode in a base environment without numpy.

### Fix Focus Areas
- pyproject.toml[40-49]
- src/mach/_vis.py[5-12]
- pyproject.toml[31-35]

### What to change
- Add `numpy>=1.25.0` (or an appropriate minimum) to `[project.optional-dependencies].vis`.
- (Optional hardening) Wrap the `import numpy as np` in a `try/except ImportError` and raise a targeted message similar to the existing matplotlib guidance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

qodo-code-review Bot commented Jun 15, 2026

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 00621ee

mach._vis imports numpy at module load time; after removing numpy from
core deps, mach-beamform[vis] must install it explicitly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@charlesbmi charlesbmi merged commit e1f84cb into main Jun 15, 2026
9 checks passed
@charlesbmi charlesbmi deleted the chore/jaxtyping-0.3.4 branch June 15, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant