13
13
class AttributeTest (DiskTestCase ):
14
14
def test_minimal_attribute (self ):
15
15
attr = tiledb .Attr ()
16
+ self .assertEqual (attr , attr )
16
17
self .assertTrue (attr .isanon )
17
18
self .assertEqual (attr .name , "" )
18
19
self .assertEqual (attr .dtype , np .float_ )
@@ -30,6 +31,7 @@ def test_attribute(self, capfd):
30
31
attr .dump ()
31
32
assert_captured (capfd , "Name: foo" )
32
33
34
+ assert attr == attr
33
35
assert attr .name == "foo"
34
36
assert attr .dtype == np .float64 , "default attribute type is float64"
35
37
@@ -46,6 +48,7 @@ def test_attribute(self, capfd):
46
48
)
47
49
def test_attribute_fill (self , dtype , fill ):
48
50
attr = tiledb .Attr ("" , dtype = dtype , fill = fill )
51
+ assert attr == attr
49
52
assert np .array (attr .fill , dtype = dtype ) == np .array (fill , dtype = dtype )
50
53
51
54
path = self .path ()
@@ -68,6 +71,7 @@ def test_full_attribute(self, capfd):
68
71
attr .dump ()
69
72
assert_captured (capfd , "Name: foo" )
70
73
74
+ self .assertEqual (attr , attr )
71
75
self .assertEqual (attr .name , "foo" )
72
76
self .assertEqual (attr .dtype , np .int64 )
73
77
self .assertIsInstance (attr .filters [0 ], tiledb .ZstdFilter )
@@ -77,6 +81,7 @@ def test_ncell_attribute(self):
77
81
dtype = np .dtype ([("" , np .int32 ), ("" , np .int32 ), ("" , np .int32 )])
78
82
attr = tiledb .Attr ("foo" , dtype = dtype )
79
83
84
+ self .assertEqual (attr , attr )
80
85
self .assertEqual (attr .dtype , dtype )
81
86
self .assertEqual (attr .ncells , 3 )
82
87
@@ -125,9 +130,27 @@ def test_two_cell_double_attribute(self, fill):
125
130
assert attr .fill == attr .fill
126
131
assert attr .ncells == 2
127
132
133
+ def test_ncell_double_attribute (self ):
134
+ dtype = np .dtype ([("" , np .double ), ("" , np .double ), ("" , np .double )])
135
+ fill = np .array ((0 , np .nan , np .inf ), dtype = dtype )
136
+ attr = tiledb .Attr ("foo" , dtype = dtype , fill = fill )
137
+
138
+ self .assertEqual (attr , attr )
139
+ self .assertEqual (attr .dtype , dtype )
140
+ self .assertEqual (attr .ncells , 3 )
141
+
142
+ def test_ncell_not_equal_fill_attribute (self ):
143
+ dtype = np .dtype ([("" , np .double ), ("" , np .double ), ("" , np .double )])
144
+ fill1 = np .array ((0 , np .nan , np .inf ), dtype = dtype )
145
+ fill2 = np .array ((np .nan , - 1 , np .inf ), dtype = dtype )
146
+ attr1 = tiledb .Attr ("foo" , dtype = dtype , fill = fill1 )
147
+ attr2 = tiledb .Attr ("foo" , dtype = dtype , fill = fill2 )
148
+ assert attr1 != attr2
149
+
128
150
def test_ncell_bytes_attribute (self ):
129
151
dtype = np .dtype ((np .bytes_ , 10 ))
130
152
attr = tiledb .Attr ("foo" , dtype = dtype )
153
+ self .assertEqual (attr , attr )
131
154
self .assertEqual (attr .dtype , dtype )
132
155
self .assertEqual (attr .ncells , 10 )
133
156
@@ -143,28 +166,34 @@ def test_bytes_var_attribute(self):
143
166
self .assertTrue (attr .isvar )
144
167
145
168
attr = tiledb .Attr ("foo" , var = True , dtype = "S" )
169
+ self .assertEqual (attr , attr )
146
170
self .assertEqual (attr .dtype , np .dtype ("S" ))
147
171
self .assertTrue (attr .isvar )
148
172
149
173
attr = tiledb .Attr ("foo" , var = False , dtype = "S1" )
174
+ self .assertEqual (attr , attr )
150
175
self .assertEqual (attr .dtype , np .dtype ("S1" ))
151
176
self .assertFalse (attr .isvar )
152
177
153
178
attr = tiledb .Attr ("foo" , dtype = "S1" )
179
+ self .assertEqual (attr , attr )
154
180
self .assertEqual (attr .dtype , np .dtype ("S1" ))
155
181
self .assertFalse (attr .isvar )
156
182
157
183
attr = tiledb .Attr ("foo" , dtype = "S" )
184
+ self .assertEqual (attr , attr )
158
185
self .assertEqual (attr .dtype , np .dtype ("S" ))
159
186
self .assertTrue (attr .isvar )
160
187
161
188
def test_nullable_attribute (self ):
162
189
attr = tiledb .Attr ("nullable" , nullable = True , dtype = np .int32 )
190
+ self .assertEqual (attr , attr )
163
191
self .assertEqual (attr .dtype , np .dtype (np .int32 ))
164
192
self .assertTrue (attr .isnullable )
165
193
166
194
def test_datetime_attribute (self ):
167
195
attr = tiledb .Attr ("foo" , dtype = np .datetime64 ("" , "D" ))
196
+ self .assertEqual (attr , attr )
168
197
assert attr .dtype == np .dtype (np .datetime64 ("" , "D" ))
169
198
assert attr .dtype != np .dtype (np .datetime64 ("" , "Y" ))
170
199
assert attr .dtype != np .dtype (np .datetime64 )
0 commit comments