Skip to content

Commit

Permalink
Merge pull request #322 from yallup/master
Browse files Browse the repository at this point in the history
Test for integer axes creation
  • Loading branch information
yallup committed Jul 26, 2023
2 parents d3aafc2 + d16a80c commit 0d6618e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
anesthetic: nested sampling post-processing
===========================================
:Authors: Will Handley and Lukas Hergt
:Version: 2.1.0
:Version: 2.1.1
:Homepage: https://github.com/handley-lab/anesthetic
:Documentation: http://anesthetic.readthedocs.io/

Expand Down
2 changes: 1 addition & 1 deletion anesthetic/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.0'
__version__ = '2.1.1'
10 changes: 6 additions & 4 deletions anesthetic/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,14 @@ def _tick_params(axes, direction='inner', **kwargs):
elif a.position == 'diagonal': # not first column
a.tick_params('y', direction='out', length=tl/2,
left=True, labelleft=False, **kwargs)
elif ax_[i-1].position == 'diagonal': # next to diagonal
elif ax_.iloc[i-1].position == 'diagonal': # next to diag
a.tick_params('y', direction='in', length=tl/2,
left=True, labelleft=False, **kwargs)
else: # not diagonal and not first column
a.tick_params('y', direction='inout',
left=True, labelleft=False, **kwargs)
elif len(ax_) and direction == 'outer': # no inner ticks
for a in ax_[1:]:
for a in ax_.iloc[1:]:
a.tick_params('y', left=False, labelleft=False, **kwargs)
elif len(ax_) and direction is None: # no ticks at all
for a in ax_:
Expand All @@ -437,7 +437,7 @@ def _tick_params(axes, direction='inner', **kwargs):
bottom=True,
labelbottom=False, **kwargs)
elif direction == 'outer': # no inner ticks
for a in ax_[:-1]:
for a in ax_.iloc[:-1]:
a.tick_params('x', bottom=False, labelbottom=False,
**kwargs)
elif direction is None: # no ticks at all
Expand Down 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
20 changes: 20 additions & 0 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ def test_make_1d_axes():
make_1d_axes(paramnames, spam='ham')


@pytest.mark.parametrize('params', [[0, 1, 2, 3],
[0, 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():
paramnames_x = ['A', 'B', 'C', 'D']
paramnames_y = ['B', 'A', 'D', 'E']
Expand Down

0 comments on commit 0d6618e

Please sign in to comment.