Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 9250038

Browse files
andrewaikens87wenleix
authored andcommitted
Improve icolumn.py cc 3/n test_list_column (#413)
Summary: Pull Request resolved: #413 Pull Request resolved: #408 Improves test coverage for icolumn.py through test_list_column. Reviewed By: wenleix Differential Revision: D37492647 fbshipit-source-id: 7674aeac36d94a07fad0147d1d2f79a2ede3f905
1 parent 2704b4a commit 9250038

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

torcharrow/icolumn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ def cast(self, dtype):
254254
res._append_value(fun(i))
255255
return res._finalize()
256256
else:
257-
raise TypeError('f"{astype}({dtype}) is not supported")')
258-
raise TypeError('f"{astype} for {type(self).__name__} is not supported")')
257+
raise TypeError(f"{dtype} for {type(self).__name__} is not supported")
258+
raise TypeError(f"{self.dtype} for {type(self).__name__} is not supported")
259259

260260
# public simple observers -------------------------------------------------
261261

torcharrow/test/test_list_column.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@ def base_test_fixed_size_list(self):
208208
f"Unexpected failure reason: {str(ex.exception)}",
209209
)
210210

211+
def base_test_cast(self):
212+
list_dtype = dt.List(item_dtype=dt.int64, fixed_size=2)
213+
c_list = ta.column(
214+
[[1, 2], [3, 4]],
215+
dtype=list_dtype,
216+
device=self.device,
217+
)
218+
219+
int_dtype = dt.int64
220+
# TODO: Nested cast should be supported in the future
221+
for arg in (int_dtype, list_dtype):
222+
with self.assertRaisesRegexp(
223+
expected_exception=TypeError,
224+
expected_regex=r"List\(int64, fixed_size=2\) for.*is not supported",
225+
):
226+
c_list.cast(arg)
227+
211228

212229
if __name__ == "__main__":
213230
unittest.main()

torcharrow/test/test_list_column_cpu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def test_map_reduce_etc(self):
4646
def test_fixed_size_list(self):
4747
self.base_test_fixed_size_list()
4848

49+
def test_cast(self):
50+
self.base_test_cast()
51+
4952

5053
if __name__ == "__main__":
5154
unittest.main()

0 commit comments

Comments
 (0)