-
Notifications
You must be signed in to change notification settings - Fork 0
/
demoForChris.py
120 lines (89 loc) · 1.65 KB
/
demoForChris.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 14 13:29:15 2014
@author: bmmorris
"""
import numpy as np
filename = 'data.txt'
rawtext = open(filename,'r').read().splitlines()
counter=0
for i in len(rawtext):
if rawtext[i].split()[0] == '#' :
counter = i+1
rawtext=rawtext[counter:]
splitlist = []
for i in range(len(rawtext)):
splitline = map(float,rawtext[i].split(' '))
splitlist.append(splitline)
a = np.array(splitlist)[:,1:]
'''
In [12]: a
Out[12]:
array([[ 1., 2., 3.],
[ 2., 3., 4.],
[ 5., 6., 7.]])
In [13]: run untitled1.py
In [14]: print a
[[ 2. 3.]
[ 3. 4.]
[ 6. 7.]]
In [15]: print a
[[ 2. 3.]
[ 3. 4.]
[ 6. 7.]]
In [16]: print a[:,0
....: ]
[ 2. 3. 6.]
In [17]: print a[:,0]
[ 2. 3. 6.]
In [18]: print a[:,1]
[ 3. 4. 7.]
In [19]: c = a[:,0]
In [20]: a
Out[20]:
array([[ 2., 3.],
[ 3., 4.],
[ 6., 7.]])
In [21]: c
Out[21]: array([ 2., 3., 6.])
In [22]: c[0] = 0
In [23]: a
Out[23]:
array([[ 0., 3.],
[ 3., 4.],
[ 6., 7.]])
In [24]: c = np.copy(a[:,0])
In [25]: c
Out[25]: array([ 0., 3., 6.])
In [26]: a
Out[26]:
array([[ 0., 3.],
[ 3., 4.],
[ 6., 7.]])
In [27]: a[0,0] = 10
In [28]: a
Out[28]:
array([[ 10., 3.],
[ 3., 4.],
[ 6., 7.]])
In [29]: c
Out[29]: array([ 0., 3., 6.])
In [30]: a
Out[30]:
array([[ 10., 3.],
[ 3., 4.],
[ 6., 7.]])
In [31]: b = np.copy(a)
In [32]: b
Out[32]:
array([[ 10., 3.],
[ 3., 4.],
[ 6., 7.]])
In [33]: a
Out[33]:
array([[ 10., 3.],
[ 3., 4.],
[ 6., 7.]])
In [34]: b[0]
Out[34]: array([ 10., 3.])
'''