Skip to content

Commit a526c08

Browse files
committed
Add single element csv parsing tests
1 parent 20fd8a0 commit a526c08

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/test_stancsv.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,35 @@ def test_csv_bytes_to_numpy_with_header():
7676
assert np.array_equiv(arr_out, expected)
7777

7878

79+
def test_csv_bytes_to_numpy_single_element():
80+
lines = [
81+
b"-6.76206\n",
82+
]
83+
expected = np.array(
84+
[
85+
[-6.76206],
86+
],
87+
dtype=np.float32,
88+
)
89+
arr_out = stancsv.csv_bytes_list_to_numpy(lines, includes_header=False)
90+
assert np.array_equiv(arr_out, expected)
91+
92+
93+
def test_csv_bytes_to_numpy_single_element_no_polars():
94+
lines = [
95+
b"-6.76206\n",
96+
]
97+
expected = np.array(
98+
[
99+
[-6.76206],
100+
],
101+
dtype=np.float32,
102+
)
103+
with mock.patch.dict("sys.modules", {"polars": None}):
104+
arr_out = stancsv.csv_bytes_list_to_numpy(lines, includes_header=False)
105+
assert np.array_equiv(arr_out, expected)
106+
107+
79108
def test_csv_bytes_to_numpy_with_header_no_polars():
80109
lines = [
81110
(

0 commit comments

Comments
 (0)