Skip to content

Replace np.float, np.in1d, np.int removed in NumPy 1.24 / NumPy 2.0 (13 files) - #2268

Open
Azimml wants to merge 1 commit into
FedML-AI:masterfrom
Azimml:fix/numpy2-removed-aliases
Open

Replace np.float, np.in1d, np.int removed in NumPy 1.24 / NumPy 2.0 (13 files)#2268
Azimml wants to merge 1 commit into
FedML-AI:masterfrom
Azimml:fix/numpy2-removed-aliases

Conversation

@Azimml

@Azimml Azimml commented Aug 23, 2026

Copy link
Copy Markdown

Thanks for putting this code out — I've been reading through it.

On a current environment (Python 3.12, NumPy 2.x) it uses a few names that NumPy and the stdlib have since removed. These raise rather than warn, so execution stops at the first one reached.

What breaks

Location Symbol Removed in
python/fedml/simulation/mpi/fedgkt/utils.py:131 np.float NumPy 1.24
python/fedml/core/data/noniid_partition.py:52 np.in1d NumPy 2.0
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/datasets.py:537 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/datasets.py:566 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/datasets.py:1519 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/datasets.py:1629 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/general.py:272 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/utils/general.py:288 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/datasets.py:597 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/datasets.py:640 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/datasets.py:1126 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/dataloaders.py:627 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/dataloaders.py:670 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/utils/dataloaders.py:1158 np.int NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/models/common.py:480 np.float NumPy 1.24
python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov6/yolov6/data/datasets.py:43 np.int NumPy 1.24
20 more of the same kinds

How I checked

I couldn't stand up the full stack locally (it needs multiprocess, which I don't have set up here), so rather than guess I executed each of these expressions directly against NumPy 2.x to confirm it genuinely raises, and confirmed the replacement returns the same value. The change is limited strictly to those substitutions.

Every file this touches still compiles (py_compile).

What this PR changes

Old New Why it's equivalent
np.float float np.float was the builtin float
np.in1d np.isin isin is the documented successor; identical for 1-D input
np.int int np.int was the builtin int; NumPy's own error text recommends this

These are exact substitutions — no behavioural or numerical change. Only the lines listed above are touched.

Happy to rework this if you'd rather pin NumPy below 2, or if you'd prefer it split differently.

  np.float                 -> float            (removed in NumPy 1.24)
  np.in1d                  -> np.isin          (removed in NumPy 2.0)
  np.int                   -> int              (removed in NumPy 1.24)

These raise rather than warn, so they stop execution on a
current environment. The replacements are exact equivalents -
no behavioural or numerical change.

Touches 13 file(s); all still compile.
@Azimml Azimml changed the title Fix NumPy 2.x / Python 3.12 incompatibilities Replace np.float, np.in1d, np.int removed in NumPy 1.24 / NumPy 2.0 (13 files) Aug 23, 2026
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