From 20db8c57453e2f3e6d95dda1802a533395867ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Wed, 18 May 2022 10:48:40 +0200 Subject: [PATCH] Add version to _version file, method and test --- Makefile | 5 +---- mufs/Selection.py | 6 ++++++ mufs/__init__.py | 1 - mufs/_version.py | 1 + mufs/tests/MUFS_test.py | 7 ++++++- setup.py | 6 ++++-- 6 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 mufs/_version.py diff --git a/Makefile b/Makefile index 490f7c6..1d042b5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SHELL := /bin/bash .DEFAULT_GOAL := help -.PHONY: coverage deps help lint push test doc build +.PHONY: coverage deps help lint push test build coverage: ## Run tests with coverage coverage erase @@ -26,9 +26,6 @@ build: ## Build package rm -fr build/* python setup.py sdist bdist_wheel -doc-clean: ## Update documentation - make -C docs --makefile=Makefile clean - help: ## Show help message @IFS=$$'\n' ; \ help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \ diff --git a/mufs/Selection.py b/mufs/Selection.py index 9eb6ed9..4134eff 100755 --- a/mufs/Selection.py +++ b/mufs/Selection.py @@ -3,6 +3,7 @@ from sys import float_info from itertools import combinations import numpy as np from .Metrics import Metrics +from ._version import __version__ class MUFS: @@ -40,6 +41,11 @@ class MUFS: ) self._fitted = False + @staticmethod + def version() -> str: + """Return the version of the package.""" + return __version__ + def _initialize(self, X, y): """Initialize the attributes so support multiple calls using same object diff --git a/mufs/__init__.py b/mufs/__init__.py index 2fe76a0..5f9ddb4 100644 --- a/mufs/__init__.py +++ b/mufs/__init__.py @@ -1,6 +1,5 @@ from .Selection import MUFS -__version__ = "0.1.2" __author__ = "Ricardo Montañana Gómez" __author_email__ = "Ricardo.Montanana@alu.uclm.es" __copyright__ = "Copyright 2021, Ricardo Montañana Gómez" diff --git a/mufs/_version.py b/mufs/_version.py new file mode 100644 index 0000000..ae73625 --- /dev/null +++ b/mufs/_version.py @@ -0,0 +1 @@ +__version__ = "0.1.3" diff --git a/mufs/tests/MUFS_test.py b/mufs/tests/MUFS_test.py index 1b60d61..1331aa6 100755 --- a/mufs/tests/MUFS_test.py +++ b/mufs/tests/MUFS_test.py @@ -4,8 +4,8 @@ import pandas as pd import numpy as np from mdlp import MDLP from sklearn.datasets import load_wine, load_iris - from ..Selection import MUFS +from .._version import __version__ class MUFSTest(unittest.TestCase): @@ -18,6 +18,11 @@ class MUFSTest(unittest.TestCase): mdlp = MDLP(random_state=1) self.X_i = mdlp.fit_transform(self.X_ic, self.y_i).astype("int64") + def test_version(self): + """Check package version.""" + mufs = MUFS() + self.assertEqual(__version__, mufs.version()) + def assertListAlmostEqual(self, list1, list2, tol=7): self.assertEqual(len(list1), len(list2)) for a, b in zip(list1, list2): diff --git a/setup.py b/setup.py index 4ca9e9b..70bb881 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +import os import setuptools @@ -6,9 +7,10 @@ def readme(): return f.read() -def get_data(field: str): +def get_data(field): item = "" - with open("mufs/__init__.py") as f: + file_name = "_version.py" if field == "version" else "__init__.py" + with open(os.path.join("mufs", file_name)) as f: for line in f.readlines(): if line.startswith(f"__{field}__"): delim = '"' if '"' in line else "'"