Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:lldelisle/baredSC into switch_pyproj…
Browse files Browse the repository at this point in the history
…ecttoml
  • Loading branch information
lldelisle committed May 8, 2024
2 parents 568376e + 4c7844d commit 3128a77
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 20 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,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
13 changes: 10 additions & 3 deletions baredSC/baredSC_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Runner for baredSC_1d
"""

import argparse
import sys
import os
from itertools import permutations
Expand All @@ -13,8 +14,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

Expand Down Expand Up @@ -188,11 +189,17 @@ 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() -> argparse.ArgumentParser:
"""Argument parser for baredSC_1d
"""
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)
Expand Down
13 changes: 10 additions & 3 deletions baredSC/baredSC_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Runner for baredSC_2d
"""

import argparse
import sys
import os
from itertools import permutations
Expand All @@ -14,8 +15,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

Expand Down Expand Up @@ -289,11 +290,17 @@ def plot(oxpdf, oypdf, x, y, logprob_values, samples,
Neff)


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for baredSC_2d
"""
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)
Expand Down
11 changes: 9 additions & 2 deletions baredSC/combineMultipleModels_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"""
Runner for combineMultipleModels_1d
"""
import argparse
import sys
import os
from tempfile import NamedTemporaryFile

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
Expand Down Expand Up @@ -96,10 +97,16 @@ def plot_combined(all_results, all_logevid, title, output, data, col_gene,
return None


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for combineMultipleModels_1d
"""
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:
Expand Down
11 changes: 9 additions & 2 deletions baredSC/combineMultipleModels_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Runner for combineMultipleModels_2d
"""
import argparse
import sys
import os
from tempfile import NamedTemporaryFile
Expand All @@ -10,7 +11,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

Expand Down Expand Up @@ -136,10 +137,16 @@ def plot_combined(all_results, all_logevid, title, output,
return None


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for combineMultipleModels_2d
"""
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)

Expand Down
2 changes: 1 addition & 1 deletion baredSC/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,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"
Expand Down
9 changes: 7 additions & 2 deletions baredSC/tests/test_baredSC_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +21,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():
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion baredSC/tests/test_combine_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,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']
12 changes: 8 additions & 4 deletions docs/content/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ baredSC_1d
-----------

.. argparse::
:ref: baredSC.baredSC_1d.parse_arguments
:module: baredSC.baredSC_1d
:func: parse_arguments
:prog: baredSC_1d

combineMultipleModels_1d
------------------------

.. argparse::
:ref: baredSC.combineMultipleModels_1d.parse_arguments
:module: baredSC.combineMultipleModels_1d
:func: parse_arguments
:prog: combineMultipleModels_1d

baredSC_2d
-----------

.. argparse::
:ref: baredSC.baredSC_2d.parse_arguments
:module: baredSC.baredSC_2d
:func: parse_arguments
:prog: baredSC_2d

combineMultipleModels_2d
------------------------

.. argparse::
:ref: baredSC.combineMultipleModels_2d.parse_arguments
:module: baredSC.combineMultipleModels_2d
:func: parse_arguments
:prog: combineMultipleModels_2d
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sphinx-argparse
sphinx-autorun
IPython
anndata
pickleshare

0 comments on commit 3128a77

Please sign in to comment.