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

Commit 43cfe81

Browse files
andrewaikens87facebook-github-bot
authored andcommitted
Improve icolumn.py cc 3/n test_list_column
Summary: Improves test coverage for icolumn.py through test_list_column. This stack gets icolumn.py to 86% coverage. Reviewed By: wenleix Differential Revision: D37492647 fbshipit-source-id: a095b9bc59ef35b297bd1c9b493aeaf2f2c36dd5
1 parent 4fd87e4 commit 43cfe81

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ 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+
for arg in (int_dtype, list_dtype):
221+
with self.assertRaisesRegexp(
222+
expected_exception=TypeError,
223+
expected_regex=r"List\(int64, fixed_size=2\) for.*is not supported",
224+
):
225+
c_list.cast(arg)
226+
211227

212228
if __name__ == "__main__":
213229
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)