Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ classifiers = [
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",
]
Comment thread
charlesbmi marked this conversation as resolved.
Comment on lines 31 to 35

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


[project.urls]
Expand All @@ -49,6 +46,7 @@ uff = [
vis = [
"matplotlib>=3.9.4",
"colorcet>=3.1.0",
"numpy>=1.25.0",
]
examples = [
"pymust>=0.1.8",
Expand Down
5 changes: 4 additions & 1 deletion src/mach/_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
except ImportError as err:
raise ImportError("matplotlib is required for visualization. Install with: pip install mach-beamform[vis]") from err

import numpy as np
try:
import numpy as np
except ImportError as err:
raise ImportError("numpy is required for visualization. Install with: pip install mach-beamform[vis]") from err
from matplotlib.colors import Colormap


Expand Down
38 changes: 30 additions & 8 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading