Skip to content

Commit c8128a0

Browse files
Alberto NogalesAlberto Nogales
authored andcommitted
ci: add GitHub Actions, tests, Sphinx docs; fix packaging
- .github/workflows/tests.yml: CI on Python 3.10 & 3.11 (pytest) - .github/workflows/docs.yml: build Sphinx docs → GitHub Pages - tests/test_gema.py: 51 unit tests covering Map, Classification, all normalizations, weight inits, save/load round-trip - docs/: Sphinx + ReadTheDocs config (sphinx_rtd_theme, autodoc) - .readthedocs.yaml: ReadTheDocs v2 build config - setup.py: fix author/url, add extras_require [test]/[docs], python_requires>=3.9 - README.md: replace missing CI badge with GitHub Actions badge
1 parent 5db68ca commit c8128a0

12 files changed

Lines changed: 575 additions & 3 deletions

File tree

.github/workflows/docs.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: pages
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.11"
26+
27+
- name: Install dependencies
28+
run: |
29+
pip install -e .
30+
pip install -r docs/requirements.txt
31+
32+
- name: Build Sphinx docs
33+
run: sphinx-build -b html docs/ docs/_build/html
34+
35+
- name: Upload Pages artifact
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
path: docs/_build/html
39+
40+
deploy:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
steps:
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

.github/workflows/tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: pip install -e ".[test]"
26+
27+
- name: Run tests
28+
run: python -m pytest tests/ -v --tb=short

.readthedocs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.11"
7+
8+
sphinx:
9+
configuration: docs/conf.py
10+
11+
python:
12+
install:
13+
- requirements: docs/requirements.txt
14+
- method: pip
15+
path: .

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# GEMA — Self-Organizing Maps in Python
22

3+
[![Tests](https://github.com/ufvceiec/GEMA/actions/workflows/tests.yml/badge.svg)](https://github.com/ufvceiec/GEMA/actions/workflows/tests.yml)
4+
[![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue.svg)](https://www.python.org/downloads/)
5+
[![PyPI](https://img.shields.io/pypi/v/GEMA?color=blue)](https://pypi.org/project/GEMA/)
6+
[![License](https://img.shields.io/github/license/ufvceiec/GEMA.svg)](LICENSE)
7+
38
**GEMA** (*GEnerador de Mapas Autoasociativos*) is an open-source Python library for building, training, and analysing Self-Organizing Maps (SOMs / Kohonen maps). It covers the full workflow: data normalisation → training → classification → quality metrics → interactive visualisation.
49

510
> **Cite as:**

docs/api.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
API Reference
2+
=============
3+
4+
GEMA.map
5+
--------
6+
7+
.. automodule:: GEMA.map
8+
:members:
9+
:undoc-members:
10+
:show-inheritance:
11+
12+
GEMA.classification
13+
-------------------
14+
15+
.. automodule:: GEMA.classification
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:
19+
20+
GEMA.visualization
21+
------------------
22+
23+
.. automodule:: GEMA.visualization
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:
27+
28+
GEMA.iterativesom
29+
-----------------
30+
31+
.. automodule:: GEMA.iterativesom
32+
:members:
33+
:undoc-members:
34+
:show-inheritance:

docs/conf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
4+
sys.path.insert(0, os.path.abspath(".."))
5+
6+
project = "GEMA"
7+
author = "Alberto Nogales, Álvaro José García-Tejedor"
8+
release = "0.4.3"
9+
version = "0.4.3"
10+
copyright = f"2024, {author}"
11+
12+
extensions = [
13+
"sphinx.ext.autodoc",
14+
"sphinx.ext.napoleon",
15+
"sphinx.ext.viewcode",
16+
]
17+
18+
templates_path = ["_templates"]
19+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
20+
21+
html_theme = "sphinx_rtd_theme"
22+
html_static_path = ["_static"]

docs/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GEMA — Self-Organizing Maps
2+
===========================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
installation
9+
api
10+
11+
Indices and tables
12+
==================
13+
14+
* :ref:`genindex`
15+
* :ref:`modindex`
16+
* :ref:`search`

docs/installation.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Installation
2+
============
3+
4+
Requirements
5+
------------
6+
7+
GEMA requires Python 3.9 or later. All runtime dependencies are listed in
8+
``requirements.txt`` and are installed automatically when you install the
9+
package via pip.
10+
11+
Install from PyPI
12+
-----------------
13+
14+
.. code-block:: bash
15+
16+
pip install GEMA
17+
18+
Install from source
19+
-------------------
20+
21+
.. code-block:: bash
22+
23+
git clone https://github.com/ufvceiec/GEMA.git
24+
cd GEMA
25+
pip install -e .
26+
27+
Running the tests
28+
-----------------
29+
30+
.. code-block:: bash
31+
32+
pip install -e ".[test]"
33+
python -m pytest tests/ -v

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx>=7.0
2+
sphinx-rtd-theme>=1.3
3+
sphinx-autodoc-typehints>=1.24

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
setuptools.setup(
77
name="GEMA",
88
version="0.4.3",
9-
author="UFV CEIEC",
10-
author_email="ceiec.info@ceiec.es",
9+
author="Alberto Nogales, Álvaro José García-Tejedor",
10+
author_email="alberto.nogales@uah.es",
1111
description="A library to build and study Self-Organizing-Maps",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
1414
url="https://github.com/ufvceiec/GEMA",
1515
packages=setuptools.find_packages(),
16-
python_requires=">=3.7",
16+
python_requires=">=3.9",
1717
install_requires=[
1818
"numpy",
1919
"tqdm",
@@ -23,6 +23,9 @@
2323
"scikit-learn",
2424
"scipy",
2525
],
26+
extras_require={
27+
'test': ['pytest>=7.0', 'pytest-cov>=4.0'],
28+
},
2629
classifiers=[
2730
"Programming Language :: Python :: 3",
2831
"Programming Language :: Python :: 3.7",

0 commit comments

Comments
 (0)