Skip to content
Merged
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
47 changes: 22 additions & 25 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
name: Python package
on: [push]
name: Documentation

on: [push, pull_request]

jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
python-version: ['3.10']
# python-version: ['3.10']
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Pandoc
run: |
sudo apt-get install pandoc
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cython
pip install ".[dev]"

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Checkout code
uses: actions/checkout@v7

- name: Set up uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc

- name: Test doc
run: |
make doc
- name: Build documentation
run: |
uv run --extra doc make doc
63 changes: 36 additions & 27 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
name: Python package
on: [push]
name: Lint and Test

on: [push, pull_request]

jobs:
build:
# lint:
# name: Lint with Ruff
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v7

# - name: Set up uv
# uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990
# with:
# enable-cache: true
# python-version: "3.12"

# - name: Lint
# run: |
# uv run --group dev make lint

test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
# python-version: ['3.10']
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cython
pip install ".[dev]"
# pip install cython poetry
# poetry config virtualenvs.create false
# poetry install --no-interaction --with dev
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
make test
- name: Checkout code
uses: actions/checkout@v7

- name: Set up uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Run tests
run: |
uv run --extra test make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,5 @@ generated_datasets/*
!generated_datasets/71GPa_experimental_data.hspy
results
.DS_Store
espm/_version.py

10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.20
hooks:
# Run the linter.
- id: ruff-check
args: [ --fix, --exit-zero ]
# Run the formatter.
- id: ruff-format
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ python:
- method: pip
path: .
extra_requirements:
- dev
- doc
22 changes: 9 additions & 13 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ development with the following::
$ pip install -e .[dev]

You can improve or add functionality in the ``espm`` folder, along with
corresponding unit tests in ``espm/tests/test_*.py`` (with reasonable
coverage).
corresponding unit tests in ``tests/test_*.py`` (with reasonable coverage).
If you have a nice example to demonstrate the use of the introduced
functionality, please consider adding a notebook in ``doc/introduction/notebooks``.
In general, this can be done as a relative symbolic link to a notebook in the
Expand All @@ -35,8 +34,8 @@ documentation with the following ::
To iterate faster, you can partially run the test suite, at various degrees of
granularity, as follows::

$ pytest espm.test.test_utils.py
$ pytest espm.test.test_estimators.py
$ pytest tests/test_utils.py
$ pytest tests/test_estimators.py

Making a release
----------------
Expand All @@ -45,8 +44,7 @@ Making a release
#. Log to `readthedoc <https://readthedocs.org/projects/espm>`,
launch a build on latest and check that it can compile
the latest version of the documentation.
#. Update the version number and release date in ``setup.py``,
``espm/__init__.py`` and ``CHANGELOG.rst``.
#. Update the release notes and release date in ``CHANGELOG.rst``.
#. Commit the changes with ``git commit -am "Bump to version 0.2.0"``.
#. Create a git tag with ``git tag -a v0.2.0 -m "espm v0.2.0"``.
#. Push the tag to GitHub with ``git push --tag``. The tag should now
Expand All @@ -72,22 +70,20 @@ Repository organization
LICENSE.txt Project license
*.rst Important documentation
Makefile Targets for make
setup.py Meta information about package (published on PyPI)
pyproject.toml Meta information about package, dependencies and tools (Ruff, pytest)
.gitignore Files ignored by the git revision control system
.travis.yml Defines testing on Travis continuous integration

espm/ Contains the modules (the actual toolbox implementation)
espm/ Contains the modules (the actual toolbox implementation)
__init.py__ Load modules at package import
*.py One file per module
espm/tables/ Contains data tables for the EDXS and EDSS models
espm/tables/ Contains data tables for the EDXS and EDSS models
__init.py__ Load modules at package import
*.json data_files for the package
*.txt data_files for the package

espm/tests/ Contains the test suites (will be distributed to end user)
__init.py__ Load modules at package import
tests/ Contains the test suites (not distributed to end user)
test_*.py One test suite per module
test_docstrings.py Test the examples in the docstrings (reference doc)
test_docstring.py Test the examples in the docstrings (reference doc)

doc/ Package documentation
conf.py Sphinx configuration
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ help:
@echo "release package and upload to PyPI"

clean:
git clean -Xdf
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ .ruff_cache/ doc/_build/
jupyter nbconvert --inplace --ClearOutputPreprocessor.enabled=True $(NB)

lint:
flake8 --doctests --exclude=doc
ruff check

# Matplotlib doesn't print to screen. Also faster.
export MPLBACKEND = agg
# Virtual framebuffer nonetheless needed for the pyqtgraph backend.
export DISPLAY = :99

test:
pytest espm
pytest

clean-doc:
rm -rf doc/_build
Expand All @@ -32,8 +32,7 @@ doc:
sphinx-build -b linkcheck -d doc/_build/doctrees doc doc/_build/linkcheck

dist: clean
python setup.py sdist
python setup.py bdist_wheel --universal
python -m build
ls -lh dist/*
twine check dist/*

Expand Down
35 changes: 17 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ If you want to develop, please use the option::

$ git clone https://github.com/adriente/espm.git
$ cd espm
$ pip install cython
$ pip install -e .[dev]
$ pip install -e .[dev]

If you get issues regarding pandoc when using `make doc`, you can install it using::

Expand Down Expand Up @@ -73,23 +72,23 @@ CITING
If you use this library, please cite on of the following papers::

@article{teurtrie2023espm,
title={espm: A Python library for the simulation of STEM-EDXS datasets},
author={Teurtrie, Adrien and Perraudin, Nathana{\"e}l and Holvoet, Thomas and Chen, Hui and Alexander, Duncan TL and Obozinski, Guillaume and H{\'e}bert, C{\'e}cile},
journal={Ultramicroscopy},
pages={113719},
year={2023},
publisher={Elsevier}
title={espm: A Python library for the simulation of STEM-EDXS datasets},
author={Teurtrie, Adrien and Perraudin, Nathana{\"e}l and Holvoet, Thomas and Chen, Hui and Alexander, Duncan TL and Obozinski, Guillaume and H{\'e}bert, C{\'e}cile},
journal={Ultramicroscopy},
pages={113719},
year={2023},
publisher={Elsevier}
}

@article{Teurtrie_2024,
doi = {10.1088/2632-2153/ad9192},
year = {2024},
month = {nov},
publisher = {IOP Publishing},
volume = {5},
number = {4},
pages = {045050},
author = {Teurtrie, Adrien and Perraudin, Nathanaël and Holvoet, Thomas and Chen, Hui and Alexander, Duncan T L and Obozinski, Guillaume and Hébert, Cécile},
title = {From STEM-EDXS data to phase separation and quantification using physics-guided NMF},
journal = {Machine Learning: Science and Technology}
doi = {10.1088/2632-2153/ad9192},
year = {2024},
month = {nov},
publisher = {IOP Publishing},
volume = {5},
number = {4},
pages = {045050},
author = {Teurtrie, Adrien and Perraudin, Nathanaël and Holvoet, Thomas and Chen, Hui and Alexander, Duncan T L and Obozinski, Guillaume and Hébert, Cécile},
title = {From STEM-EDXS data to phase separation and quantification using physics-guided NMF},
journal = {Machine Learning: Science and Technology}
}
Loading
Loading