Skip to content

Commit

Permalink
Cast root to str to allow e.g. a pathlib.Path object to be used (
Browse files Browse the repository at this point in the history
…handley-lab#358)

* cast root to string in case it is a path

* move import to top

* bump version to 2.6.1

---------

Co-authored-by: Will Handley <[email protected]>
  • Loading branch information
AdamOrmondroyd and williamjameshandley authored Mar 2, 2024
1 parent e5b3bdf commit 3ea992c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 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.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)

0 comments on commit 3ea992c

Please sign in to comment.