FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/func/python/numpy_test.py at main · faasm/python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
faasm
/
python
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
6
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
func
/
python
/
numpy_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
95 lines (69 loc) · 2.17 KB
Breadcrumbs
python
/
func
/
python
/
numpy_test.py
Copy path
File metadata and controls
95 lines (69 loc) · 2.17 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import
numpy
as
np
def
_print_array
(
a
):
print
(
"
\n
array={} (type={}, shape={}, strides={}). Sum: {}"
.
format
(
a
,
a
.
dtype
,
a
.
shape
,
a
.
strides
,
np
.
sum
(
a
)
)
)
ix
=
3
got_item
=
a
[
ix
]
sum_item
=
0.0
+
got_item
.
item
()
print
(
"array[{}] = {}"
.
format
(
ix
,
got_item
))
print
(
"array[{}] + 0.0 = {}"
.
format
(
ix
,
sum_item
))
print
(
"array[{}].item = {}"
.
format
(
ix
,
got_item
.
item
))
print
(
"array.__repr__(): {}
\n
"
.
format
(
a
.
__repr__
()))
for
i
,
x
in
enumerate
(
a
):
print
(
"array[{}] = {} ({})"
.
format
(
i
,
x
,
a
[
i
]))
def
faasm_main
():
print
(
"Starting numpy version {}"
.
format
(
np
.
__version__
))
np
.
__config__
.
show
()
print
(
"Loaded numpy version {}"
.
format
(
np
.
__version__
))
print
(
"
\n
----- INT ARRAY -----
\n
"
)
a
=
np
.
array
([
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
])
print
(
"Printing array elems check:"
)
print
(
"10={}"
.
format
(
a
[
10
]))
print
(
"6={}"
.
format
(
a
[
6
]))
a1
=
a
[
1
]
a2
=
a
[
2
]
a12
=
a
[
1
:
3
]
print
(
"1="
+
str
(
a1
)
+
", 2="
+
str
(
a2
))
print
(
"1,2={}"
.
format
(
a12
))
print
(
"Explicit iterator printing check:"
)
arrayOut
=
""
a0
=
None
for
i
,
x
in
enumerate
(
a
):
if
i
==
0
:
a0
=
x
elif
x
==
a0
:
print
(
"x == a0"
)
if
i
==
1
:
if
x
==
a1
:
print
(
"a1 equal"
)
else
:
print
(
"a1 not equal"
)
arrayOut
+=
str
(
x
)
+
", "
print
(
"Array = {}"
.
format
(
arrayOut
))
print
(
"Random int array print check:"
)
ia
=
np
.
random
.
randint
(
0
,
100
,
size
=
10
)
_print_array
(
ia
)
print
(
"
\n
----- FLOAT ARRAY -----
\n
"
)
# Float array
a
=
np
.
arange
(
10.0
)
y
=
7.2
a
[
1
]
=
y
a
[
2
]
=
9.0
a
.
__setitem__
(
3
,
10.0
)
a
[
5
:
8
]
=
[
41
,
42
,
43
]
a
.
itemset
(
4
,
10.0
)
print
(
"Printing check:"
)
_print_array
(
a
)
# Matrix
print
(
"
\n
----- MATRIX -----
\n
"
)
x1
=
np
.
arange
(
9.0
).
reshape
((
3
,
3
))
print
(
"Matrix (shape = {}):
\n
{}"
.
format
(
x1
.
shape
,
x1
))
print
(
"Data: {}"
.
format
(
x1
.
data
))
print
(
"
\n
Matrix as list:
\n
{}"
.
format
(
x1
.
tolist
()))
x2
=
np
.
arange
(
3.0
)
res
=
np
.
multiply
(
x1
,
x2
)
print
(
"
\n
Multiplied: (sum = {})
\n
{}"
.
format
(
np
.
sum
(
res
),
res
))
return
0
Back
|
FazBrowse Home
|
New Git URL