Skip to content

Commit

Permalink
Merge branch 'master' into performance-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MarJMue committed Jan 4, 2025
2 parents a17c087 + 18a57d2 commit da5f3a3
Show file tree
Hide file tree
Showing 37 changed files with 3,124 additions and 2,049 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install deps
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.13"
- name: Install deps
run: |
pip install sphinx-lint ruff==0.4.8
pip install sphinx-lint ruff==0.8.5
- name: ruff
run: |
ruff check src/elli tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
103 changes: 78 additions & 25 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish 📦

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]
on: push

jobs:
deploy:

build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
Expand All @@ -24,15 +14,78 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish to PyPi
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyElli/
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.8
rev: v0.8.5
hooks:
# Run the linter.
- id: ruff
Expand Down
3 changes: 3 additions & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dispersions
dataframes
ellipsometry
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## Version 0.21.2

### Bugfixes
- Include the RII database submodule in the Pypi package again

## Version 0.21.1

### Bugfixes
- Fix documentation generation

## Version 0.21.0

### New
- Reenable pytorch 4x4solver
- Use OIDC for publishing
- Add custom fitting example
- Add chardet encoding detection
- Add reader for accurion data

### Bugfixes
- Fix deprecation warnings


## Version 0.20.0

### New
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ pip install pyElli[fitting]
```

This installs pyElli with the additional fitting capabilities and interactive widgets.
If don't want to have this functionality just drop the `[fitting]` in the end.
If you don't want to have this functionality just drop the `[fitting]` in the end.

To increase performance of the 4x4 Solver, it is recommended to
install PyTorch manually, as it is too big to include in the standard installation.
Installation information can be found at the [PyTorch Website](https://pytorch.org/get-started/locally/).
The CPU variant is sufficient, if you want to save some space.

A complete environment for pyElli is also available as a [Docker Container](https://hub.docker.com/r/domna/pyelli).
To pull and run it directly just execute
Expand Down Expand Up @@ -68,10 +73,15 @@ cd pyElli
pip install -e ".[fitting]"
```

## How to cite

Until we have published a Paper on pyElli, we have prepared a Zenodo entry with DOIs for every pyElli Version. The can be found [here](https://zenodo.org/records/13903325).


## Acknowledgements

- Based on Olivier Castany's [Berreman4x4](https://github.com/Berreman4x4/Berreman4x4)
- Solver2x2 based on Steve Byrnes' [tmm](https://github.com/sbyrnes321/tmm)
- Mikhail Polyanskiy's [refractiveindex.info database](https://github.com/polyanskiy/refractiveindex.info-database) and Pavel Dmitriev's [pyTMM](https://github.com/kitchenknif/PyTMM) for his importer script for the database

[@MarJMue](https://github.com/MarJMue) recieves financial support by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation), grant No. 398143140 (FOR 2824).
[@MarJMue](https://github.com/MarJMue) receives financial support by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation), grant No. 398143140 (FOR 2824).
Binary file added docs/_static/custom_fitting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"sphinx.ext.napoleon",
"sphinx_plotly_directive",
"sphinx_rtd_theme",
"m2r2",
"sphinx_mdinclude",
"sphinx_gallery.gen_gallery",
"sphinxcontrib.mermaid",
]
Expand Down
4 changes: 2 additions & 2 deletions docs/dispersions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ DispersionSum
This object can be used to add an arbitrary number of dispersions.
The overloaded `+` operator of the dispersion base class creates an instance
of this object with two classes as parameters.
If you want to chain a lot of dispersions it may be more performant to use
If you want to chain a lot of dispersions, it may be more performant to use
this class directly.

.. autoclass:: elli.dispersions.base_dispersion.DispersionSum
Expand All @@ -274,6 +274,6 @@ this class directly.

InvalidParameters
-----------------
This exception is thrown whenever a dispersions got invalid parameters.
This exception is thrown whenever a dispersion got invalid parameters.

.. autoexception:: elli.dispersions.base_dispersion.InvalidParameters
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ However, pyElli comes with batteries included and already offers a wide range
of :doc:`dispersion models<dispersions>` and the material database of Refractiveindex.info.

Most of the models presented in the
comprehensive book of Fujiwara and Colllins [1]_ are present and additionally
a lot of other models used by ellipsometry vendor softwares are included.
comprehensive book of Fujiwara and Collins [1]_ are present and additionally
a lot of other models used by ellipsometry vendor software are included.

The material database offers the dispersions seen on the `website <https://refractiveindex.info/>`_
and can be accessed by using the :class:`elli.db.RII<elli.db.RII>` module.
Expand Down Expand Up @@ -54,7 +54,7 @@ but can contain arbitrary more :class:`layers<elli.structure.Layer>` which are o
The :class:`VaryingMixtureLayer<elli.structure.VaryingMixtureLayer>` class can also account for gradient changes of materials in z-direction
of a layer, which is useful for gradient layers or roughness modeling.
As the last step the :class:`Structure<elli.structure.Structure>` is plugged into an :class:`Experiment<elli.experiment.Experiment>`, which contains
the experimental conditions, such as light polarizations.
the experimental conditions, such as light polarization.
By evaluating the experiment a :class:`Result<elli.result.Result>` class containing the calculated data is returned.
The creation of an experiment can be skipped by calling the :meth:`evaluate<elli.structure.Structure.evaluate>` method directly
on a :class:`Structure<elli.structure.Structure>` class if you want to use standard experimental settings.
Expand Down
10 changes: 9 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ To install the package in your current virtual environment execute

.. code-block:: shell
pip install pyElli
pip install pyElli[fitting]
This installs pyElli with the additional fitting capabilities and interactive widgets.
If you don't want to have this functionality just drop the `[fitting]` in the end.

To increase performance of the 4x4 Solver, it is recommended to
install PyTorch manually, as it is too big to include in the standard installation.
Installation information can be found at the `PyTorch Website <https://pytorch.org/get-started/locally/>`_.
The CPU variant is sufficient, if you want to save some space.

A complete environment for pyElli is also available as a
`Docker Container <https://hub.docker.com/r/domna/pyelli>`_.
Expand Down
4 changes: 2 additions & 2 deletions docs/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Interactive fitting
PyElli offers several classes and decorators to make fitting easy.
The central idea is to construct a class containing the measurement data and an optical model
which is fitted to the data with `lmfit <https://lmfit.github.io/lmfit-py/index.html>`_.
Since pyElli uses lmfit under the hood you may take advantage of it's vast capabilities.
Since pyElli uses lmfit under the hood you may take advantage of its vast capabilities.

To make creation of the fitting classes as easy as possible pyElli contains decorators to
automatically instantiate the class by providing a function containing the optical model.
Expand Down Expand Up @@ -56,7 +56,7 @@ be inherited from in additional fitting classes.

Parameter class
---------------
The parameter class extending lmfits Parameter class by a history
The parameter class extending lmfit's Parameter class by a history
of parameter changes.

.. automodule:: elli.fitting.params_hist
Expand Down
9 changes: 4 additions & 5 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# under `install_requires` in `setup.cfg` is also listed here!
sphinx!=5.1.0
sphinx_rtd_theme
m2r2
sphinx-mdinclude
myst_parser
scipy
numpy>=1.20
Expand All @@ -14,13 +14,12 @@ ipython
ipywidgets
sphinx-gallery
sphinx-plotly-directive
sphinxcontrib-mermaid
sphinxcontrib-mermaid
matplotlib
h5py
importlib-resources
h5py
pyyaml
importlib-resources
rapidfuzz
lark>=1.1.5
pint
pint
chardet
1 change: 1 addition & 0 deletions docs/solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pyElli provides different implementations to be used in the calculation of the t
The :class:`PropagatorEig<elli.solver4x4.PropagatorEig>` is based on solving the eigenvalues of the first order approximation of the matrix exponential.
Although, it is very fast it is not very accurate.
The :class:`PropagatorExpm<elli.solver4x4.PropagatorExpm>` is solving the matrix exponential by the Pade approximation.
It can use SciPy as backend, but for performance-critical tasks, it is recommended to install PyTorch.

.. rubric:: References

Expand Down
6 changes: 3 additions & 3 deletions examples/Basic Usage/Basic Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"## Building the model\n",
"\n",
"For simple parameter estimation,\n",
"the fit decorator (**@fit**) in conjuction with the model definition is used.\n",
"the fit decorator (**@fit**) in conjunction with the model definition is used.\n",
"The fitting decorator takes a pandas dataframe containing\n",
"the psi/delta measurement data (**psi_delta**) and the model parameters (**params**) as an input.\n",
"It then passes the wavelength from measurement dataframe (**lbda**)\n",
Expand All @@ -204,7 +204,7 @@
"This is done by calling the :code:`elli.IsotropicMaterial(...)` function\n",
"with a dispersion model as a parameter\n",
"or simply calling :code:`.get_mat()` on a dispersion model.\n",
"These two approaches are equivalent.From these materials the layer is build,\n",
"These two approaches are equivalent. From these materials the layer is build,\n",
"which only consists of the SiO2 layer in this example.\n",
"The final structure consists of an incoming half-space,\n",
"the layers and an outgoing half space. Specifically,\n",
Expand All @@ -223,7 +223,7 @@
"Executing the cell below in a jupyter notebook displays a comparison of the simulated Ψ / Δ values\n",
"at the current parameter values with their measured counterparts.\n",
"Additionally, input fields for each model parameter are shown.\n",
"You may change the parameters and the calcualted data will change accordingly.\n",
"You may change the parameters and the calculated data will change accordingly.\n",
"For clarification the modeled data is shown with `_calc` postfix in the legend.\n",
"\n"
]
Expand Down
Loading

0 comments on commit da5f3a3

Please sign in to comment.