Skip to content

Commit

Permalink
Clean up temporary files (#374)
Browse files Browse the repository at this point in the history
* use tmp_path to clean up mcmc_wldf.csv

* use pytest's tmp_path to clean things up

* bump version to 2.8.2

* bump version to 2.8.3
  • Loading branch information
AdamOrmondroyd committed Mar 17, 2024
1 parent cb60b9a commit 80769c5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 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.8.2
:Version: 2.8.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.8.2'
__version__ = '2.8.3'
4 changes: 2 additions & 2 deletions tests/test_labelled_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ def test_drop_labels(lframe_index):
assert nolabels.drop_labels() is not nolabels


def test_read_csv():
filename = 'mcmc_ldf.csv'
def test_read_csv(tmp_path):
filename = tmp_path / 'mcmc_ldf.csv'

lframe = LabelledDataFrame(np.random.rand(3, 3),
index=['A', 'B', 'C'],
Expand Down
13 changes: 7 additions & 6 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,23 @@ def test_path(root):


@pytest.mark.parametrize('root', ['pc', 'gd'])
def test_read_csv(root):
def test_read_csv(tmp_path, root):
filename = tmp_path / f'{root}.csv'
samples = read_chains(f'./tests/example_data/{root}')
samples.to_csv(f'{root}.csv')
samples.to_csv(filename)

samples_ = read_csv(f'{root}.csv')
samples_ = read_csv(filename)
samples_.root = samples.root
assert_frame_equal(samples, samples_)

samples_ = read_csv(f'{root}')
samples_ = read_csv(filename)
samples_.root = samples.root
assert_frame_equal(samples, samples_)

samples_ = read_chains(f'{root}.csv')
samples_ = read_chains(filename)
samples_.root = samples.root
assert_frame_equal(samples, samples_)

samples_ = read_chains(f'{root}')
samples_ = read_chains(filename)
samples_.root = samples.root
assert_frame_equal(samples, samples_)
4 changes: 2 additions & 2 deletions tests/test_weighted_labelled_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pandas


def test_read_csv():
filename = 'mcmc_wldf.csv'
def test_read_csv(tmp_path):
filename = tmp_path / 'mcmc_wldf.csv'

wlframe = WeightedLabelledDataFrame(np.random.rand(3, 3),
index=[0, 1, 2],
Expand Down
4 changes: 2 additions & 2 deletions tests/test_weighted_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,8 @@ def test_style(mcmc_wdf):
ax = mcmc_wdf.plot.scatter_2d('x', 'y', style='c')


def test_read_csv(mcmc_wdf):
filename = 'mcmc_wdf.csv'
def test_read_csv(tmp_path, mcmc_wdf):
filename = tmp_path / 'mcmc_wdf.csv'

mcmc_wdf.to_csv(filename)
mcmc_wdf_ = read_csv(filename)
Expand Down

0 comments on commit 80769c5

Please sign in to comment.