Replace removed np.bool8 alias with np.bool_ for NumPy 2.x#73
Open
stoiver wants to merge 1 commit into
Open
Conversation
np.bool8 was removed in NumPy 2.0, so SuperLink.reposition_junctions() (nsuperlink.py) and QualityBuilder construction (nquality.py) raise AttributeError under NumPy >= 2.0. Use np.bool_, matching the alias already used elsewhere in the codebase (e.g. superlink.py). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
stoiver
added a commit
to anuga-community/anuga_drainage
that referenced
this pull request
Jun 8, 2026
…t ANUGA) Make the coupled examples run against the current scientific-Python stack in the ANUGA conda env, using the standard pyswmm release and our own calculate_Q (not the patched 2D-coupling pyswmm fork). pyswmm 2.1.0 (SWMM scripts): - sim.next() was removed -> step the iterator with next(sim) - swmm_stride requires an int (whole seconds); even 1.0 raises TypeError. Pass int(dt) and keep dt a whole number of seconds. run_swmm_short/long bumped from dt=0.2 to dt=1.0 (sub-second SWMM coupling is not supported by stock pyswmm; SWMM still routes internally at the .inp ROUTING_STEP). Drop hymo dependency (real_example/run_swmm.py + inlet_initialization.py): - hymo is unmaintained and not installable on current Python. It was only used to read node map coordinates from the .inp [COORDINATES] section. Replace with a small zero-dependency read_inp_coordinates() helper in inlet_initialization.py; initialize_inlets() now takes that DataFrame. ANUGA API drift (pipedream culvert + real_example, swmm real_example): - create_domain_from_regions() no longer accepts mesh_filename (mesh is built in-memory) -> drop the kwarg. Add CLAUDE.md documenting the coupling architecture, the standard-pyswmm decision, and these environment constraints. Smoke-tested end to end (all run to finaltime with stable mass-balance): SWMM short/long/real_example; pipedream simple_culvert/yshape/real_example/ culvert. pipedream requires git-master install (PyPI 0.2.2 uses np.bool8, removed in numpy 2.x; fix submitted upstream as mdbartos/pipedream#73). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
np.bool8was removed in NumPy 2.0. Two remaining uses causeAttributeError: module 'numpy' has no attribute 'bool8'under NumPy >= 2.0:pipedream_solver/nsuperlink.py:1682— inreposition_junctions()(np.ones(NK, dtype=np.bool8))pipedream_solver/nquality.py:104— inQualityBuilderconstruction (...astype(np.bool8))Most
np.bool8usages were already migrated tonp.bool_(e.g. insuperlink.py); these two were missed, so they only surface on thereposition_junctions()/ water-quality code paths.Fix
Replace both with
np.bool_, matching the alias already used elsewhere in the codebase.np.bool_is valid in both NumPy 1.x and 2.x, so this is backward compatible.Context
Hit while coupling pipedream with ANUGA in an environment that requires NumPy 2.x (NumPy 2.3.4). With these two lines fixed,
SuperLinkconstruction andreposition_junctions()work under NumPy 2.x.🤖 Generated with Claude Code