File size: 789 Bytes
314ecfb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | """
Compatibility shim so that imgaug (written for numpy<2) keeps working with
numpy>=2. Must be imported before `imgaug`.
"""
import numpy as np
if not hasattr(np, "sctypes"):
np.sctypes = {
"int": [np.int8, np.int16, np.int32, np.int64],
"uint": [np.uint8, np.uint16, np.uint32, np.uint64],
"float": [np.float16, np.float32, np.float64],
"complex": [np.complex64, np.complex128],
"others": [bool, object, bytes, str, np.void],
}
for _name, _alias in [
("bool", np.bool_),
("float", float),
("int", int),
("object", object),
("str", str),
("unicode", np.str_),
("string_", np.bytes_),
("unicode_", np.str_),
]:
if _name not in np.__dict__:
setattr(np, _name, _alias)
|