Skip to content

Commit fb40418

Browse files
committed
fix numpy error
1 parent 9de7875 commit fb40418

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
* Fixed publish to YAK via CI workflow.
2020
* Added selector for `test` and `prod` to CI workflow.
21+
* Fixed `AttributeError` in `compas.data.DataEncoder.default` due to `np.float_` no longer being available in `numpy>=2`.
2122

2223
### Removed
2324

src/compas/data/encoders.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
try:
3131
import numpy as np
3232

33+
try:
34+
np_float = np.float_
35+
except AttributeError:
36+
np_float = np.float64
37+
3338
numpy_support = True
3439
except (ImportError, SyntaxError):
3540
numpy_support = False
@@ -143,7 +148,7 @@ def default(self, o):
143148
), # type: ignore
144149
):
145150
return int(o)
146-
if isinstance(o, (np.float_, np.float16, np.float32, np.float64)): # type: ignore
151+
if isinstance(o, (np_float, np.float16, np.float32, np.float64)): # type: ignore
147152
return float(o)
148153
if isinstance(o, np.bool_):
149154
return bool(o)

0 commit comments

Comments
 (0)