Skip to content

Commit dc2a649

Browse files
committed
Added fuzzy_number, fuzzy_set, trapezoidal_fuzzy_number + CI
1 parent 93cf8bf commit dc2a649

33 files changed

+25643
-0
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: build
5+
6+
on: [push]
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
# Only use python version matching libboost_python*.so lib
13+
# 3.8 for ubuntu 20.04
14+
# 3.10 for ubuntu 22.04
15+
# ...
16+
# Unfortunately, 3.x does not work for ubuntu-latest
17+
python-version: ["3.11"]
18+
# poetry-version >= 1.2 is required to support groups
19+
poetry-version: ["1.3.2"]
20+
os: [ubuntu-latest]
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
# https://github.com/marketplace/actions/python-poetry-action
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
# https://github.com/actions/setup-python/issues/529
28+
# https://github.com/actions/setup-python#caching-packages-dependencies
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@main
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
cache: 'pip'
34+
35+
- name: Run image
36+
uses: abatilo/actions-poetry@v2
37+
with:
38+
poetry-version: ${{ matrix.poetry-version }}
39+
40+
- name: Install Python dependencies
41+
run: |
42+
poetry install --with dev,test
43+
44+
- name: Lint with flake8
45+
run: |
46+
# stop the build if there are Python syntax errors or undefined names
47+
poetry run flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
48+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
49+
poetry run flake8 src/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
50+
51+
- name: Run tests and generate coverage report
52+
run: |
53+
# tox -e py
54+
poetry run coverage run -m pytest
55+
poetry run coverage xml
56+
57+
- name: Upload coverage to Codecov
58+
uses: codecov/codecov-action@v3

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will generate the docs on each push, and publish them on GitHub Pages if the branch is "main".
2+
3+
name: docs
4+
5+
on: [push]
6+
7+
jobs:
8+
build-and-deploy:
9+
strategy:
10+
matrix:
11+
# Only use python version matching libboost_python*.so lib
12+
# 3.8 for ubuntu 20.04
13+
# 3.10 for ubuntu 22.04
14+
# ...
15+
# Unfortunately, 3.x does not work for ubuntu-latest
16+
python-version: ["3.11"]
17+
# poetry-version >= 1.2 is required to support groups
18+
poetry-version: ["1.3.2"]
19+
os: [ubuntu-latest]
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
# https://github.com/marketplace/actions/python-poetry-action
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
26+
# https://github.com/actions/setup-python/issues/529
27+
# https://github.com/actions/setup-python#caching-packages-dependencies
28+
- name: Set up Python
29+
uses: actions/setup-python@main
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
cache: 'pip' # Caching dependencies
33+
34+
- name: Run image
35+
uses: abatilo/actions-poetry@v2
36+
with:
37+
poetry-version: ${{ matrix.poetry-version }}
38+
39+
- name: Install package
40+
run: |
41+
poetry install --with docs
42+
43+
- name: Build Sphinx documentation
44+
run: |
45+
#sphinx-build -a -E -b html docs build
46+
poetry run sphinx-build -a -E -b html docs build
47+
48+
- name: Deploy Sphinx documentation on Github Pages
49+
uses: JamesIves/[email protected]
50+
if: github.ref == 'refs/heads/main'
51+
with:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
BRANCH: gh-pages
54+
FOLDER: build/
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#the-whole-ci-cd-workflow
2+
3+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
4+
5+
on: push
6+
7+
jobs:
8+
build:
9+
name: Build distribution 📦
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
persist-credentials: false
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.x"
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
- name: Build a binary wheel and a source tarball
27+
run: python3 -m build
28+
- name: Store the distribution packages
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
34+
publish-to-pypi:
35+
name: >-
36+
Publish Python 🐍 distribution 📦 to PyPI
37+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
38+
needs:
39+
- build
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: pypi
43+
url: https://pypi.org/p/sphinx_uml
44+
permissions:
45+
id-token: write # IMPORTANT: mandatory for trusted publishing
46+
47+
steps:
48+
- name: Download all the dists
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
- name: Publish distribution 📦 to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
56+
publish-to-testpypi:
57+
name: Publish Python 🐍 distribution 📦 to TestPyPI
58+
needs:
59+
- build
60+
runs-on: ubuntu-latest
61+
62+
environment:
63+
name: testpypi
64+
url: https://test.pypi.org/p/sphinx_uml
65+
66+
permissions:
67+
id-token: write # IMPORTANT: mandatory for trusted publishing
68+
69+
steps:
70+
- name: Download all the dists
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: python-package-distributions
74+
path: dist/
75+
- name: Publish distribution 📦 to TestPyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1
77+
with:
78+
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Packaging
2+
build/
3+
dist/
4+
.coverage
5+
.pytest_cache
6+
.tox/
7+
__pycache__
8+
*.egg-info
9+
10+
# Python
11+
*.pyc
12+
*.ipynb
13+
14+
# Editor
15+
*.swp
16+
17+
# Helpers
18+
install.sh

.readthedocs.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
# Install APT package as explained in:
10+
# https://docs.readthedocs.io/en/stable/build-customization.html
11+
build:
12+
os: "ubuntu-22.04"
13+
tools:
14+
python: "3.11"
15+
apt_packages:
16+
- graphviz # https://stackoverflow.com/a/77369269
17+
jobs:
18+
# https://docs.readthedocs.io/en/stable/build-customization.html
19+
post_create_environment:
20+
# Install poetry
21+
# https://python-poetry.org/docs/#installing-manually
22+
- pip install poetry
23+
# Tell poetry to not use a virtual environment
24+
- poetry config virtualenvs.create false
25+
post_install:
26+
# Install dependencies with 'docs' dependency group
27+
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
28+
# Readthedoc and poetry
29+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
30+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry run sphinx-apidoc -f -o docs/ src/ --separate
31+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry run sphinx-build -b html docs/ docs/_build/html
32+
33+
# Build documentation in the docs/ directory with Sphinx
34+
sphinx:
35+
configuration: docs/conf.py

AUTHORS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Development Lead
2+
3+
* [Marc-Olivier Buob](https://www.bell-labs.com/about/researcher-profiles/marc-olivier-buob/) <[[email protected]](mailto:[email protected])>
4+
5+
## Contributors
6+
7+
* [Adrien Banse](https://github.com/adrienbanse)
8+
* [Samuel Rincé](https://github.com/samuelrince)

HISTORY.md

Whitespace-only changes.

Makefile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.PHONY: clean clean-test clean-pyc clean-build docs help
2+
.DEFAULT_GOAL := help
3+
4+
define BROWSER_PYSCRIPT
5+
import os, webbrowser, sys
6+
7+
from urllib.request import pathname2url
8+
9+
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
10+
endef
11+
export BROWSER_PYSCRIPT
12+
13+
define PRINT_HELP_PYSCRIPT
14+
import re, sys
15+
16+
for line in sys.stdin:
17+
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
18+
if match:
19+
target, help = match.groups()
20+
print("%-20s %s" % (target, help))
21+
endef
22+
export PRINT_HELP_PYSCRIPT
23+
24+
BROWSER := python3 -c "$$BROWSER_PYSCRIPT"
25+
PROJECT := fuzzy_set
26+
27+
help:
28+
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
29+
30+
clean: clean-doc clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
31+
32+
clean-build: ## remove build artifacts
33+
rm -fr build/
34+
rm -fr dist/
35+
rm -fr .eggs/
36+
find . -name '*.egg-info' -exec rm -fr {} +
37+
find . -name '*.egg' -exec rm -fr {} +
38+
39+
clean-pyc: ## remove Python file artifacts
40+
find . -name '*.pyc' -exec rm -f {} +
41+
find . -name '*.pyo' -exec rm -f {} +
42+
find . -name '*~' -exec rm -f {} +
43+
find . -name '__pycache__' -exec rm -fr {} +
44+
45+
clean-test: ## remove test and coverage artifacts
46+
rm -fr .tox/
47+
rm -f .coverage
48+
rm -fr htmlcov/
49+
rm -fr .pytest_cache
50+
51+
lint: ## check style with flake8
52+
poetry run flake8 src tests
53+
54+
test: ## run tests quickly with the default Python
55+
poetry run pytest
56+
57+
test-all: ## run tests on every Python version with tox
58+
poetry run tox
59+
60+
coverage: ## check code coverage quickly with the default Python
61+
poetry run coverage run -m pytest
62+
poetry run coverage html
63+
poetry run coverage xml
64+
$(BROWSER) htmlcov/index.html
65+
66+
clean-doc:
67+
rm -rf docs/_build
68+
rm -rf docs/_autosummary
69+
rm -f docs/$(PROJECT).*.rst
70+
71+
docs: clean-doc ## generate Sphinx HTML documentation, including API docs
72+
poetry run sphinx-apidoc -f -o docs/ src/ --separate
73+
poetry run sphinx-build -b html docs/ docs/_build/html
74+
$(BROWSER) docs/_build/html/index.html
75+
76+
servedocs: docs ## compile the docs watching for changes
77+
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
78+
79+
release: dist ## package and upload a release
80+
poetry publish
81+
82+
dist: clean ## builds source and wheel package
83+
poetry build
84+
85+
install: clean dist ## install the package to the active Python's site-packages
86+
pip3 install dist/*whl --break-system-packages --force-reinstall --no-deps

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `fuzzy-set`
2+
## Overview
3+
4+
The `fuzzy-set` is a [Python3](https://www.python.org/downloads/) framework built on top of [Numpy](https://numpy.org/) and [Matplotlib](https://matplotlib.org/) allowing to plot and manipulate:
5+
6+
* [Fuzzy Sets](src/fuzzy_set/fuzzy_set.py);
7+
* [Fuzzy Numbers](src/fuzzy_set/fuzzy_number.py);
8+
* [Trapezoidal Fuzzy Numbers](src/fuzzy_set/trapezoidal_fuzzy_number.py);
9+
10+
__Details:__
11+
12+
* [Authors](AUTHORS.md)
13+
* [History](HISTORY.md)
14+
* [LICENSE](LICENSE)
15+
16+
## [Documentation](https://nokia-fuzzy-set.readthedocs.io/en/latest/?badge=latest)
17+
18+
## References
19+
20+
* [Managing Uncertainties in ICT Services Life Cycle Assessment using Fuzzy Logic](https://hal.science/hal-04532041/), Édouard Guégain, Thibault Simon, Alban Rahier, Romain Rouvoy
21+
* [Environmental life cycle assessment with support of fuzzy-sets](https://link.springer.com/article/10.1007/BF02977589), Albert Weckenmann & Achim Schwan
22+
* [Ecologits Github](https://github.com/genai-impact/ecologits/tree/main/ecologits/data)

0 commit comments

Comments
 (0)