Skip to content

Commit

Permalink
Merge pull request #521 from GavinHuttley/develop
Browse files Browse the repository at this point in the history
pre-release code maintenance
  • Loading branch information
GavinHuttley committed Feb 7, 2020
2 parents 449cdaf + c150e6d commit 9a50192
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/cogent3/align/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from cogent3.core.alignment import Aligned
from cogent3.evolve.likelihood_tree import LikelihoodTreeEdge
from cogent3.util.modules import ExpectedImportError, importVersionedModule
from cogent3.util.warning import deprecated, discontinued

from .indel_positions import leaf2pog

Expand Down
7 changes: 3 additions & 4 deletions src/cogent3/core/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,9 @@ class Source(_Feature):
type = "source"

def __init__(self, seq, map, accession, basemap):
self._serialisable = locals()
for key in ("self", "__class__", "kw"):
self._serialisable.pop(key, None)
self._serialisable
d = locals()
exclude = ("self", "__class__")
self._serialisable = {k: v for k, v in d.items() if k not in exclude}

self.accession = accession
self.name = repr(basemap) + " of " + accession
Expand Down
23 changes: 11 additions & 12 deletions src/cogent3/core/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ def __init__(
value=None,
reverse=False,
):
self._serialisable = locals()
for key in ("self", "__class__", "__slots__"):
self._serialisable.pop(key, None)
d = locals()
x = ("self", "__class__", "__slots__")
self._serialisable = {k: v for k, v in d.items() if k not in x}

self._new_init(start, end, reverse)
self.tidy_start = tidy_start
Expand All @@ -253,10 +253,9 @@ def _new_init(self, start, end=None, reverse=False):
If end is not supplied, it is set to start + 1 (providing a 1-element
range).
reverse defaults to False.
This should replace the current __init__ method when deprecated vars
are removed.
"""
# This should replace the current __init__ method when deprecated vars
# are removed.
# special handling in case we were passed another Span
if isinstance(start, Span):
assert end is None
Expand Down Expand Up @@ -480,9 +479,9 @@ class _LostSpan(object):
terminal = False

def __init__(self, length, value=None):
self._serialisable = locals()
for key in ("self", "__class__", "__slots__"):
self._serialisable.pop(key, None)
d = locals()
exclude = ("self", "__class__", "__slots__")
self._serialisable = {k: v for k, v in d.items() if k not in exclude}

self.length = length
self.value = value
Expand Down Expand Up @@ -563,9 +562,9 @@ def __init__(
termini_unknown=False,
):
assert parent_length is not None
self._serialisable = locals()
for key in ("self", "__class__", "__slots__"):
self._serialisable.pop(key, None)
d = locals()
exclude = ("self", "__class__", "__slots__")
self._serialisable = {k: v for k, v in d.items() if k not in exclude}

if spans is None:
spans = []
Expand Down
7 changes: 1 addition & 6 deletions src/cogent3/evolve/likelihood_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
from cogent3.recalculation.definition import ParameterController
from cogent3.util import table
from cogent3.util.dict_array import DictArrayTemplate
from cogent3.util.misc import (
adjusted_gt_minprob,
adjusted_within_bounds,
get_object_provenance,
)
from cogent3.util.warning import deprecated, discontinued
from cogent3.util.misc import adjusted_gt_minprob, get_object_provenance


__author__ = "Peter Maxwell"
Expand Down
7 changes: 3 additions & 4 deletions src/cogent3/evolve/parameter_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from cogent3.maths.stats.information_criteria import aic, bic
from cogent3.recalculation.scope import _indexed
from cogent3.util.misc import adjusted_gt_minprob
from cogent3.util.warning import deprecated, discontinued


__author__ = "Peter Maxwell"
Expand Down Expand Up @@ -72,9 +71,9 @@ def __init__(
**kw,
):
# cache of arguments used to construct
self._serialisable = locals()
for key in ("self", "__class__", "kw"):
self._serialisable.pop(key)
d = locals()
exclude = ("self", "__class__", "kw")
self._serialisable = {k: v for k, v in d.items() if k not in exclude}
self._serialisable.update(kw)

self.model = self._model = model
Expand Down
23 changes: 15 additions & 8 deletions src/cogent3/evolve/substitution_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ def __init__(
tuple-alphabet (including codon) motif probs are used.
"""
self._serialisable = locals()
self._serialisable.pop("self")
d = locals()
exclude = ("self", "__class__")
self._serialisable = {k: v for k, v in d.items() if k not in exclude}
# MISC
assert len(alphabet) < 65, (
"Alphabet too big. Try explicitly " "setting alphabet to PROTEIN or DNA"
Expand Down Expand Up @@ -469,8 +470,10 @@ def __init__(
"""

_SubstitutionModel.__init__(self, alphabet, **kw)
self._serialisable.update(locals())
self._serialisable.pop("self")
d = locals()
exclude = ("self", "__class__")
d = {k: v for k, v in d.items() if k not in exclude}
self._serialisable.update(d)
alphabet = self.get_alphabet() # as may be altered by recode_gaps etc.

# BINS
Expand Down Expand Up @@ -679,8 +682,10 @@ def __init__(self, alphabet, rate_matrix, **kw):
- rate_matrix: The instantaneous rate matrix
"""
_ContinuousSubstitutionModel.__init__(self, alphabet, **kw)
self._serialisable.update(locals())
self._serialisable.pop("self")
d = locals()
exclude = ("self", "__class__")
d = {k: v for k, v in d.items() if k not in exclude}
self._serialisable.update(d)

alphabet = self.get_alphabet() # as may be altered by recode_gaps etc.
N = len(alphabet)
Expand Down Expand Up @@ -710,8 +715,10 @@ def __init__(self, alphabet, predicates=None, scales=None, **kw):
self._canned_predicates = None
_ContinuousSubstitutionModel.__init__(self, alphabet, **kw)

self._serialisable.update(locals())
self._serialisable.pop("self")
d = locals()
exclude = ("self", "__class__")
d = {k: v for k, v in d.items() if k not in exclude}
self._serialisable.update(d)

(predicate_masks, predicate_order) = self._adapt_predicates(predicates or [])

Expand Down
4 changes: 1 addition & 3 deletions src/cogent3/phylo/nj.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ def _show_progress():
return ScoredTreeCollection(result)


def nj(dists, no_negatives=True, show_progress=True):
def nj(dists, show_progress=True):
"""Arguments:
- dists: dict of (name1, name2): distance
- no_negatives: negative branch lengths will be set to 0
"""
assert no_negatives, "no_negatives=False is deprecated"
(result,) = gnj(dists, keep=1, show_progress=show_progress)
(score, tree) = result
return tree

0 comments on commit 9a50192

Please sign in to comment.