Skip to content

Commit

Permalink
Added further checks and internal corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjameshandley committed Jul 26, 2023
1 parent e9dce13 commit d16a80c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion anesthetic/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,9 @@ def make_1d_axes(params, ncol=None, labels=None,
"make_1d_axes(..., labels=tex) # anesthetic 2.0"
)
fig = fig_kw.pop('fig') if 'fig' in fig_kw else plt.figure(**fig_kw)
axes = AxesSeries(index=np.atleast_1d(params),
if np.array(params).ndim == 0:
params = [params]
axes = AxesSeries(index=params,
fig=fig,
ncol=ncol,
labels=labels,
Expand Down
10 changes: 9 additions & 1 deletion tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,22 @@ def test_make_1d_axes():

@pytest.mark.parametrize('params', [[0, 1, 2, 3],
[0, 2, 3],
[1, 2, 3]])
[1, 2, 3],
['x0', 'x1', 'x2'],
['1', '2', '3'],
[0, 'x1', 'x2'],
])
def test_make_Nd_axes_integers(params):
fig, axes = make_1d_axes(params)
assert isinstance(fig, Figure)
assert isinstance(axes, AxesSeries)
assert list(axes.index) == params

fig, axes = make_2d_axes(params)
assert isinstance(fig, Figure)
assert isinstance(axes, AxesDataFrame)
assert list(axes.index) == params
assert list(axes.columns) == params


def test_make_2d_axes_inputs_outputs():
Expand Down

0 comments on commit d16a80c

Please sign in to comment.