Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version to _version file, method and test #6

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build
on:
push:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
python: [3.8]
python: [3.8, "3.10"]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,7 @@ jobs:
pip install -q --upgrade pip
pip install -q cython
pip install -q numpy
pip install -q git+git://github.com/doctorado-ml/mdlp
pip install -q git+https://github.com/doctorado-ml/mdlp
pip install -q -r requirements/dev.txt
pip install -q --upgrade codecov coverage black flake8 codacy-coverage
- name: Lint
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/##/:/'`); \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Doctorado-ML/mufs.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Doctorado-ML/mufs/context:python)
[![PyPI version](https://badge.fury.io/py/MUFS.svg)](https://badge.fury.io/py/MUFS)
![https://img.shields.io/badge/python-3.8%2B-blue](https://img.shields.io/badge/python-3.8%2B-brightgreen)
[![Security Rating](https://haystack.rmontanana.es:25000/api/project_badges/measure?project=mufs&metric=security_rating&token=1119a3bfd4025d50ef3009a44c600c16670ee31a)](http://haystack.local:25000/dashboard?id=mufs)
[![Technical Debt](https://haystack.rmontanana.es:25000/api/project_badges/measure?project=mufs&metric=sqale_index&token=1119a3bfd4025d50ef3009a44c600c16670ee31a)](http://haystack.local:25000/dashboard?id=mufs)

# MUFS

Expand Down
8 changes: 7 additions & 1 deletion mufs/Selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from itertools import combinations
import numpy as np
from .Metrics import Metrics
from ._version import __version__


class MUFS:
Expand Down Expand Up @@ -40,6 +41,11 @@ def __init__(self, max_features=None, discrete=True):
)
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
Expand Down Expand Up @@ -128,7 +134,7 @@ def _compute_merit(self, features):
k = len(features)
for pair in list(combinations(features, 2)):
rff += self._compute_su_features(*pair)
return rcf / sqrt(k + (k ** 2 - k) * rff)
return rcf / sqrt(k + (k**2 - k) * rff)

def cfs(self, X, y):
"""Correlation-based Feature Selection
Expand Down
3 changes: 1 addition & 2 deletions mufs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
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"
__copyright__ = "Copyright 2021-2022, Ricardo Montañana Gómez"
__license__ = "MIT License"

__all__ = ["MUFS"]
1 change: 1 addition & 0 deletions mufs/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.3"
7 changes: 6 additions & 1 deletion mufs/tests/MUFS_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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):
Expand All @@ -18,6 +18,11 @@ def __init__(self, *args, **kwargs):
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):
Expand Down
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import setuptools


Expand All @@ -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 "'"
Expand All @@ -19,6 +21,11 @@ def get_data(field: str):
return item


def get_requirements():
with open("requirements/production.txt") as f:
return f.read().splitlines()


setuptools.setup(
name="MUFS",
version=get_data("version"),
Expand All @@ -38,11 +45,13 @@ def get_data(field: str):
"Development Status :: 4 - Beta",
"License :: OSI Approved :: " + get_data("license"),
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Natural Language :: English",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Intended Audience :: Science/Research",
],
install_requires=["scikit-learn"],
install_requires=get_requirements(),
test_suite="mufs.tests",
zip_safe=False,
)
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sonar.projectKey=mufs