diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4d15100..aca7b88 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies diff --git a/README.rst b/README.rst index b1ced0a..c0e1e19 100644 --- a/README.rst +++ b/README.rst @@ -247,7 +247,7 @@ Thanks to Whit Athey, Ryan Dale, Binh Bui, Jeff Gill, Gopal Vashishtha, `CS50 `_, and `openSNP `_. ``lineage`` incorporates code and concepts generated with the assistance of -`OpenAI's `_ `ChatGPT `_ (GPT-3.5). ✨ +`OpenAI's `_ `ChatGPT `_ . ✨ .. https://github.com/rtfd/readthedocs.org/blob/master/docs/badges.rst .. |ci| image:: https://github.com/apriha/lineage/actions/workflows/ci.yml/badge.svg?branch=master diff --git a/docs/conf.py b/docs/conf.py index ab6120f..c121253 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,6 +19,7 @@ # import os import sys +from unittest.mock import MagicMock # http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules autodoc_mock_imports = [ @@ -31,6 +32,17 @@ sys.path.insert(0, os.path.abspath("../")) + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + +# Apply the mock for each module +for mod_name in autodoc_mock_imports: + sys.modules[mod_name] = Mock() + import lineage # https://samnicholls.net/2016/06/15/how-to-sphinx-readthedocs/ diff --git a/src/lineage/visualization.py b/src/lineage/visualization.py index ca58547..07d0388 100644 --- a/src/lineage/visualization.py +++ b/src/lineage/visualization.py @@ -70,7 +70,6 @@ matplotlib.use("Agg") from matplotlib import pyplot as plt -from matplotlib.collections import BrokenBarHCollection from matplotlib import patches logger = logging.getLogger(__name__) @@ -139,7 +138,8 @@ def plot_chromosomes(one_chrom_match, two_chrom_match, cytobands, path, title, b # Now all we have to do is call our function for the chromosome data... for collection in _chromosome_collections(df, chrom_ybase, chrom_height): - ax.add_collection(collection) + xranges, yrange, colors = collection + ax.broken_barh(xranges, yrange, facecolors=colors) # Axes tweaking ax.set_yticks([chrom_centers[i] for i in chromosome_list]) @@ -184,8 +184,8 @@ def plot_chromosomes(one_chrom_match, two_chrom_match, cytobands, path, title, b def _chromosome_collections(df, y_positions, height, **kwargs): """ - Yields BrokenBarHCollection of features that can be added to an Axes - object. + Yields data for features that can be added to an Axes + object using ax.broken_barh. Parameters ---------- @@ -195,13 +195,12 @@ def _chromosome_collections(df, y_positions, height, **kwargs): column 'width', it will be calculated from start/end. y_positions : dict - Keys are chromosomes, values are y-value at which to anchor the - BrokenBarHCollection + Keys are chromosomes, values are y-value at which to anchor the bars height : float - Height of each BrokenBarHCollection + Height of each bar - Additional kwargs are passed to BrokenBarHCollection + Additional kwargs are passed to ax.broken_barh """ del_width = False if "width" not in df.columns: @@ -210,9 +209,8 @@ def _chromosome_collections(df, y_positions, height, **kwargs): for chrom, group in df.groupby("chrom"): yrange = (y_positions["chr" + chrom], height) xranges = group[["start", "width"]].values - yield BrokenBarHCollection( - xranges, yrange, facecolors=group["colors"], **kwargs - ) + colors = group["colors"].values + yield xranges, yrange, colors if del_width: del df["width"]