FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/integration_tests/array_03_decl.py at main · sailfish009/lpython · GitHub
sailfish009
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lpython
/
integration_tests
/
array_03_decl.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (23 loc) · 649 Bytes
Breadcrumbs
lpython
/
integration_tests
/
array_03_decl.py
Copy path
File metadata and controls
29 lines (23 loc) · 649 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
29
from
lpython
import
i32
,
f64
,
dataclass
from
numpy
import
empty
@
dataclass
class
Car
:
price
:
i32
horsepower
:
f64
@
dataclass
class
Truck
:
price
:
i32
wheels
:
i32
def
declare_struct_array
():
cars
:
Car
[
1
]
=
empty
(
1
,
dtype
=
Car
)
trucks
:
Truck
[
2
]
=
empty
(
2
,
dtype
=
Truck
)
cars
[
0
]
=
Car
(
100000
,
800.0
)
trucks
[
0
]
=
Truck
(
1000000
,
8
)
trucks
[
1
]
=
Truck
(
5000000
,
12
)
assert
cars
[
0
].
price
==
100000
assert
abs
(
cars
[
0
].
horsepower
-
800.0
)
<=
1e-12
assert
trucks
[
0
].
price
==
1000000
assert
trucks
[
1
].
price
==
5000000
assert
trucks
[
0
].
wheels
==
8
assert
trucks
[
1
].
wheels
==
12
declare_struct_array
()
Back
|
FazBrowse Home
|
New Git URL