Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast root to str to allow e.g. a pathlib.Path object to be used #358

Merged
merged 5 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.7.2
:Version: 2.7.3
: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.7.2'
__version__ = '2.7.3'
3 changes: 2 additions & 1 deletion anesthetic/read/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def read_chains(root, *args, **kwargs):

Parameters
----------
root : str
root : str, pathlib.Path
root name for reading files

*args, **kwargs:
Expand All @@ -39,6 +39,7 @@ def read_chains(root, *args, **kwargs):
:class:`anesthetic.samples.MCMCSamples` depending on auto-detection

"""
root = str(root)
if 'burn_in' in kwargs:
raise KeyError(
"This is anesthetic 1.0 syntax. The `burn_in` keyword is no "
Expand Down
7 changes: 7 additions & 0 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import anesthetic.examples._matplotlib_agg # noqa: F401
import os
from pathlib import Path
import pytest
import numpy as np
from numpy.testing import assert_array_equal, assert_array_almost_equal
Expand Down Expand Up @@ -300,3 +301,9 @@ def test_hdf5(tmp_path, root):
samples_ = read_hdf(filename, key)
assert_frame_equal(samples_, samples)
assert type(samples_) is type(samples)


@pytest.mark.parametrize('root', ['pc', 'gd'])
def test_path(root):
base_dir = Path("./tests/example_data")
read_chains(base_dir / root)
Loading