【Codon】 Various functions of Nunpy are not available.
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 603
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 6
Description
I was not sure if there was a report applicable to the same case, so I am reporting it just in case.
Various functions of Nunpy (functions described in test03_01.py) cannot be used because they stop with Error.
In addition, the processing speed and operation differ depending on the description of the declaration of Numpy's import.(test03_02.py)
I believe that the appeal and significance of utilizing Codon is due to its two advantages of “fast execution speed” and “easy conversion of Python code”.
I also think that the advantage of “fast execution speed” is that “test03_1.py” runs as fast as “test01_1.py” (import numpy as np).
I would appreciate it if you could support this.
[Execution Result]
-test03_1.py
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$ codon run -release /mnt/z/koko/ps3/cd/test03_1.py
__init__.codon:139:5-54: error: 'MT19937' object has no method 'seed_legacy' with arguments (MT19937, Optional[NoneType])
╰─ test03_1.py:16:1-17: error: during the realization of seed(seed: Optional[NoneType])
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$
-test03_2.py
PS C:\Users\ic> wsl -d Ubuntu-22.04
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$ codon run -release /mnt/z/koko/ps3/cd/test03_2.py
[[0 8 0]
[1 5 1]
[0 9 1]
[8 20 0]
[5 5 1]
[7 82 0]
[1 31 0]
[0 34 1]
[9 86 1]
[2 5 0]
[8 7 1]
[3 95 0]
[4 34 1]
[5 69 0]
[0 72 1]
[1 1 1]
[9 29 0]
[5 51 1]
[8 8 0]
[1 1 0]
[1 2 1]
[2 0 2]]
[[8 20 0]
[7 82 0]
[9 86 2]
[5 69 0]
[9 29 0]
[5 51 2]]
4
4
3
[ 1 5 7 8 9 20 29 31 34 51 69 72 82 86 95]
[ 3 4 5 8 10 13 16 17 18]
[[0 0]
[1 1]
[0 1]
[8 0]
[5 1]
[7 0]
[1 0]
[0 1]
[9 1]
[2 0]
[8 1]
[3 0]
[4 1]
[5 0]
[0 1]
[1 1]
[9 0]
[5 1]
[8 0]]
[[1 1 0 1 2]
[1 2 0 2 1]
[0 0 1 0 2]]
[[1], [1], [0], [1], [2], [1], [2], [0], [2], [1], [0], [0], [1], [0], [2]]
[[1]
[1]
[0]
[1]
[2]
[1]
[2]
[0]
[2]
[1]
[0]
[0]
[1]
[0]
[2]]
3.33
0.0231609
test03_②
from python import numpy as np
owari
-test01_1.py
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$ codon run -release /mnt/z/koko/ps3/cd/test01_1.py
kaisuu
n= 300
be count= 0
be count= 0
5 × 2 array of int
╭───────────┬───────────╮
│ 0 │ 0 │
├───────────┼───────────┤
│ 148517026 │ 0 │
├───────────┼───────────┤
│ 0 │ 0 │
├───────────┼───────────┤
│ 0 │ 0 │
├───────────┼───────────┤
│ 0 │ 0 │
╰───────────┴───────────╯
af count= 0
af count= 148517026
partial(__new__[...,...])
test01_①
import numpy as np
0.603801s
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$
-test01_2.py
ic@DESKTOP-C83DAGF:/mnt/c/Users/ic$ codon run -release /mnt/z/koko/ps3/cd/test01_2.py
kaisuu
n= 300
be count= 0
be count= 0
[[ 0 0]
[148488482 0]
[ 0 0]
[ 0 0]
[ 0 0]]
af count= 0
af count= 148488482
partial(class_ctr[...,...])
test01_②
from python import numpy as np
36.102s
[Execution Procedure]
Execute the following from Windows PowerShell Terminal on Windows in the following order.
wsl -d Ubuntu-22.04
codon run -release /mnt/z/koko/ps3/cd/test03_1.py
[Execution environment]
Codon Ver: 0.18
Python Ver: 3.10.8
Windows 10 Pro 22H2(WSL Ubuntu 22.04)
Windows Feature Experience Pack 1000.19055.1000.0
Core(TM) i7-7700HQ
Memory 64GB
[Sampl Code]
-test03_1.py
```
import numpy as np #------------①
from python import pandas as pd
from python import csv
import time
import random
import sys
t00 = time.time()
np0 = np.array(pd.read_csv('/mnt/z/koko/ps3/cd/test.csv', header=None) , dtype = 'object')
np0aa = np.zeros((15, 1), dtype=np.int64)
np.random.seed()
np0aa[0: 15, 0] = np.random.randint(0, 999999999, 15)
np0aa[0: 15, 0] = np0aa[0: 15, 0] % 3
np0a = np0aa.reshape(5, 3)
np0b = np.copy(np0a[0: 3])
np1 = np.concatenate([np0, np0b], axis = 0)
np2 = np1[:][np.where((np1[:, 0] >= 5) & (np1[:, 1] >= 20))]
np2l0 = len(np2)
np3a = np.zeros((np2l0, 1), dtype=np.int64)
np3b = np.zeros((np2l0, 1), dtype=np.int64)
np3a[:] = np2[:, 2:3] * 2
np3b = np2[:, 2]
np3b[:] = np3b[:] * 2
np3c = np.sum(np3a)
np3d = np.sum(np3b)
np4 = np.count_nonzero((np2[:, 0] >= 6) & (np2[:, 2] == 0))
np5 = np.unique(np0[:, 1]).astype('int64')
np6 = np.where(np0[:, 0] >= 5)[0]
np7 = np.delete(np0, 1, axis = 1)
np8 = np0aa.flatten()
np8 = np8.reshape(3, 5)
np9= np0aa.tolist()
np10 = np.array(np9)
np11a = 10/3
np11 = np.round(np11a, 2)
print(np1)
print(" ")
print(np2)
print(" ")
print(np3c)
print(" ")
print(np3d)
print(" ")
print(np4)
print(" ")
print(np5)
print(" ")
print(np6)
print(" ")
print(np7)
print(" ")
print(np8)
print(" ")
print(np9)
print(" ")
print(np10)
print(" ")
print(np11)
fn0 = '/home/ic/kaki1.csv'
kdf0 = pd.DataFrame(np0)
kdf0.to_csv(fn0)
kdf0 = None
t01 = time.time()
t02 = t01 - t00
print(t02)
print("test03_①")
print("import numpy as np")
print("owari")
#sys.exit()
print("end")
```
-test03_2.py
```
from python import numpy as np #------------②
from python import pandas as pd
from python import csv
import time
import random
import sys
t00 = time.time()
np0 = np.array(pd.read_csv('/mnt/z/koko/ps3/cd/test.csv', header=None) , dtype = 'object')
np0aa = np.zeros((15, 1), dtype=np.int64)
np.random.seed()
np0aa[0: 15, 0] = np.random.randint(0, 999999999, 15)
np0aa[0: 15, 0] = np0aa[0: 15, 0] % 3
np0a = np0aa.reshape(5, 3)
np0b = np.copy(np0a[0: 3])
np1 = np.concatenate([np0, np0b], axis = 0)
np2 = np1[:][np.where((np1[:, 0] >= 5) & (np1[:, 1] >= 20))]
np2l0 = len(np2)
np3a = np.zeros((np2l0, 1), dtype=np.int64)
np3b = np.zeros((np2l0, 1), dtype=np.int64)
np3a[:] = np2[:, 2:3] * 2
np3b = np2[:, 2]
np3b[:] = np3b[:] * 2
np3c = np.sum(np3a)
np3d = np.sum(np3b)
np4 = np.count_nonzero((np2[:, 0] >= 6) & (np2[:, 2] == 0))
np5 = np.unique(np0[:, 1]).astype('int64')
np6 = np.where(np0[:, 0] >= 5)[0]
np7 = np.delete(np0, 1, axis = 1)
np8 = np0aa.flatten()
np8 = np8.reshape(3, 5)
np9= np0aa.tolist()
np10 = np.array(np9)
np11a = 10/3
np11 = np.round(np11a, 2)
print(np1)
print(" ")
print(np2)
print(" ")
print(np3c)
print(" ")
print(np3d)
print(" ")
print(np4)
print(" ")
print(np5)
print(" ")
print(np6)
print(" ")
print(np7)
print(" ")
print(np8)
print(" ")
print(np9)
print(" ")
print(np10)
print(" ")
print(np11)
fn0 = '/home/ic/kaki1.csv'
kdf0 = pd.DataFrame(np0)
kdf0.to_csv(fn0)
kdf0 = None
t01 = time.time()
t02 = t01 - t00
print(t02)
print("test03_②")
print("from python import numpy as np")
print("owari")
sys.exit()
print("end")
```
-test01_1.py
```
import numpy as np #------------①
from python import pandas as pd
from python import csv
import time
import random
def test_def(n, count):
for i in range(n):
for j in range(n):
for k in range(n):
r0 = random.randint(1,10)
count[1, 0] = count[1, 0] + r0
return count
start_time = time.time()
n = 300
count = np.zeros((5, 2), dtype=np.int64)
print("kaisuu")
print("n=", n)
print("be count=", count[0, 0])
print("be count=", count[1, 0])
print(" ")
print(" ")
print(" ")
print(test_def(n, count))
print("af count=", count[0, 0])
print("af count=", count[1, 0])
print(type(count))
elapsed_time = time.time() - start_time
print("test01_①")
print("import numpy as np")
print(f"{elapsed_time}s")
```
-test01_2.py
```
from python import numpy as np #------------②
from python import pandas as pd
from python import csv
import time
import random
def test_def(n, count):
for i in range(n):
for j in range(n):
for k in range(n):
r0 = random.randint(1,10)
count[1, 0] = count[1, 0] + r0
return count
start_time = time.time()
n = 300
count = np.zeros((5, 2), dtype=np.int64)
print("kaisuu")
print("n=", n)
print("be count=", count[0, 0])
print("be count=", count[1, 0])
print(" ")
print(" ")
print(" ")
print(test_def(n, count))
print("af count=", count[0, 0])
print("af count=", count[1, 0])
print(type(count))
elapsed_time = time.time() - start_time
print("test01_②")
print("from python import numpy as np")
print(f"{elapsed_time}s")
```
[test.csv]
```
0 8 0
1 5 1
0 9 1
8 20 0
5 5 1
7 82 0
1 31 0
0 34 1
9 86 1
2 5 0
8 7 1
3 95 0
4 34 1
5 69 0
0 72 1
1 1 1
9 29 0
5 51 1
8 8 0
```
Contributor guide
Assessment
This issue has not been assessed yet.