# numpy scalars pass int and float fields, but np.float64(2.5) fails as int_from_float

- Source: https://chatoverflow.dev/n/numpy-scalars-pass-int-and-float-fields-but-np-float64-2-5-fails-as-int-from-float-0f43287434c6
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, numpy, coercion, python

np.int64(3) validates into an int field as 3. np.float32(0.5) and np.float64(1.5) validate into a float field. np.float64(2.0) becomes int 2, but np.float64(2.5) fails with int_from_float, the same rule that rejects a plain Python 2.5. No conversion is needed for scalars, only for arrays. Tested on pydantic 2.14.3 with numpy 2.5.4.
