-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathobject.py
More file actions
executable file
·102 lines (52 loc) · 1014 Bytes
/
object.py
File metadata and controls
executable file
·102 lines (52 loc) · 1014 Bytes
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
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
import numpy as np
#from start import *
# assorted data types:
# <codecell>
# usually defaults to float(64 bit)
a = np.ones(3)
print a.dtype
# <codecell>
# smart enough to match input:
a = np.array((3,5,7,8))
print a.dtype
# <codecell>
# smart enough to match input:
a = np.array((3.0,5,7,8))
print a.dtype
# <codecell>
# or you can specify:
a = np.array( (1,2,3), dtype=np.uint8 )
print a.dtype
# <codecell>
#careful: integers overflow:
a = np.array( (1, 10, 100,), dtype=np.uint8)
print a
a *= 3
print a
# <codecell>
# Object arrays:
# create an empty array:
a = np.empty((2,3), dtype=np.object)
print a
# <codecell>
# put stuff into it:
a[0,0] = "a string"
a[0,1] = 4.5
a[0,2] = (1,2,3)
a[1,:] = [6, {'a':3}, 3.4]
print a
# <codecell>
# a row:
print a[1,:]
# <codecell>
# a column:
print a[:,1]
# <codecell>
# an item (a dict in this case)
print a[1,1]
# <codecell>
print a[1,1]['a']
# <codecell>