Skip to content

Commit

Permalink
fix usage of the deprecation module
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Feb 8, 2020
1 parent 64eb2c7 commit 1eac402
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
29 changes: 15 additions & 14 deletions sourmash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@

ffi.init_once(lib.sourmash_init, "init")

from pkg_resources import get_distribution, DistributionNotFound

try:
VERSION = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
try:
from .version import version as VERSION # noqa
except ImportError: # pragma: no cover
raise ImportError(
"Failed to find (autogenerated) version.py. "
"This might be because you are installing from GitHub's tarballs, "
"use the PyPI ones."
)

from ._minhash import MinHash, get_minhash_default_seed, get_minhash_max_hash

DEFAULT_SEED = get_minhash_default_seed()
Expand All @@ -22,6 +36,7 @@
SourmashSignature,
save_signatures,
)

from .sbtmh import load_sbt_index, search_sbt_index, create_sbt_index
from . import lca
from . import sbt
Expand All @@ -31,17 +46,3 @@
from . import sig
from . import cli
from . import commands

from pkg_resources import get_distribution, DistributionNotFound

try:
VERSION = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
try:
from .version import version as VERSION # noqa
except ImportError: # pragma: no cover
raise ImportError(
"Failed to find (autogenerated) version.py. "
"This might be because you are installing from GitHub's tarballs, "
"use the PyPI ones."
)
16 changes: 10 additions & 6 deletions sourmash/_minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import math
import copy

from . import VERSION
from ._compat import string_types, range_type
from ._lowlevel import ffi, lib
from .utils import RustObject, rustcall, decode_str
Expand Down Expand Up @@ -439,8 +440,9 @@ def downsample_scaled(self, new_scaled):

return a

@deprecated(version='3.3',
reason='Use count_common or set methods instead.')
@deprecated(deprecated_in="3.3", removed_in="4.0",
current_version=VERSION,
details='Use count_common or set methods instead.')
def intersection(self, other, in_common=False):
"""Calculate the intersection between ``self`` and ``other``, and
return ``(mins, size)`` where ``mins`` are the hashes in common, and
Expand Down Expand Up @@ -479,8 +481,9 @@ def jaccard(self, other, downsample=False):
raise TypeError(err)
return self._methodcall(lib.kmerminhash_similarity, other._get_objptr(), True, downsample)

@deprecated(version='3.3',
reason="Use 'similarity' instead of compare.")
@deprecated(deprecated_in="3.3", removed_in="4.0",
current_version=VERSION,
details="Use 'similarity' instead of compare.")
def compare(self, other, downsample=False):
"Calculate Jaccard similarity of two sketches."
return self.jaccard(other, downsample=downsample)
Expand Down Expand Up @@ -521,8 +524,9 @@ def contained_by(self, other, downsample=False):

return self.count_common(other, downsample) / len(self)

@deprecated(version='3.3',
reason="Use 'contained_by' with downsample=True instead.")
@deprecated(deprecated_in="3.3", removed_in="4.0",
current_version=VERSION,
details="Use 'contained_by' with downsample=True instead.")
def containment_ignore_maxhash(self, other):
"""Calculate contained_by, with downsampling.
"""
Expand Down

0 comments on commit 1eac402

Please sign in to comment.