teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

あああ

2021/09/21 03:24

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -49,6 +49,7 @@
49
49
  992 return a
50
50
 
51
51
  #参考にしたもの
52
+ **np.vectorize**を用いてみましたが同じエラー文がでます
52
53
  ```python
53
54
  # PYTHON_NUMPY_FROMPYFUNC
54
55
 

5

aaa

2021/09/21 03:24

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -49,6 +49,22 @@
49
49
  992 return a
50
50
 
51
51
  #参考にしたもの
52
+ ```python
53
+ # PYTHON_NUMPY_FROMPYFUNC
54
+
55
+ import numpy as np
56
+
57
+ # binをユニバーサル関数に変換
58
+ ubin = np.frompyfunc(bin, 1, 1)
59
+
60
+ # 配列を用意
61
+ num = np.array([1, 2, 3, 4, 5])
62
+
63
+ # numの要素を2進数表記に変換
64
+ x = ubin(num)
65
+
66
+ print(x)
67
+ ```
52
68
  下記のコードは特に軸とか選択してないと思うのですがlistだから動くのでしょうか?
53
69
  ```python
54
70
  import numpy as np

4

, → .

2021/09/21 03:22

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -28,7 +28,7 @@
28
28
  ```python
29
29
  class Calc:
30
30
 
31
- def calc_test(self.array_in):
31
+ def calc_test(self, array_in):
32
32
  何かしらの計算
33
33
  return array_out
34
34
 

3

書き忘れていたselfを追加

2021/09/21 03:18

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -28,7 +28,7 @@
28
28
  ```python
29
29
  class Calc:
30
30
 
31
- def calc_test(array_in):
31
+ def calc_test(self.array_in):
32
32
  何かしらの計算
33
33
  return array_out
34
34
 

2

特になし

2021/09/21 03:17

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -42,6 +42,11 @@
42
42
  # Error
43
43
  **ndarray_out = calc(ndarray_out)**でエラーが出ます
44
44
  axis -1 is out of bounds for array of dimension 0
45
+ **詳細**
46
+ 989 else:
47
+ 990 a = asanyarray(a).copy(order="K")
48
+ --> 991 a.sort(axis=axis, kind=kind, order=order)
49
+ 992 return a
45
50
 
46
51
  #参考にしたもの
47
52
  下記のコードは特に軸とか選択してないと思うのですがlistだから動くのでしょうか?

1

np.frompyfuncの代入先をcalc→calcFに変更

2021/09/21 02:50

投稿

LOLOLOL
LOLOLOL

スコア12

title CHANGED
File without changes
body CHANGED
@@ -34,8 +34,8 @@
34
34
 
35
35
  calc = Calc()
36
36
 
37
- calc = np.frompyfunc(calc.calc_test, 1, 1)
37
+ calcF = np.frompyfunc(calc.calc_test, 1, 1)
38
- ndarray_out = calc(ndarray_out)
38
+ ndarray_out = calcF(ndarray_out)
39
39
 
40
40
  ```
41
41