Closed
Description
- The error message mis-counts the number of arguments.
- The results do not match ordinary CPython.
MVE:
from lpython import (i8, i32, i64, f32, f64,
u8, u32,
TypeVar, Const,
dataclass)
from numpy import empty, sqrt, float32, float64, int8, array
@dataclass
class LPBHV_small:
dim : i32 = 4
a : i8[4] = empty(4, dtype=int8)
def g() -> None:
l2 : LPBHV_small = LPBHV_small(
4,
array([214, 157, 3, 146],dtype=int8))
# [i8(214), i8(157), i8(3), i8(146)])
if __name__ == "__main__":
print("Module HDC")
print('')
g()
runs:
(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s000)─┐
└─(14:19:03 on brian-lasr ✹)──> ~/CLionProjects/lpython/src/bin/lpython -I. issue2089.py ──(Mon,Jul03)─┘
semantic error: array accepts only 1 argument for now, got 105553123855456 arguments instead.
--> issue2089.py:17:9
|
17 | array([214, 157, 3, 146],dtype=int8))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that must be fixed).
(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s000)─┐
└─(14:19:11 on brian-lasr ✹)──> PYTHONPATH='../../src/runtime/lpython' python issue2089.py 2 ↵ ──(Mon,Jul03)─┘
Module HDC
/Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2089.py:17: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 214 to int8 will fail in the future.
For the old behavior, usually:
np.array(value).astype(dtype)
will give the desired result (the cast overflows).
array([214, 157, 3, 146],dtype=int8))
/Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2089.py:17: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 157 to int8 will fail in the future.
For the old behavior, usually:
np.array(value).astype(dtype)
will give the desired result (the cast overflows).
array([214, 157, 3, 146],dtype=int8))
/Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2089.py:17: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 146 to int8 will fail in the future.
For the old behavior, usually:
np.array(value).astype(dtype)
will give the desired result (the cast overflows).
array([214, 157, 3, 146],dtype=int8))