diff --git a/odte/Odte.py b/odte/Odte.py index bd202e5..036be0a 100644 --- a/odte/Odte.py +++ b/odte/Odte.py @@ -23,6 +23,7 @@ ) from joblib import Parallel, delayed # type: ignore from stree import Stree # type: ignore +from ._version import __version__ class Odte(BaseEnsemble, ClassifierMixin): @@ -49,6 +50,10 @@ def __init__( self.max_samples = max_samples # size of bootstrap self.be_hyperparams = be_hyperparams + @staticmethod + def version() -> str: + return __version__ + def _initialize_random(self) -> np.random.mtrand.RandomState: if self.random_state is None: self.random_state = random.randint(0, sys.maxsize) diff --git a/odte/__init__.py b/odte/__init__.py index c3c684d..deaf8e4 100644 --- a/odte/__init__.py +++ b/odte/__init__.py @@ -1,8 +1,7 @@ from .Odte import Odte +from ._version import __version__ -__version__ = "0.3.1" - -__author__ = "Rica.rdo Montañana Gómez" +__author__ = "Ricardo Montañana Gómez" __copyright__ = "Copyright 2020-2021, Ricardo Montañana Gómez" __license__ = "MIT License" __author_email__ = "ricardo.montanana@alu.uclm.es" diff --git a/odte/_version.py b/odte/_version.py new file mode 100644 index 0000000..260c070 --- /dev/null +++ b/odte/_version.py @@ -0,0 +1 @@ +__version__ = "0.3.1" diff --git a/odte/tests/Odte_tests.py b/odte/tests/Odte_tests.py index 0fc16b4..f19f063 100644 --- a/odte/tests/Odte_tests.py +++ b/odte/tests/Odte_tests.py @@ -9,6 +9,7 @@ from odte import Odte from stree import Stree from .utils import load_dataset +from .._version import __version__ class Odte_test(unittest.TestCase): @@ -252,3 +253,7 @@ def test_base_estimator_hyperparams(self): for estimator in tclf.estimators_: for key, value in hyperparams.items(): self.assertEqual(value, estimator.get_params()[key]) + + def test_version(self): + tclf = Odte() + self.assertEqual(__version__, tclf.version()) diff --git a/setup.py b/setup.py index 93a9be2..2cab1c0 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import setuptools +import os def readme(): @@ -8,7 +9,8 @@ def readme(): def get_data(field): item = "" - with open("odte/__init__.py") as f: + file_name = "_version.py" if field == "version" else "__init__.py" + with open(os.path.join("odte", file_name)) as f: for line in f.readlines(): if line.startswith(f"__{field}__"): delim = '"' if '"' in line else "'"