Coverage for pesummary/tests/notebook_test.py: 50.0%
22 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1# Licensed under an MIT style license -- see LICENSE.md
3from pesummary.gw.fetch import fetch_open_samples
4from pesummary.gw.notebook import make_public_notebook
5import os
6import shutil
7import tempfile
9tmpdir = tempfile.TemporaryDirectory(prefix=".", dir=".").name
11__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
14class TestPublicNoteBook(object):
15 """Test the `make_public_notebook` function
16 """
17 def setup_method(self):
18 """Setup the TestCoreDat class
19 """
20 if not os.path.isdir(tmpdir):
21 os.mkdir(tmpdir)
23 def teardown_method(self):
24 """Remove the files and directories created from this class
25 """
26 if os.path.isdir(tmpdir):
27 shutil.rmtree(tmpdir)
29 def test_public_notebook(self):
30 from pesummary.core.fetch import download_dir
31 file_name = os.path.join(download_dir, "GW190424_180648.h5")
32 if not os.path.isfile(file_name):
33 from pesummary.gw.fetch import fetch_open_samples
34 file_name = fetch_open_samples(
35 "GW190424_180648", read_file=False, outdir=download_dir,
36 unpack=True, path="GW190424_180648.h5", catalog="GWTC-2"
37 )
38 make_public_notebook(
39 file_name, "Title", default_analysis="PublicationSamples",
40 default_parameter="mass_ratio", outdir=tmpdir,
41 filename="posterior_samples.ipynb"
42 )
43 assert os.path.isfile(os.path.join(tmpdir, "posterior_samples.ipynb"))