File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,13 @@ def to_tabular(
8282 DimensionMismatchError: when there are mismatched column identifiers and
8383 dimensions
8484 """
85- if len (arr .shape ) == 1 :
85+ n_dims = len (arr .shape )
86+
87+ if n_dims == 0 :
88+ n_cols = 1
89+ elif n_dims == 1 :
8690 n_cols = arr .shape [0 ]
87- elif len ( arr . shape ) == 2 :
91+ elif n_dims == 2 :
8892 n_cols = arr .shape [1 ]
8993 else :
9094 raise TooManyDimensionsError
Original file line number Diff line number Diff line change @@ -259,5 +259,22 @@ def test_one_dimensional(self) -> None:
259259\midrule
2602601 & 2 & 3 \\
261261\endrule
262+ \end{tabular}"""
263+ )
264+
265+ def test_0_d (self ) -> None :
266+ """0 dimensional scalars are handled properly."""
267+ mat = np .array (1 )
268+
269+ out = to_tabular (mat )
270+
271+ assert (
272+ out
273+ == r"""\begin{tabular}{c}
274+ \toprule
275+ Col 1 \\
276+ \midrule
277+ 1 \\
278+ \endrule
262279\end{tabular}"""
263280 )
You can’t perform that action at this time.
0 commit comments