-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2118 from czgdp1807/array
Accept ``dtype`` argument in ``numpy.array``
- Loading branch information
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from lpython import i8, i32, dataclass | ||
from numpy import empty, int8, array | ||
|
||
|
||
@dataclass | ||
class LPBHV_small: | ||
dim: i32 = 4 | ||
a: i8[4] = empty(4, dtype=int8) | ||
|
||
|
||
def g(): | ||
l2: LPBHV_small = LPBHV_small(4, array([127, -127, 3, 111], dtype=int8)) | ||
|
||
print(l2.dim) | ||
assert l2.dim == 4 | ||
|
||
print(l2.a[0], l2.a[1], l2.a[2], l2.a[3]) | ||
assert l2.a[0] == i8(127) | ||
assert l2.a[1] == i8(-127) | ||
assert l2.a[2] == i8(3) | ||
assert l2.a[3] == i8(111) | ||
|
||
|
||
g() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters