Skip to content

Commit bb15b90

Browse files
committed
apply codestyle changes
1 parent 97da1f2 commit bb15b90

35 files changed

+936
-403
lines changed

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ci:
2+
autofix_prs: true
3+
autoupdate_schedule: monthly
4+
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
8+
hooks:
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- id: check-merge-conflict
12+
- id: check-case-conflict
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: check-ast
16+
- id: check-docstring-first
17+
18+
- repo: https://github.com/psf/black-pre-commit-mirror
19+
rev: 23.10.1
20+
hooks:
21+
- id: black
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.1.3
24+
hooks:
25+
- id: ruff
26+
args: [--fix, --exit-non-zero-on-fix]

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119119
version 2.0, available at
120120
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121121

122-
Community Impact Guidelines were inspired by
122+
Community Impact Guidelines were inspired by
123123
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124124

125125
For answers to common questions about this code of conduct, see the FAQ at
126-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127127
at [https://www.contributor-covenant.org/translations][translations].
128128

129129
[homepage]: https://www.contributor-covenant.org

docs/_static/output_sample.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ antecedent,consequent,fitness,support,confidence,lift,coverage,rhs_support,convi
88
"[Rings([1, 29]), Shucked weight([0.001, 1.488])]","[Viscera weight([0.0005, 0.76])]",1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.3333333333333333,0.9997605937275557,0.5,0.0,-1.0
99
"[Shucked weight([0.001, 1.488]), Rings([1, 29])]","[Whole weight([0.002, 2.8255]), Viscera weight([0.0005, 0.76])]",1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.4444444444444444,0.9997605937275557,0.6826061944859854,0.0,-1.0
1010
"[Rings([1, 29]), Whole weight([0.002, 2.8255])]","[Viscera weight([0.0005, 0.76])]",1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.3333333333333333,0.9997605937275557,0.5,0.0,-1.0
11-
"[Shucked weight([0.001, 1.488])]","[Height([0.0, 1.13]), Viscera weight([0.0005, 0.76])]",1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.3333333333333333,0.9997605937275557,0.7924812503605781,0.0,-1.0
11+
"[Shucked weight([0.001, 1.488])]","[Height([0.0, 1.13]), Viscera weight([0.0005, 0.76])]",1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.3333333333333333,0.9997605937275557,0.7924812503605781,0.0,-1.0

docs/api/text.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Text
33

44
.. automodule:: niaarm.text
55
:members:
6-
:show-inheritance:
6+
:show-inheritance:

docs/api/visualize.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Visualize
33

44
.. automodule:: niaarm.visualize
55
:members:
6-
:show-inheritance:
6+
:show-inheritance:

docs/cli.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,3 @@ E.g. (for the above run):
110110
Average length of antecedent: 1.97723292469352
111111
Average length of consequent: 1.5604203152364273
112112
Run Time: 6.4538s
113-

docs/conf.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,61 @@
1212
#
1313
import os
1414
import sys
15+
1516
sys.path.insert(0, os.path.abspath("../"))
1617

1718
# -- Project information -----------------------------------------------------
1819

19-
project = 'NiaARM'
20-
copyright = '2022-2023, Žiga Stupan, Iztok Fister Jr.'
21-
author = 'Žiga Stupan, Iztok Fister Jr.'
20+
project = "NiaARM"
21+
copyright = "2022-2023, Žiga Stupan, Iztok Fister Jr."
22+
author = "Žiga Stupan, Iztok Fister Jr."
2223

2324
# The full version, including alpha/beta/rc tags
24-
release = '0.3.3'
25+
release = "0.3.3"
2526

2627

2728
# -- General configuration ---------------------------------------------------
2829

2930
# Add any Sphinx extension module names here, as strings. They can be
3031
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3132
# ones.
32-
extensions = ['sphinx.ext.autodoc', 'sphinx_rtd_theme', 'sphinxcontrib.bibtex', 'sphinx.ext.napoleon']
33+
extensions = [
34+
"sphinx.ext.autodoc",
35+
"sphinx_rtd_theme",
36+
"sphinxcontrib.bibtex",
37+
"sphinx.ext.napoleon",
38+
]
3339

3440
# Add any paths that contain templates here, relative to this directory.
35-
templates_path = ['_templates']
41+
templates_path = ["_templates"]
3642

3743
# List of patterns, relative to source directory, that match files and
3844
# directories to ignore when looking for source files.
3945
# This pattern also affects html_static_path and html_extra_path.
40-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
46+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4147

4248

4349
# -- Options for HTML output -------------------------------------------------
4450

4551
# The theme to use for HTML and HTML Help pages. See the documentation for
4652
# a list of builtin themes.
4753
#
48-
html_theme = 'sphinx_rtd_theme'
54+
html_theme = "sphinx_rtd_theme"
4955

5056
# Add any paths that contain custom static files (such as style sheets) here,
5157
# relative to this directory. They are copied after the builtin static files,
5258
# so a file named "default.css" will overwrite the builtin "default.css".
53-
html_static_path = ['_static']
59+
html_static_path = ["_static"]
5460

5561
# Bibtex
56-
bibtex_bibfiles = ['refs.bib']
62+
bibtex_bibfiles = ["refs.bib"]
5763

5864
# Bibliography style
59-
bibtex_default_style = 'unsrt'
65+
bibtex_default_style = "unsrt"
6066

6167
# Add logo for project
62-
html_logo = '_static/logo.png'
68+
html_logo = "_static/logo.png"
6369
html_theme_options = {
64-
'logo_only': True,
65-
'display_version': False,
70+
"logo_only": True,
71+
"display_version": False,
6672
}

docs/documentation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ To locally generate and preview documentation run the following commands in the
88
poetry install --extras docs
99
poetry run sphinx-build ./docs ./docs/_build
1010
11-
If the build of the documentation is successful, you can preview the documentation in the docs/_build folder by clicking the ``index.html`` file.
11+
If the build of the documentation is successful, you can preview the documentation in the docs/_build folder by clicking the ``index.html`` file.

docs/installation.rst

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ run the following command from the root of the cloned project:
1616
1717
$ poetry install
1818
19+
To also install the documentation dependencies run:
20+
21+
.. code:: sh
22+
23+
$ poetry install --with docs
24+
1925
All of the project's dependencies should be installed and the project
2026
ready for further development. **Note that Poetry creates a separate
2127
virtual environment for your project.**
@@ -26,11 +32,13 @@ Dependencies
2632
+----------------+--------------+------------+
2733
| Package | Version | Platform |
2834
+================+==============+============+
29-
| niapy | ^2.0.1 | All |
35+
| niapy | ^2.0.5 | All |
3036
+----------------+--------------+------------+
31-
| pandas | ^1.3.5 | All |
37+
| pandas | ^2.1.1 | All |
3238
+----------------+--------------+------------+
33-
| numpy | ^1.21.5 | All |
39+
| numpy | ^1.26.1 | All |
40+
+----------------+--------------+------------+
41+
| nltk | ^3.8.1 | All |
3442
+----------------+--------------+------------+
3543

3644
Development Dependencies
@@ -39,18 +47,50 @@ Development Dependencies
3947
+--------------------+-----------+------------+
4048
| Package | Version | Platform |
4149
+====================+===========+============+
42-
| Pytest | ^7.0.1 | Any |
50+
| pre-commit | ^3.5.0 | Any |
51+
+--------------------+-----------+------------+
52+
53+
Test Dependencies
54+
~~~~~~~~~~~~~~~~~
55+
56+
+--------------------+-----------+------------+
57+
| Package | Version | Platform |
58+
+====================+===========+============+
59+
| pytest | ^7.4.2 | Any |
60+
+--------------------+-----------+------------+
61+
| pytest-cov | ^7.4.2 | Any |
62+
+--------------------+-----------+------------+
63+
| pytest-randomly | ^7.4.2 | Any |
4364
+--------------------+-----------+------------+
4465

45-
Extras
46-
~~~~~~
66+
Documentation dependencies
67+
~~~~~~~~~~~~~~~~~~~~~~~~~~
4768

4869
+------------------------------+--------------+------------+
4970
| Package | Version | Platform |
5071
+==============================+==============+============+
51-
| Sphinx | ^4.4.0 | Any |
72+
| sphinx | ^7.2.6 | Any |
5273
+------------------------------+--------------+------------+
5374
| sphinx-rtd-theme | ^1.0.0 | Any |
5475
+------------------------------+--------------+------------+
5576
| sphinxcontrib-bibtex | ^2.4.1 | Any |
5677
+------------------------------+--------------+------------+
78+
79+
80+
Pre-commit hooks
81+
~~~~~~~~~~~~~~~~
82+
83+
We use pre-commit hooks for formatting and linting. You can install the pre-commit hooks with:
84+
85+
.. code:: sh
86+
87+
$ pre-commit install
88+
89+
90+
Once the pre-commit hooks are installed and configured, they will automatically run before each git commit. If any hook fails, the commit will be aborted, and you'll need to address the issues raised by the hooks.
91+
92+
To manually run the pre-commit hooks on all files, use the following command:
93+
94+
.. code:: sh
95+
96+
$ pre-commit run --all-files

examples/basic_run.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from niapy.task import Task, OptimizationType
55

66

7-
if __name__ == '__main__':
7+
if __name__ == "__main__":
88
# load and preprocess the dataset from csv
99
data = Dataset("datasets/Abalone.csv")
1010

@@ -13,14 +13,24 @@
1313
# features represent the list of features, while transactions depicts the list of transactions
1414
# the following 4 elements represent weights (support, confidence, coverage, shrinkage)
1515
# A weight of 0.0 means that criteria are omitted and are, therefore, excluded from the fitness function
16-
problem = NiaARM(data.dimension, data.features, data.transactions, metrics=('support', 'confidence'), logging=True)
16+
problem = NiaARM(
17+
data.dimension,
18+
data.features,
19+
data.transactions,
20+
metrics=("support", "confidence"),
21+
logging=True,
22+
)
1723

1824
# build niapy task
19-
task = Task(problem=problem, max_iters=30, optimization_type=OptimizationType.MAXIMIZATION)
25+
task = Task(
26+
problem=problem, max_iters=30, optimization_type=OptimizationType.MAXIMIZATION
27+
)
2028

2129
# use Differential Evolution (DE) algorithm from the NiaPy library
2230
# see full list of available algorithms: https://github.com/NiaOrg/NiaPy/blob/master/Algorithms.md
23-
algo = DifferentialEvolution(population_size=50, differential_weight=0.5, crossover_probability=0.9)
31+
algo = DifferentialEvolution(
32+
population_size=50, differential_weight=0.5, crossover_probability=0.9
33+
)
2434

2535
# run algorithm
2636
best = algo.run(task=task)
@@ -29,4 +39,4 @@
2939
problem.rules.sort()
3040

3141
# export all rules to csv
32-
problem.rules.to_csv('output.csv')
42+
problem.rules.to_csv("output.csv")

0 commit comments

Comments
 (0)