From c562fa6b60d97239743b944a5751f529facdb091 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 12:58:47 +1000 Subject: [PATCH 1/7] MAINT: various --- .github/workflows/release.yml | 99 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 8 +-- pyproject.toml | 6 ++- refellips/reflect_modelSE.py | 32 +++++++---- refellips/structureSE.py | 2 +- 5 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f8fee49 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +# This action releases refnx on PyPI for every version tagged commit (e.g. v0.0.1) +name: PyPI/Github Release + +on: + push: + tags: + - "v*" + +jobs: + make_sdist: + name: Make sdist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: wheels-sdist + path: dist/*.tar.gz + + + check-version: + runs-on: ubuntu-latest + needs: [make_sdist] + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: 3.11 + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + pattern: wheels-* + merge-multiple: true + path: dist + - name: Check version + run: | + python -m pip install numpy scipy orsopy + ls dist + python -m pip install --only-binary=refnx --no-index --find-links=dist refnx + cd dist + RNX_VERSION="$(python -c "import refnx;print(refnx.version.release)")" + cd .. + if [ $RNX_VERSION == "True" ]; then + echo "It's a release version of refellips" + else + echo "This is not a release version of refellips" + exit 1 + fi + + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + needs: [check-version] + environment: + name: pypi + url: https://pypi.org/p/refellips + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + steps: + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + pattern: wheels-* + merge-multiple: true + path: dist + + - name: Upload to PyPI + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 + with: + # repository-url: https://test.pypi.org/legacy/ + skip_existing: true + + + release-github: + runs-on: ubuntu-latest + needs: [ pypi-publish ] + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + pattern: wheels-* + merge-multiple: true + path: dist + + - uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0 + with: + artifacts: "dist/refellips*.tar.gz" + token: ${{ secrets.GITHUB_TOKEN }} + allowUpdates: true + generateReleaseNotes: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a411b09..87173f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 3 matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.11", "3.11", "3.13"] steps: - uses: actions/checkout@v4 @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11"] + python-version: ["3.12"] steps: - uses: actions/checkout@v4 @@ -66,7 +66,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: ["3.10"] + python-version: ["3.13"] steps: - uses: actions/checkout@v4 @@ -95,7 +95,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: ["3.11"] + python-version: ["3.13"] steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 5c74142..7f7d2bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,8 @@ [project] requires-python = ">=3.9" name = "refellips" -dynamic=["version", "description", "readme", "license", "classifiers", "urls", "authors"] \ No newline at end of file +dynamic=["version", "description", "readme", "license", "classifiers", "urls", "authors"] + +[tool.black] +line-length = 79 +extend-exclude="refnx/_lib/emcee/|refnx/_lib/ptemcee/|benchmarks" diff --git a/refellips/reflect_modelSE.py b/refellips/reflect_modelSE.py index 2d2396b..cb1593f 100644 --- a/refellips/reflect_modelSE.py +++ b/refellips/reflect_modelSE.py @@ -238,16 +238,26 @@ def Delta_Psi_TMM(AOI, layers, wavelength, delta_offset, reflect_delta=False): Wavelength of light. Units = nm layers: np.ndarray coefficients required for the calculation, has shape (2 + N, 4), - where N is the number of layers - layers[0, 1] - refractive index of fronting - layers[0, 2] - extinction coefficent of fronting - layers[N, 0] - thickness of layer N - layers[N, 1] - refractive index of layer N - layers[N, 2] - extinction coefficent of layer N - layers[N, 3] - roughness between layer N-1/N (IGNORED!) - layers[-1, 1] - refractive index of backing - layers[-1, 2] - extinction coefficent of backing - layers[-1, 3] - roughness between backing and last layer (IGNORED!) + where N is the number of layers. + + - layers[0, 1] + refractive index of fronting + - layers[0, 2] + extinction coefficent of fronting + - layers[N, 0] + thickness of layer N + - layers[N, 1] + refractive index of layer N + - layers[N, 2] + extinction coefficent of layer N + - layers[N, 3] + roughness between layer N-1/N (IGNORED!) + - layers[-1, 1] + refractive index of backing + - layers[-1, 2] + extinction coefficent of backing + - layers[-1, 3] + roughness between backing and last layer (IGNORED!) Returns ------- @@ -288,7 +298,7 @@ class ReflectModelSE: r""" Parameters ---------- - structure : refnx.reflect.Structure + structure : refellips.StructureSE The interfacial structure. name : str, optional Name of the Model diff --git a/refellips/structureSE.py b/refellips/structureSE.py index 25c69fc..407b914 100644 --- a/refellips/structureSE.py +++ b/refellips/structureSE.py @@ -268,7 +268,7 @@ def parameters(self): def slabs(self, structure=None): """ - Slab representation of this component. See :class:`Component.slabs` + Slab representation of this component. See :class:`ComponentSE.slabs` """ # speculative shortcut to prevent a number of attribute retrievals if self.ri.dispersive: From c594e3ee770789ccb5b98ba22b1437dc23f0d3e0 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:01:45 +1000 Subject: [PATCH 2/7] MAINT: various --- .github/workflows/release.yml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8fee49..c39b366 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,42 +22,10 @@ jobs: path: dist/*.tar.gz - check-version: - runs-on: ubuntu-latest - needs: [make_sdist] - - steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - - name: Set up Python - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - with: - python-version: 3.11 - - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 - with: - pattern: wheels-* - merge-multiple: true - path: dist - - name: Check version - run: | - python -m pip install numpy scipy orsopy - ls dist - python -m pip install --only-binary=refnx --no-index --find-links=dist refnx - cd dist - RNX_VERSION="$(python -c "import refnx;print(refnx.version.release)")" - cd .. - if [ $RNX_VERSION == "True" ]; then - echo "It's a release version of refellips" - else - echo "This is not a release version of refellips" - exit 1 - fi - - pypi-publish: name: Upload release to PyPI runs-on: ubuntu-latest - needs: [check-version] + needs: [ make_sdist ] environment: name: pypi url: https://pypi.org/p/refellips From 1c3df0377a2c974f249424427bb8a186b6b25a0c Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:07:32 +1000 Subject: [PATCH 3/7] MAINT: fix artefact upload --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87173f8..daf4808 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,8 @@ jobs: - uses: actions/upload-artifact@v4 with: + if: github.repository == 'refnx/refellips' && matrix.python-version == "3.13" + name: refellips-linux-${{ matrix.python-version }} path: dist/ From 4cc29925769f66ccb689d11e5ffb42824a32646a Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:08:01 +1000 Subject: [PATCH 4/7] MAINT: fix artefact upload --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index daf4808..b4c7c2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 3 matrix: - python-version: ["3.11", "3.11", "3.13"] + python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 @@ -36,7 +36,6 @@ jobs: - uses: actions/upload-artifact@v4 with: if: github.repository == 'refnx/refellips' && matrix.python-version == "3.13" - name: refellips-linux-${{ matrix.python-version }} path: dist/ From fca9bc9ad2ae11d6a1a226f2a3a9eedd81a68490 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:12:32 +1000 Subject: [PATCH 5/7] MAINT: fix artefact upload --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4c7c2a..f8345bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,8 +34,8 @@ jobs: popd - uses: actions/upload-artifact@v4 + if: github.repository == 'refnx/refellips' && matrix.python-version == "3.13" with: - if: github.repository == 'refnx/refellips' && matrix.python-version == "3.13" name: refellips-linux-${{ matrix.python-version }} path: dist/ From 2a08ab414057ae09b1a24facbb4d2ec685b37a8b Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:14:31 +1000 Subject: [PATCH 6/7] MAINT: fix artefact upload --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 42106e5..caba7bc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,3 +16,4 @@ First release on PyPI 0.0.6 ----- +- added circular_difference to calculate shortest difference between two angles. From 85c220f777a9ff1b461ce78a4526b29a938256a7 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Sat, 27 Sep 2025 13:49:06 +1000 Subject: [PATCH 7/7] MAINT: fix artefact upload --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8345bc..ccf6413 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,6 @@ jobs: popd - uses: actions/upload-artifact@v4 - if: github.repository == 'refnx/refellips' && matrix.python-version == "3.13" with: name: refellips-linux-${{ matrix.python-version }} path: dist/