From 38a78787f51aaaaa349a730bcea70547d4c17813 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 7 May 2024 17:06:37 +0200 Subject: [PATCH 1/9] add build.os to rtd conf and remove static html --- .readthedocs.yaml | 5 +++++ docs/conf.py | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 8c652a9..bc5a3d3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -5,6 +5,11 @@ # Required version: 2 +build: + os: "ubuntu-22.04" + tools: + python: "3.10" + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py diff --git a/docs/conf.py b/docs/conf.py index 3bfabf6..0474282 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -84,4 +84,3 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] From 1a5c9d7e1f5f24309cc08f2249514f5c0f369125 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 7 May 2024 17:07:45 +0200 Subject: [PATCH 2/9] remove version in python --- .readthedocs.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bc5a3d3..c170e31 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -20,6 +20,5 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 install: - requirements: docs/requirements.txt \ No newline at end of file From fa5857d54f35ada3ed0795916f5cb763eb2df057 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 7 May 2024 17:36:36 +0200 Subject: [PATCH 3/9] add pickleshare --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index bb340d3..f865b4d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -9,3 +9,4 @@ sphinx-argparse sphinx-autorun IPython anndata +pickleshare From 7b62c5cbe300c20c9c20195a9ade97fe5836d2ef Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 7 May 2024 17:49:34 +0200 Subject: [PATCH 4/9] fix usage.rst --- docs/content/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content/usage.rst b/docs/content/usage.rst index 8588f63..7e065c2 100644 --- a/docs/content/usage.rst +++ b/docs/content/usage.rst @@ -16,26 +16,26 @@ baredSC_1d ----------- .. argparse:: - :ref: baredSC.baredSC_1d.parse_arguments + :ref: baredSC.common.parse_arguments('baredSC_1d') :prog: baredSC_1d combineMultipleModels_1d ------------------------ .. argparse:: - :ref: baredSC.combineMultipleModels_1d.parse_arguments + :ref: baredSC.common.parse_arguments('combineMultipleModels_1d') :prog: combineMultipleModels_1d baredSC_2d ----------- .. argparse:: - :ref: baredSC.baredSC_2d.parse_arguments + :ref: baredSC.common.parse_arguments('baredSC_2d') :prog: baredSC_2d combineMultipleModels_2d ------------------------ .. argparse:: - :ref: baredSC.combineMultipleModels_2d.parse_arguments + :ref: baredSC.common.parse_arguments('combineMultipleModels_2d') :prog: combineMultipleModels_2d From a2fe0776d344ee1f4cb0323428b4f7e3ef53d59f Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 7 May 2024 18:00:17 +0200 Subject: [PATCH 5/9] try module func --- docs/content/usage.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/content/usage.rst b/docs/content/usage.rst index 7e065c2..a06eff2 100644 --- a/docs/content/usage.rst +++ b/docs/content/usage.rst @@ -16,26 +16,30 @@ baredSC_1d ----------- .. argparse:: - :ref: baredSC.common.parse_arguments('baredSC_1d') + :module: baredSC.common + :func: parse_arguments('baredSC_1d') :prog: baredSC_1d combineMultipleModels_1d ------------------------ .. argparse:: - :ref: baredSC.common.parse_arguments('combineMultipleModels_1d') + :module: baredSC.common + :func: parse_arguments('combineMultipleModels_1d') :prog: combineMultipleModels_1d baredSC_2d ----------- .. argparse:: - :ref: baredSC.common.parse_arguments('baredSC_2d') + :module: baredSC.common + :func: parse_arguments('baredSC_2d') :prog: baredSC_2d combineMultipleModels_2d ------------------------ .. argparse:: - :ref: baredSC.common.parse_arguments('combineMultipleModels_2d') + :module: baredSC.common + :func: parse_arguments('combineMultipleModels_2d') :prog: combineMultipleModels_2d From 1e5257044f2673bf8a3f77d15882e9549eb2aca1 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Wed, 8 May 2024 06:40:26 +0200 Subject: [PATCH 6/9] isolate parse_arguments --- baredSC/baredSC_1d.py | 10 +++++++--- baredSC/baredSC_2d.py | 10 +++++++--- baredSC/combineMultipleModels_1d.py | 8 ++++++-- baredSC/combineMultipleModels_2d.py | 8 ++++++-- baredSC/common.py | 2 +- docs/content/usage.rst | 16 ++++++++-------- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/baredSC/baredSC_1d.py b/baredSC/baredSC_1d.py index a74d181..0c22e65 100644 --- a/baredSC/baredSC_1d.py +++ b/baredSC/baredSC_1d.py @@ -13,8 +13,8 @@ # Local imports from . common import permuted, get_Ax, \ - plot_QC, get_bins_centers, parse_arguments, checkNeff, args_check_baredSC, \ - get_data_from_args + plot_QC, get_bins_centers, common_parse_arguments, checkNeff, \ + args_check_baredSC, get_data_from_args from . oned import logprob, extract_from_npz, write_evidence, \ get_pdf, plots_from_pdf, args_check @@ -188,11 +188,15 @@ def plot(oxpdf, x, logprob_values, samples, title, output, data, col_gene, plots_from_pdf(x, pdf, title, output, data, col_gene, osampx, xscale, target_sum) +def parse_arguments(): + return(common_parse_arguments('baredSC_1d')) + + def main(args=None): """Main function of baredSC_1d """ original_args = sys.argv[1:] - args = parse_arguments('baredSC_1d').parse_args(args) + args = parse_arguments().parse_args(args) args = args_check_baredSC(args) # Update args and check args = args_check(args) diff --git a/baredSC/baredSC_2d.py b/baredSC/baredSC_2d.py index 08e12fe..7db132b 100644 --- a/baredSC/baredSC_2d.py +++ b/baredSC/baredSC_2d.py @@ -14,8 +14,8 @@ # Local imports from . common import permuted, get_Ax, get_prefix_suffix, \ - plot_QC, get_bins_centers, parse_arguments, checkNeff, args_check_baredSC, \ - get_data_from_args + plot_QC, get_bins_centers, common_parse_arguments, checkNeff, \ + args_check_baredSC, get_data_from_args from . twod import logprob, extract_from_npz, write_evidence, \ get_pdf, plots_from_pdf, args_check @@ -289,11 +289,15 @@ def plot(oxpdf, oypdf, x, y, logprob_values, samples, Neff) +def parse_arguments(): + return(common_parse_arguments('baredSC_2d')) + + def main(args=None): """Main function of baredSC_2d """ original_args = sys.argv[1:] - args = parse_arguments('baredSC_2d').parse_args(args) + args = parse_arguments().parse_args(args) args = args_check_baredSC(args) # Update args and check args = args_check(args) diff --git a/baredSC/combineMultipleModels_1d.py b/baredSC/combineMultipleModels_1d.py index 13975ed..23ccb31 100644 --- a/baredSC/combineMultipleModels_1d.py +++ b/baredSC/combineMultipleModels_1d.py @@ -9,7 +9,7 @@ import numpy as np # Local imports -from . common import get_bins_centers, parse_arguments, \ +from . common import get_bins_centers, common_parse_arguments, \ get_data_from_args from . oned import logprob, extract_from_npz, write_evidence, \ get_pdf, plots_from_pdf, args_check @@ -96,10 +96,14 @@ def plot_combined(all_results, all_logevid, title, output, data, col_gene, return None +def parse_arguments(): + return(common_parse_arguments('combineMultipleModels_1d')) + + def main(args=None): """Main function of combineMultipleModels_1d """ - args = parse_arguments('combineMultipleModels_1d').parse_args(args) + args = parse_arguments().parse_args(args) # Update args and check args = args_check(args) # Check the directory of args.figure is writtable: diff --git a/baredSC/combineMultipleModels_2d.py b/baredSC/combineMultipleModels_2d.py index 1e2c702..0201b43 100644 --- a/baredSC/combineMultipleModels_2d.py +++ b/baredSC/combineMultipleModels_2d.py @@ -10,7 +10,7 @@ # Local imports from . common import get_bins_centers, \ - get_Neff, parse_arguments, get_data_from_args + get_Neff, common_parse_arguments, get_data_from_args from . twod import logprob, extract_from_npz, write_evidence, \ get_pdf, plots_from_pdf, args_check @@ -136,10 +136,14 @@ def plot_combined(all_results, all_logevid, title, output, return None +def parse_arguments(): + return(common_parse_arguments('combineMultipleModels_2d')) + + def main(args=None): """Main function of combineMultipleModels_2d """ - args = parse_arguments('combineMultipleModels_2d').parse_args(args) + args = parse_arguments().parse_args(args) # Update args and check args = args_check(args) diff --git a/baredSC/common.py b/baredSC/common.py index 4b6af32..b44765f 100644 --- a/baredSC/common.py +++ b/baredSC/common.py @@ -388,7 +388,7 @@ def get_bins_centers(xmin, xmax, nx): return (x_borders[:-1] + x_borders[1:]) / 2 -def parse_arguments(tool: str) -> argparse.ArgumentParser: +def common_parse_arguments(tool: str) -> argparse.ArgumentParser: """Argument parser for all 4 tools """ docu_ref = "The full documentation is available at https://baredsc.readthedocs.io" diff --git a/docs/content/usage.rst b/docs/content/usage.rst index a06eff2..7bcd87d 100644 --- a/docs/content/usage.rst +++ b/docs/content/usage.rst @@ -16,30 +16,30 @@ baredSC_1d ----------- .. argparse:: - :module: baredSC.common - :func: parse_arguments('baredSC_1d') + :module: baredSC.baredSC_1d + :func: parse_arguments :prog: baredSC_1d combineMultipleModels_1d ------------------------ .. argparse:: - :module: baredSC.common - :func: parse_arguments('combineMultipleModels_1d') + :module: baredSC.combineMultipleModels_1d + :func: parse_arguments :prog: combineMultipleModels_1d baredSC_2d ----------- .. argparse:: - :module: baredSC.common - :func: parse_arguments('baredSC_2d') + :module: baredSC.baredSC_2d + :func: parse_arguments :prog: baredSC_2d combineMultipleModels_2d ------------------------ .. argparse:: - :module: baredSC.common - :func: parse_arguments('combineMultipleModels_2d') + :module: baredSC.combineMultipleModels_2d + :func: parse_arguments :prog: combineMultipleModels_2d From 501d8dde473aad88549bbf601cf8c4753e9273d0 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Wed, 8 May 2024 06:46:43 +0200 Subject: [PATCH 7/9] lint --- baredSC/baredSC_1d.py | 7 +++++-- baredSC/baredSC_2d.py | 7 +++++-- baredSC/combineMultipleModels_1d.py | 7 +++++-- baredSC/combineMultipleModels_2d.py | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/baredSC/baredSC_1d.py b/baredSC/baredSC_1d.py index 0c22e65..c282ee0 100644 --- a/baredSC/baredSC_1d.py +++ b/baredSC/baredSC_1d.py @@ -3,6 +3,7 @@ Runner for baredSC_1d """ +import argparse import sys import os from itertools import permutations @@ -188,8 +189,10 @@ def plot(oxpdf, x, logprob_values, samples, title, output, data, col_gene, plots_from_pdf(x, pdf, title, output, data, col_gene, osampx, xscale, target_sum) -def parse_arguments(): - return(common_parse_arguments('baredSC_1d')) +def parse_arguments() -> argparse.ArgumentParser: + """Argument parser for baredSC_1d + """ + return common_parse_arguments('baredSC_1d') def main(args=None): diff --git a/baredSC/baredSC_2d.py b/baredSC/baredSC_2d.py index 7db132b..91f74a4 100644 --- a/baredSC/baredSC_2d.py +++ b/baredSC/baredSC_2d.py @@ -3,6 +3,7 @@ Runner for baredSC_2d """ +import argparse import sys import os from itertools import permutations @@ -289,8 +290,10 @@ def plot(oxpdf, oypdf, x, y, logprob_values, samples, Neff) -def parse_arguments(): - return(common_parse_arguments('baredSC_2d')) +def parse_arguments() -> argparse.ArgumentParser: + """Argument parser for baredSC_2d + """ + return common_parse_arguments('baredSC_2d') def main(args=None): diff --git a/baredSC/combineMultipleModels_1d.py b/baredSC/combineMultipleModels_1d.py index 23ccb31..0c86bd8 100644 --- a/baredSC/combineMultipleModels_1d.py +++ b/baredSC/combineMultipleModels_1d.py @@ -2,6 +2,7 @@ """ Runner for combineMultipleModels_1d """ +import argparse import sys import os from tempfile import NamedTemporaryFile @@ -96,8 +97,10 @@ def plot_combined(all_results, all_logevid, title, output, data, col_gene, return None -def parse_arguments(): - return(common_parse_arguments('combineMultipleModels_1d')) +def parse_arguments() -> argparse.ArgumentParser: + """Argument parser for combineMultipleModels_1d + """ + return common_parse_arguments('combineMultipleModels_1d') def main(args=None): diff --git a/baredSC/combineMultipleModels_2d.py b/baredSC/combineMultipleModels_2d.py index 0201b43..faa9eb9 100644 --- a/baredSC/combineMultipleModels_2d.py +++ b/baredSC/combineMultipleModels_2d.py @@ -2,6 +2,7 @@ """ Runner for combineMultipleModels_2d """ +import argparse import sys import os from tempfile import NamedTemporaryFile @@ -136,8 +137,10 @@ def plot_combined(all_results, all_logevid, title, output, return None -def parse_arguments(): - return(common_parse_arguments('combineMultipleModels_2d')) +def parse_arguments() -> argparse.ArgumentParser: + """Argument parser for combineMultipleModels_2d + """ + return common_parse_arguments('combineMultipleModels_2d') def main(args=None): From acd3f0fa83c26ec585c8aa9836f623f63fdb184a Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Wed, 8 May 2024 09:57:16 +0200 Subject: [PATCH 8/9] increase tolerence in baredsc2d test --- baredSC/tests/test_baredSC_2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baredSC/tests/test_baredSC_2d.py b/baredSC/tests/test_baredSC_2d.py index 77e8fec..675b9c8 100644 --- a/baredSC/tests/test_baredSC_2d.py +++ b/baredSC/tests/test_baredSC_2d.py @@ -20,7 +20,7 @@ BARED_2D_TEXT_SUFFIX = ['_neff.txt', '_p.txt', '_corr.txt', '_pdf2d.txt', '_pdf2d_flat.txt'] -TOLERENCE = 13 # default matplotlib pixed difference tolerance +TOLERENCE = 19 # default matplotlib pixed difference tolerance def test_baredSC_2d_1gauss_small(): From 6a641a1b0b61e1d34404e292452b9f13993e3472 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Wed, 8 May 2024 11:34:10 +0200 Subject: [PATCH 9/9] decrease number of images to test on macos --- baredSC/tests/test_baredSC_2d.py | 7 ++++++- baredSC/tests/test_combine_2d.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/baredSC/tests/test_baredSC_2d.py b/baredSC/tests/test_baredSC_2d.py index 675b9c8..e2e3a7e 100644 --- a/baredSC/tests/test_baredSC_2d.py +++ b/baredSC/tests/test_baredSC_2d.py @@ -3,6 +3,7 @@ """ from tempfile import NamedTemporaryFile import os.path +import platform import matplotlib as mpl from matplotlib.testing.compare import compare_images import baredSC.baredSC_2d @@ -45,7 +46,11 @@ def test_baredSC_2d_1gauss_small(): f"--figure {outfig.name} " \ f"--logevidence {outfile_evid.name}".split() baredSC.baredSC_2d.main(args) - for suffix in BARED_2D_IMAGES_SUFFIX: + if platform.system() == "Linux": + suffix_to_test = BARED_2D_IMAGES_SUFFIX + else: + suffix_to_test = ['', '_median'] + for suffix in suffix_to_test: expected_file = f'{expected}{suffix}.{extension}' obtained_file = f'{outfig_base}{suffix}.{extension}' res = compare_images(expected_file, diff --git a/baredSC/tests/test_combine_2d.py b/baredSC/tests/test_combine_2d.py index 6a76f1c..57e4b8c 100644 --- a/baredSC/tests/test_combine_2d.py +++ b/baredSC/tests/test_combine_2d.py @@ -3,6 +3,7 @@ """ from tempfile import NamedTemporaryFile import os.path +import platform import matplotlib as mpl from matplotlib.testing.compare import compare_images import baredSC.combineMultipleModels_2d @@ -40,7 +41,11 @@ def test_combine_2d_test1(): f"--outputs {ROOT}/2d_small_1gauss {ROOT}/2d_small_2gauss " \ f"--figure {outfig.name}".split() baredSC.combineMultipleModels_2d.main(args) - for suffix in BARED_2D_IMAGES_SUFFIX: + if platform.system() == "Linux": + suffix_to_test = BARED_2D_IMAGES_SUFFIX + else: + suffix_to_test = ['', '_median'] + for suffix in suffix_to_test: expected_file = f'{expected}{suffix}.{extension}' obtained_file = f'{outfig_base}{suffix}.{extension}' res = compare_images(expected_file,