chore: pin numpy only where pymatgen needs it, and declare scipy for the core - #299
Merged
Merged
Conversation
…the core numpy<=1.26.4 sat in the core dependencies on pymatgen's behalf, but only the tools extra imports pymatgen. Every downstream package that used made's core alone -- lattices, reciprocal lattices, symmetry points -- was forced down to numpy 1.26 regardless. Worse, pip resolves the conflict with any package that wants numpy 2 by silently backtracking made rather than failing: q3's `pip install -e .[test,relax,build]` landed on mat3ra-made 2024.6.12, two years old and without mat3ra.made.reciprocal, and failed at import time. The pin moves into [tools], next to pymatgen. Verifying that turned up a second declaration bug: basis/__init__.py imports scipy.spatial at load time and material.py imports basis, but scipy was declared only in [tools], so a core install could not import Material. scipy moves to the core dependencies. Checked: - core on numpy 2.5.3 (scipy 1.18): test_cell, test_lattice, test_lattice_type_extended, test_reciprocal_lattice, test_symmetry_points, test_reciprocal_paths -- 76 passed; Material.create, its basis, cell volume and to_dict also work there. - [tools] still resolves numpy 1.26.4 with pymatgen 2024.4.13 and scipy 1.17.1, so pymatgen users are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Timur Bazhirov <timur@mat3ra.com>
VsevolodX
approved these changes
Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
numpy<=1.26.4sits in the core dependencies on pymatgen's behalf, but only thetoolsextra imports pymatgen. So every downstream package that uses made's core alone —Lattice,ReciprocalLattice, symmetry points, k-paths — is forced down to numpy 1.26, whether or not it touchestools.It is worse than a cap. When a downstream environment also wants numpy 2 (anything pulling the newest scipy does), pip resolves the conflict by silently backtracking made rather than failing. mat3ra/q3's
pip install -e ".[test,relax,build]"landed on mat3ra-made 2024.6.12 — two years old, predatingmat3ra.made.reciprocal— installed cleanly, and failed at import time in CI. The only workaround downstream is to cap numpy at 1.26.4 for the whole project.Change
numpy<=1.26.4moves from the core dependencies into[tools], next topymatgen==2024.4.13, which is the thing that needs it. Core keepsnumpyunpinned.basis/__init__.pyimportsscipy.spatialat load time andmaterial.pyimportsbasis, but scipy was declared only in[tools]— so a core-only install could not importMaterial. scipy moves to the core dependencies. That is the only scipy import outsidetools/.Verified
Core on numpy 2.5.3 (scipy 1.18.1), in a clean venv with only core + test deps:
Material.create, its basis, cell volume andto_dictalso work there. A scan of the 14 core modules for the APIs numpy 2.0 removed (np.float_,np.product,np.in1d,np.trapz, …) finds none.test_material.pyandtest_primitive_cell.pywere left out because they importtools(ASE) transitively.[tools]is unaffected — it still resolves numpy 1.26.4:The existing CI installs
[tests], which includesmat3ra-made[tools], so the Python test matrix keeps running on numpy 1.26.4 exactly as before.Downstream
mat3ra/q3#175 currently carries
numpy>=1.24,<=1.26.4andmat3ra-made>=2026.8.26.post0to keep pip from choosing the 2024 release. Once this merges and publishes, both bounds there can go.🤖 Generated with Claude Code