@@ -72,18 +72,41 @@ def test_dataframe(df_from_dict):
72
72
assert dfX .column_names () == ["x" , "y" , "z" ]
73
73
assert dfX .select_columns ((0 , 2 )).column_names () == dfX .select_columns_by_name (("x" , "z" )).column_names ()
74
74
75
- @pytest .mark .parametrize (["size" , "n_chunks" ],
76
- [(10 , 3 ), (12 , 3 ), (12 , 5 )]
77
- )
78
- def test_chunks (size , n_chunks , df_from_dict ):
75
+ @pytest .mark .parametrize (["size" , "n_chunks" ], [(10 , 3 ), (12 , 3 ), (12 , 5 )])
76
+ def test_df_get_chunks (size , n_chunks , df_from_dict ):
79
77
df = df_from_dict ({"x" : list (range (size ))})
80
78
dfX = df .__dataframe__ ()
81
79
chunks = list (dfX .get_chunks (n_chunks ))
82
80
assert len (chunks ) == n_chunks
83
81
assert sum (chunk .num_rows () for chunk in chunks ) == size
84
82
83
+ @pytest .mark .parametrize (["size" , "n_chunks" ], [(10 , 3 ), (12 , 3 ), (12 , 5 )])
84
+ def test_column_get_chunks (size , n_chunks , df_from_dict ):
85
+ df = df_from_dict ({"x" : list (range (size ))})
86
+ dfX = df .__dataframe__ ()
87
+ chunks = list (dfX .get_column (0 ).get_chunks (n_chunks ))
88
+ assert len (chunks ) == n_chunks
89
+ assert sum (chunk .size for chunk in chunks ) == size
85
90
86
- def test_get_chunks (df_from_dict ):
87
- df = df_from_dict ({"x" : [1 ]})
91
+ def test_get_columns (df_from_dict ):
92
+ df = df_from_dict ({"a" : [0 , 1 ], "b" : [2.5 , 3.5 ]})
93
+ dfX = df .__dataframe__ ()
94
+ for colX in dfX .get_columns ():
95
+ assert colX .size == 2
96
+ assert colX .num_chunks () == 1
97
+ assert dfX .get_column (0 ).dtype [0 ] == 0
98
+ assert dfX .get_column (1 ).dtype [0 ] == 2
99
+
100
+ def test_buffer (df_from_dict ):
101
+ df = df_from_dict ({"a" : [0 , 1 ]})
88
102
dfX = df .__dataframe__ ()
89
- assert len (list (dfX .get_chunks ())) == 1
103
+ colX = dfX .get_column (0 )
104
+ bufX = colX .get_buffers ()
105
+
106
+ dataBuf , dataDtype = bufX ['data' ]
107
+
108
+ assert dataBuf .bufsize > 0
109
+ assert dataBuf .ptr != 0
110
+ assert dataBuf .__dlpack_device__
111
+
112
+ assert dataDtype [0 ] == 0
0 commit comments