@@ -198,21 +198,6 @@ def test_datetime_attribute(self):
198
198
assert attr .dtype != np .dtype (np .datetime64 ("" , "Y" ))
199
199
assert attr .dtype != np .dtype (np .datetime64 )
200
200
201
- @pytest .mark .parametrize ("dtype" , ["ascii" , "blob" , "wkb" , "wkt" ])
202
- def test_nonnumpy_dtype_attribute (self , dtype , capfd ):
203
- # Do not test wkb/wkt if not yet implemented in linked libtiledb.
204
- if not hasattr (tiledb .cc .DataType , "GEOM_WKB" ) and (
205
- dtype == "wkb" or dtype == "wkt"
206
- ):
207
- return
208
- attr = tiledb .Attr ("example_attr" , dtype = dtype )
209
- self .assertEqual (attr , attr )
210
-
211
- attr .dump ()
212
- assert_captured (capfd , "Name: example_attr" )
213
-
214
- self .assertEqual (attr , attr )
215
-
216
201
@pytest .mark .parametrize ("sparse" , [True , False ])
217
202
def test_ascii_attribute (self , sparse , capfd ):
218
203
path = self .path ("test_ascii" )
@@ -267,3 +252,52 @@ def test_modify_attribute_in_schema(self):
267
252
assert "can't set attribute" in str (exc .value )
268
253
else :
269
254
assert "object has no setter" in str (exc .value )
255
+
256
+ def test_wkt_attribute (self ):
257
+ A = np .array (
258
+ ["POINT (30 10)" , "POLYGON ((3 1, 4 5, 2 2, 1 2, 3 1))" ],
259
+ dtype = "S" ,
260
+ )
261
+
262
+ dom = tiledb .Domain (tiledb .Dim (domain = (0 , 1 ), tile = 2 ))
263
+ att = tiledb .Attr (dtype = "wkt" , var = True )
264
+
265
+ schema = tiledb .ArraySchema (dom , (att ,))
266
+
267
+ tiledb .DenseArray .create (self .path ("foo" ), schema )
268
+ with tiledb .DenseArray (self .path ("foo" ), mode = "w" ) as T :
269
+ T [:] = A
270
+
271
+ # read back the data
272
+ with tiledb .DenseArray (self .path ("foo" ), mode = "r" ) as T :
273
+ for i in range (2 ):
274
+ assert_array_equal (T [:][i ].tobytes (), A [i ])
275
+
276
+ def test_wkb_attribute (self ):
277
+ A = np .array (
278
+ [
279
+ # representation of POINT (30 10)
280
+ b"\x01 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 >@\x00 \x00 \x00 \x00 \x00 \x00 $@" ,
281
+ # representation of POLYGON ((3 1, 4 5, 2 2, 1 2, 3 1))
282
+ (
283
+ b"\x01 \x03 \x00 \x00 \x00 \x01 \x00 \x00 \x00 \x05 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x08 @"
284
+ b"\x00 \x00 \x00 \x00 \x00 \x00 \xf0 ?\x00 \x00 \x00 \x00 \x00 \x00 \x10 @\x00 \x00 \x00 \x00 \x00 \x00 \x14 @"
285
+ b"\x00 \x00 \x00 \x00 \x00 \x00 \x00 @\x00 \x00 \x00 \x00 \x00 \x00 \x00 @\x00 \x00 \x00 \x00 \x00 \x00 \xf0 ?"
286
+ b"\x00 \x00 \x00 \x00 \x00 \x00 \x00 @\x00 \x00 \x00 \x00 \x00 \x00 \x08 @\x00 \x00 \x00 \x00 \x00 \x00 \xf0 ?"
287
+ ),
288
+ ],
289
+ )
290
+
291
+ dom = tiledb .Domain (tiledb .Dim (domain = (0 , 1 ), tile = 2 ))
292
+ att = tiledb .Attr (dtype = "wkb" , var = True )
293
+
294
+ schema = tiledb .ArraySchema (dom , (att ,))
295
+
296
+ tiledb .DenseArray .create (self .path ("foo" ), schema )
297
+ with tiledb .DenseArray (self .path ("foo" ), mode = "w" ) as T :
298
+ T [:] = A
299
+
300
+ # read back the data
301
+ with tiledb .DenseArray (self .path ("foo" ), mode = "r" ) as T :
302
+ for i in range (2 ):
303
+ assert_array_equal (T [:][i ].tobytes (), A [i ])
0 commit comments