Now, requesting to allocate an array that is too big gives the exception 'array is too big', like numpy. This does depend on a gcc extension, `__builtin_mul_overflow`, present since at least version 5. This extension is also supported in clang. msvc is probably the only compiler of note that does not support it. Closes: #576
28 lines
530 B
Python
28 lines
530 B
Python
try:
|
|
from ulab import numpy as np
|
|
except:
|
|
import numpy as np
|
|
|
|
dtypes = (np.uint8, np.int8, np.uint16, np.int16, np.float)
|
|
|
|
print(np.zeros(3))
|
|
print(np.zeros((3,3)))
|
|
|
|
for dtype in dtypes:
|
|
print(np.zeros((3,3), dtype=dtype))
|
|
print(np.zeros((4,2), dtype=dtype))
|
|
|
|
try:
|
|
np.zeros((1<<31, 1<<31))
|
|
except ValueError:
|
|
print("ValueError")
|
|
|
|
try:
|
|
np.zeros((2147483653, 2147483649))
|
|
except ValueError:
|
|
print("ValueError")
|
|
|
|
try:
|
|
np.zeros((194899806, 189294637612))
|
|
except ValueError:
|
|
print("ValueError")
|