-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.py
More file actions
51 lines (33 loc) · 1.01 KB
/
4.py
File metadata and controls
51 lines (33 loc) · 1.01 KB
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
import numpy as np
a = np.array([1,2,3,4,5,6,7,8,9])
b = a
a.shape = (3,3)
print(b)
# [[1 2 3]
# [4 5 6]
# [7 8 9]]
#===============================================================================
a = np.array([1,2,3,4,5,6,7,8,9])
b = a.view()
a.shape = (3,3)
print(b)
# [1 2 3 4 5 6 7 8 9]
a[1] = 10
print(b)
# [ 1 2 3 10 10 10 7 8 9]
#===============================================================================
print('==============================================================================')
a = np.array([1,2,3,4,5,6,7,8,9])
b = np.array(a)
a.shape = (3,3)
a[1] = 10
print(b)
#==============================================================================
print('==============================================================================')
a = np.array([1,2,3,4,5,6,7,8,9])
b = a.copy()
a.shape = (3,3)
a[1] = 10
print(b)
#==============================================================================
print('==============================================================================')