diff --git a/integration_tests/bindc_08.py b/integration_tests/bindc_08.py index d5ba74cd9f..e23e979b80 100644 --- a/integration_tests/bindc_08.py +++ b/integration_tests/bindc_08.py @@ -1,5 +1,5 @@ # file: main.py -from lpython import CPtr, i32, dataclass, c_p_pointer, Pointer, empty_c_void_p, p_c_pointer +from lpython import CPtr, i32, dataclass, c_p_pointer, Pointer, empty_c_void_p, p_c_pointer, Array from numpy import empty, array @@ -9,11 +9,11 @@ class Foo: y: i32 def init(foos_ptr: CPtr) -> None: - foos: Pointer[Foo[:]] = c_p_pointer(foos_ptr, Foo[:], array([1])) + foos: Pointer[Array[Foo, :]] = c_p_pointer(foos_ptr, Array[Foo, :], array([1])) foos[0] = Foo(3, 2) def main() -> None: - foos: Foo[1] = empty(1, dtype=Foo) + foos: Array[Foo, 1] = empty(1, dtype=Foo) foos_ptr: CPtr = empty_c_void_p() foos[0] = Foo(0, 1) p_c_pointer(foos, foos_ptr) diff --git a/integration_tests/structs_05.py b/integration_tests/structs_05.py index 7d66f41a58..6ae6262ac7 100644 --- a/integration_tests/structs_05.py +++ b/integration_tests/structs_05.py @@ -1,4 +1,4 @@ -from lpython import i32, f64, i64, i16, i8, f32, dataclass, InOut +from lpython import i32, f64, i64, i16, i8, f32, dataclass, InOut, Array from numpy import empty @dataclass @@ -11,7 +11,7 @@ class A: c: i8 d: bool -def verify(s: A[:], x1: i32, y1: f64, x2: i32, y2: f64): +def verify(s: Array[A, :], x1: i32, y1: f64, x2: i32, y2: f64): eps: f64 = 1e-12 s0: A = s[0] print(s0.x, s0.y, s0.z, s0.a, s0.b, s0.c, s0.d) @@ -41,7 +41,7 @@ def update_1(s: InOut[A]): s.b = i16(2) s.c = i8(2) -def update_2(s: A[:]): +def update_2(s: Array[A, :]): s[1].x = 3 s[1].y = 2.3 s[1].z = i64(3) @@ -50,7 +50,7 @@ def update_2(s: A[:]): s[1].c = i8(3) def g(): - y: A[2] = empty([2], dtype=A) + y: Array[A, 2] = empty([2], dtype=A) y[0] = A(1.1, 1, i64(1), f32(1.1), i16(1), i8(1), True) y[1] = A(2.2, 2, i64(2), f32(2.2), i16(2), i8(2), True) verify(y, 1, 1.1, 2, 2.2) diff --git a/integration_tests/structs_25.py b/integration_tests/structs_25.py index 4ed57ea564..d5402c6c5d 100644 --- a/integration_tests/structs_25.py +++ b/integration_tests/structs_25.py @@ -1,4 +1,4 @@ -from lpython import i32, dataclass +from lpython import i32, dataclass, Array from numpy import empty @dataclass @@ -6,11 +6,11 @@ class Foo: x: i32 y: i32 -def init(foos: Foo[:]) -> None: +def init(foos: Array[Foo, :]) -> None: foos[0] = Foo(5, 21) def main0() -> None: - foos: Foo[1] = empty(1, dtype=Foo) + foos: Array[Foo, 1] = empty(1, dtype=Foo) init(foos) print("foos[0].x =", foos[0].x) diff --git a/src/runtime/lpython/lpython.py b/src/runtime/lpython/lpython.py index fa07f1e143..9f23b02e9b 100644 --- a/src/runtime/lpython/lpython.py +++ b/src/runtime/lpython/lpython.py @@ -2,7 +2,7 @@ import os import ctypes import platform -from dataclasses import dataclass as py_dataclass, is_dataclass as py_is_dataclass, field +from dataclasses import dataclass, field, is_dataclass as py_is_dataclass import functools @@ -48,13 +48,6 @@ def __getitem__(self, params): def __call__(self, arg): return self._convert(arg) -def dataclass(arg): - def __class_getitem__(key): - return Array(arg, key) - arg.__class_getitem__ = __class_getitem__ - - return py_dataclass(arg) - def is_ctypes_Structure(obj): return (isclass(obj) and issubclass(obj, ctypes.Structure)) diff --git a/tests/reference/asr-structs_05-fa98307.json b/tests/reference/asr-structs_05-fa98307.json index 38fdafab0c..2fd40b217c 100644 --- a/tests/reference/asr-structs_05-fa98307.json +++ b/tests/reference/asr-structs_05-fa98307.json @@ -2,7 +2,7 @@ "basename": "asr-structs_05-fa98307", "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", "infile": "tests/../integration_tests/structs_05.py", - "infile_hash": "5c587158fe09782d15aa8f5f9c24468c62795e9f537a9eb439d8e8a4", + "infile_hash": "ef1037b0936a63be679efd366920a94463900e80630a070ba440aa78", "outfile": null, "outfile_hash": null, "stdout": "asr-structs_05-fa98307.stdout",