Skip to content

Replace removed np.bool8 alias with np.bool_ for NumPy 2.x#73

Open
stoiver wants to merge 1 commit into
mdbartos:masterfrom
stoiver:fix-numpy2-bool8
Open

Replace removed np.bool8 alias with np.bool_ for NumPy 2.x#73
stoiver wants to merge 1 commit into
mdbartos:masterfrom
stoiver:fix-numpy2-bool8

Conversation

@stoiver
Copy link
Copy Markdown

@stoiver stoiver commented Jun 5, 2026

Problem

np.bool8 was removed in NumPy 2.0. Two remaining uses cause AttributeError: module 'numpy' has no attribute 'bool8' under NumPy >= 2.0:

  • pipedream_solver/nsuperlink.py:1682 — in reposition_junctions() (np.ones(NK, dtype=np.bool8))
  • pipedream_solver/nquality.py:104 — in QualityBuilder construction (...astype(np.bool8))

Most np.bool8 usages were already migrated to np.bool_ (e.g. in superlink.py); these two were missed, so they only surface on the reposition_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, SuperLink construction and reposition_junctions() work under NumPy 2.x.

🤖 Generated with Claude Code

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>
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