回答編集履歴

2

edit

2017/12/04 03:48

投稿

mkgrei
mkgrei

スコア8560

test CHANGED
@@ -39,3 +39,49 @@
39
39
  print(a)
40
40
 
41
41
  ```
42
+
43
+
44
+
45
+ ---
46
+
47
+
48
+
49
+ 素朴な疑問に、`a,b`にこだわりすぎているように思います。
50
+
51
+ 最終的に`a,b`で操作したいとしても、そこに到達するまではいちいち`a,b`に代入する必要がありません。
52
+
53
+
54
+
55
+ ```python
56
+
57
+ import numpy as np
58
+
59
+
60
+
61
+ a = [np.array([[1, 2, 3],[4, 5, 6]])]
62
+
63
+ b = [np.array([[10, 11, 12],[13, 14, 15]])]
64
+
65
+
66
+
67
+ a_and_b = [a, b]
68
+
69
+
70
+
71
+ a_and_b = [np.sort(x.T) for x in a_and_b]
72
+
73
+ #もしくは
74
+
75
+ a_and_b = [x.T for x in a_and_b]
76
+
77
+ a_and_b = [np.sort(x) for x in a_and_b]
78
+
79
+
80
+
81
+ #他の操作全部
82
+
83
+
84
+
85
+ a, b = a_and_b
86
+
87
+ ```

1

edit

2017/12/04 03:47

投稿

mkgrei
mkgrei

スコア8560

test CHANGED
@@ -3,3 +3,39 @@
3
3
  a, b = [x.T for x in array]
4
4
 
5
5
  ```
6
+
7
+
8
+
9
+ ---
10
+
11
+
12
+
13
+ 意味はありませんが、どうしてもその書き方がよいのであれば、
14
+
15
+ ```python
16
+
17
+ import numpy as np
18
+
19
+
20
+
21
+ a = [np.array([[1, 2, 3],[4, 5, 6]])]
22
+
23
+ b = [np.array([[10, 11, 12],[13, 14, 15]])]
24
+
25
+
26
+
27
+ array = [a, b]
28
+
29
+
30
+
31
+ for x in array:
32
+
33
+ x[0] = x[0].T
34
+
35
+ print(x)
36
+
37
+
38
+
39
+ print(a)
40
+
41
+ ```