12
12
13
13
try :
14
14
import polars
15
+
15
16
NO_POLARS = False
16
17
except ImportError :
17
18
NO_POLARS = True
18
19
19
20
try :
20
21
import pyarrow
22
+
21
23
NO_PYARROW = False
22
24
except ImportError :
23
25
NO_PYARROW = True
@@ -54,10 +56,15 @@ def test_empty_vector():
54
56
def test_typed_descriptors ():
55
57
s_untyped = af .ScalarObject ("" )
56
58
assert s_untyped .dtype == object
57
- v_untyped = af .VectorObject ("" )
59
+ v_untyped = af .VectorObject ("" , values = [ 0 , "0" ] )
58
60
assert v_untyped .dtype == object
59
- v_bool = af .VectorBool ("" )
60
- assert v_bool .dtype == "boolean"
61
+ assert v_untyped ._values .values .tolist () == [0 , "0" ]
62
+ v_str = af .VectorString ("" , values = [0 , "0" ])
63
+ assert v_str .dtype == pd .StringDtype ()
64
+ assert v_str ._values .tolist () == ["0" , "0" ]
65
+ v_bool = af .VectorBool ("" , values = [False , 1 ])
66
+ assert v_bool .dtype == v_bool .dtype
67
+ assert v_bool ._values .tolist () == [False , True ]
61
68
v_i8 = af .VectorI8 ("" )
62
69
assert v_i8 .dtype == pd .Int8Dtype ()
63
70
v_i16 = af .VectorI16 ("" )
@@ -228,7 +235,7 @@ class aDataset(af.Dataset):
228
235
pd .testing .assert_frame_equal (data .df , data2 .df )
229
236
assert data .origin .get ("source" ) == "dataframe, shape (2, 3)"
230
237
default_dtypes = source_df .dtypes
231
- desired_dtypes = {"v1" : "boolean" , "v2" : np .float32 , "v3" : pd .Int16Dtype ()}
238
+ desired_dtypes = {"v1" : np . bool , "v2" : np .float32 , "v3" : pd .Int16Dtype ()}
232
239
pd .testing .assert_frame_equal (data .df , source_df .astype (desired_dtypes ))
233
240
with pytest .raises (AssertionError ):
234
241
pd .testing .assert_frame_equal (data .df , source_df .astype (default_dtypes ))
@@ -252,7 +259,7 @@ class aDataset(af.Dataset):
252
259
data .origin .get ("source" ) == "dataframe, shape (2, 3)\n query:\n FROM source_df"
253
260
)
254
261
default_dtypes = source_df .dtypes
255
- desired_dtypes = {"v1" : "boolean" , "v2" : np .float32 , "v3" : pd .Int16Dtype ()}
262
+ desired_dtypes = {"v1" : np . bool , "v2" : np .float32 , "v3" : pd .Int16Dtype ()}
256
263
pd .testing .assert_frame_equal (data .df , source_df .astype (desired_dtypes ))
257
264
with pytest .raises (AssertionError ):
258
265
pd .testing .assert_frame_equal (data .df , source_df .astype (default_dtypes ))
0 commit comments