Skip to content

Commit

Permalink
Add version info to model
Browse files Browse the repository at this point in the history
  • Loading branch information
rmontanana committed Dec 17, 2021
1 parent 2ebec2d commit 7481af3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions odte/Odte.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions odte/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions odte/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.1"
5 changes: 5 additions & 0 deletions odte/tests/Odte_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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())
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import setuptools
import os


def readme():
Expand All @@ -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 "'"
Expand Down

0 comments on commit 7481af3

Please sign in to comment.