Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10, and macOS integration testing #115

Merged
merged 10 commits into from
May 15, 2023
10 changes: 6 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ on:

jobs:
build:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, "3.10"] # https://github.com/actions/runner/issues/1989

runs-on: ${{ matrix.os }}

steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Pandoc
uses: r-lib/actions/setup-pandoc@v2
Expand Down Expand Up @@ -46,6 +46,8 @@ jobs:
run: make test

- name: Test docs build
# NOTE: only run on ubuntu-latest to save on compute usage
if: matrix.os == 'ubuntu-latest'
shell: bash -l {0}
run: |
make docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Pandoc
uses: r-lib/actions/setup-pandoc@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions docs/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ Developer install::

make install

.. warning::

If you're working on an ARM Mac, you may run into trouble installing the PyQt5 dependency
(which is also a dependency of the ``historydag`` package) via pip. As a workaround,
we recommend commenting out the the ``PyQt5``, ``ete3``, and ``historydag`` lines from
the ``setup.py`` and installing those via Conda.

Run tests::

make test
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The preferred way to install gctree is with Conda:

.. code-block:: bash

conda create -n gctree python=3.9
conda create -n gctree python=3.10
conda activate gctree
conda install -c conda-forge gctree

Expand Down
1 change: 0 additions & 1 deletion gctree/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# This file is released into the public domain. Generated by
# versioneer-0.18 (https://github.com/warner/python-versioneer)

"""Git implementation of _version.py."""

import errno
Expand Down
14 changes: 8 additions & 6 deletions gctree/branching_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def simulate(self, p: np.float64, q: np.float64, root: bool = True):
self._build_cm_counts()

def __repr__(self):
r"""return a string representation for printing."""
r"""Return a string representation for printing."""
return str(self.tree)

def render(
Expand Down Expand Up @@ -1266,7 +1266,8 @@ def mask(weighttuple, n=10):
dagweight_kwargs = ll_dagfuncs + iso_funcs + mut_funcs + allele_funcs
trimdag = dag.copy()
trimdag.trim_optimal_weight(
**dagweight_kwargs, optimal_func=lambda l: min(l, key=minfunckey)
**dagweight_kwargs,
optimal_func=lambda l: min(l, key=minfunckey), # noqa: E741
)
# make sure trimming worked as expected:
min_weightcounter = trimdag.weight_count(**dagweight_kwargs)
Expand All @@ -1278,7 +1279,8 @@ def mask(weighttuple, n=10):
)

best_weighttuple = trimdag.optimal_weight_annotate(
**dagweight_kwargs, optimal_func=lambda l: min(l, key=minfunckey)
**dagweight_kwargs,
optimal_func=lambda l: min(l, key=minfunckey), # noqa: E741
)
if summarize_forest:
with open(outbase + ".forest_summary.log", "w") as fh:
Expand Down Expand Up @@ -1347,7 +1349,7 @@ def mask(weighttuple, n=10):
return (self._trimmed_self(trimdag), best_weighttuple)

def likelihood_rankplot(self, outbase, p, q, img_type="svg"):
"""save a rank plot of likelihoods to the file
"""Save a rank plot of likelihoods to the file
`[outbase].inference.likelihood_rank.[img_type]`."""
ll_dagfuncs = _ll_genotype_dagfuncs(p, q)
if self._forest is not None:
Expand Down Expand Up @@ -1587,7 +1589,7 @@ def _clade_tree_to_ctree(
return ctree

def __repr__(self):
r"""return a string representation for printing."""
r"""Return a string representation for printing."""
return f"n_trees = {self.n_trees}\n" "\n".join([str(tree) for tree in self])

def __iter__(self):
Expand Down Expand Up @@ -1615,7 +1617,7 @@ def _mle_helper(
bounds = ((1e-6, 1 - 1e-6), (1e-6, 1 - 1e-6))

def f(x):
"""negative log likelihood."""
"""Negative log likelihood."""
return tuple(-y for y in ll(*x, **kwargs))

grad_check = sco.check_grad(lambda x: f(x)[0], lambda x: f(x)[1], x_0)
Expand Down
2 changes: 1 addition & 1 deletion gctree/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test(args):


def infer(args):
"""inference subprogram."""
"""Inference subprogram."""

def isotype_add(forest):
forest.add_isotypes(
Expand Down
11 changes: 5 additions & 6 deletions gctree/mkconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
r"""Read a PHYLIP-format file and produce an appropriate config file for passing
to `dnapars`.

`dnapars` doesn't play very well in a
pipeline. It prompts the user for configuration information and reads
responses from stdin. The config file generated by this script is
meant to mimic the responses to the expected prompts.
`dnapars` doesn't play very well in a pipeline. It prompts the user for
configuration information and reads responses from stdin. The config
file generated by this script is meant to mimic the responses to the
expected prompts.

Typical usage is,

$ mkconfig sequence.phy > dnapars.cfg
$ dnapars < dnapars.cfg
$ mkconfig sequence.phy > dnapars.cfg $ dnapars < dnapars.cfg
"""
import os
import argparse
Expand Down
2 changes: 1 addition & 1 deletion gctree/mutation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(

@staticmethod
def _disambiguate(sequence):
r"""generator of all possible nt sequences implied by a sequence
r"""Generator of all possible nt sequences implied by a sequence
containing ambiguous bases."""
return _sequence_disambiguations(sequence)

Expand Down
3 changes: 1 addition & 2 deletions gctree/phylip_parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Given an outputfile from one of the PHYLIP tools - `dnaml` or `dnapars` -
produce a CollapsedForest containing the trees in that outputfile."""

Expand Down Expand Up @@ -100,7 +99,7 @@ def parse_seqdict(fh, mode="dnaml"):
# list biopython.SeqRecords and a dict containing adjacency
# relationships and distances between nodes.
def parse_outfile(outfile, abundance_file=None, root="root", disambiguate=False):
"""parse phylip outfile, and return dnapars trees."""
"""Parse phylip outfile, and return dnapars trees."""
if abundance_file is not None:
counts = {
line.split(",")[0]: int(line.split(",")[1]) for line in open(abundance_file)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
],
python_requires=">=3.7, <3.10",
python_requires=">=3.7",
install_requires=[
"PyQt5",
"ete3",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_isotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_trim_byisotype():
# idmap_file=None,
# isotype_names=None,
tdag = dag.copy()
tdag.optimal_weight_annotate(**kwargs, optimal_func=lambda l: l[0])
tdag.optimal_weight_annotate(**kwargs, optimal_func=lambda l: l[0]) # noqa: E741
for node in tdag.preorder():
if node.attr is not None:
node.attr["isotype"] = node._dp_data
Expand Down