From 6170de15474efae973c96118651a63ae8e1618ea Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 09:56:40 +0200 Subject: [PATCH 01/19] check the newest sphinx --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a0c79ff5..5049ce21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dev = [ docs = [ "myst_parser", "nbsphinx", - "sphinx==8.1.3", + "sphinx", "sphinx_autodoc_typehints", "sphinx_book_theme", "sphinx-copybutton", From 3781112b4006b1bc30b72fb7f5ee75d39c00bd24 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 13:18:28 +0200 Subject: [PATCH 02/19] try lines from doc_fix --- .github/workflows/documentation-build.yml | 3 +-- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 5a741554..05fce59d 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -41,11 +41,10 @@ jobs: pip install sphinx==8.1.3 pip install . '.[dev,docs]' - name: Build and Commit - uses: sphinx-notes/pages@master + uses: sphinx-notes/pages@v3 with: install_requirements: false sphinx_version: 8.1.3 - documentation_path: docs/src - name: Push changes uses: ad-m/github-push-action@master continue-on-error: true diff --git a/pyproject.toml b/pyproject.toml index 5049ce21..f99044f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dev = [ docs = [ "myst_parser", "nbsphinx", - "sphinx", + "sphinx<=8.1.3", "sphinx_autodoc_typehints", "sphinx_book_theme", "sphinx-copybutton", From 5fb61fde09b8d89db4e4aeefccd30c9f5b5d971c Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 13:31:24 +0200 Subject: [PATCH 03/19] no cairo on new runners. Switch to 2022. --- .github/workflows/ossar-analysis.yml | 2 +- .github/workflows/python-ci.yml | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml index 1b941b7a..a2c77306 100644 --- a/.github/workflows/ossar-analysis.yml +++ b/.github/workflows/ossar-analysis.yml @@ -13,7 +13,7 @@ jobs: OSSAR-Scan: # OSSAR runs on windows-latest. # ubuntu-latest and macos-latest support coming soon - runs-on: windows-latest + runs-on: windows-2022 steps: # Checkout your code repository to scan diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index e263bcbb..2f34eb2a 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -31,7 +31,7 @@ jobs: max-parallel: 4 matrix: python-version: ['3.11', '3.12'] - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest, windows-2022] runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, '[ci skip]')" diff --git a/pyproject.toml b/pyproject.toml index f99044f8..18bd9685 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,7 +142,7 @@ python = PLATFORM = ubuntu-latest: linux macos-latest: macos - windows-latest: windows + windows-latest: 2022 [testenv] passenv = CI From a5a15245d05a761f3d0e63f42fa975453baf341f Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 13:43:25 +0200 Subject: [PATCH 04/19] install cairo --- .github/workflows/documentation-build.yml | 3 ++- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 05fce59d..588eff57 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -34,10 +34,11 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 - name: Install Pandoc, repo and dependencies run: | sudo apt install pandoc + sudo apt install libcairo2-dev pip install sphinx==8.1.3 pip install . '.[dev,docs]' - name: Build and Commit diff --git a/pyproject.toml b/pyproject.toml index 18bd9685..4b2159e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,7 @@ dev = [ docs = [ "myst_parser", + "pycairo", "nbsphinx", "sphinx<=8.1.3", "sphinx_autodoc_typehints", From d10b53239e79b62a54c3ce13d85a594b2711f537 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 14:35:00 +0200 Subject: [PATCH 05/19] specify right path --- .github/workflows/documentation-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 588eff57..bcf22fe2 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -46,6 +46,7 @@ jobs: with: install_requirements: false sphinx_version: 8.1.3 + documentation_path: docs/src - name: Push changes uses: ad-m/github-push-action@master continue-on-error: true From 2d7ff15e3de38c10d48cc10a39b1c077b8f47ad0 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 25 Sep 2025 15:03:33 +0200 Subject: [PATCH 06/19] install correct env --- .github/workflows/documentation-build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index bcf22fe2..faaff2bd 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -41,10 +41,14 @@ jobs: sudo apt install libcairo2-dev pip install sphinx==8.1.3 pip install . '.[dev,docs]' + + - name: Install Jupyter kernel + run: | + python -m ipykernel install --user --name=python3 + - name: Build and Commit uses: sphinx-notes/pages@v3 with: - install_requirements: false sphinx_version: 8.1.3 documentation_path: docs/src - name: Push changes From 3a233b2a4dfdf1ac0eb7e345a2d5576cf96108e3 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Fri, 26 Sep 2025 09:17:06 +0200 Subject: [PATCH 07/19] fixed notebooks --- .../advancedfitting/multi_contrast.ipynb | 18 ++++++------------ docs/src/tutorials/fitting/monolayer.ipynb | 4 ++-- docs/src/tutorials/fitting/repeating.ipynb | 4 ++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/docs/src/tutorials/advancedfitting/multi_contrast.ipynb b/docs/src/tutorials/advancedfitting/multi_contrast.ipynb index 2c812091..51e4e225 100644 --- a/docs/src/tutorials/advancedfitting/multi_contrast.ipynb +++ b/docs/src/tutorials/advancedfitting/multi_contrast.ipynb @@ -251,7 +251,7 @@ ")\n", "d13d2o.constrain_area_per_molecule = True\n", "d13d2o.conformal_roughness = True\n", - "d13d2o.constrain_solvent_roughness(d2o_layer)" + "d13d2o.constrain_solvent_roughness(d2o_layer.roughness)" ] }, { @@ -291,7 +291,7 @@ ")\n", "d70d2o.constrain_area_per_molecule = True\n", "d70d2o.conformal_roughness = True\n", - "d70d2o.constrain_solvent_roughness(d2o_layer)" + "d70d2o.constrain_solvent_roughness(d2o_layer.roughness)" ] }, { @@ -331,7 +331,7 @@ ")\n", "d83acmw.constrain_area_per_molecule = True\n", "d83acmw.conformal_roughness = True\n", - "d83acmw.constrain_solvent_roughness(acmw_layer)" + "d83acmw.constrain_solvent_roughness(acmw_layer.roughness)" ] }, { @@ -341,8 +341,8 @@ "source": [ "## Introducing constraints\n", "\n", - "Then to ensure that the structure (thicknesss, area per molecule, etc.) is kept the same between the different contrasts we constain these (`layer2` is the head layer and `layer1`, which the neutron are incident on first are the tail layer). \n", - "The `constrain_multiple_contrast` method allows this, not that is it important that a chain of constraints is produced, one constraining the next. " + "To ensure that the structure (thicknesss, area per molecule, etc.) is kept the same between the different contrasts we constrain these (`layer2` is the head layer and `layer1`, which the neutron are incident on first are the tail layer). \n", + "The `constrain_multiple_contrast` method allows this, note that it is important that a chain of constraints is produced, one constraining the next. " ] }, { @@ -352,12 +352,6 @@ "metadata": {}, "outputs": [], "source": [ - "# These four lines should be removed in future\n", - "d70d2o.head_layer.area_per_molecule_parameter.enabled = True\n", - "d70d2o.tail_layer.area_per_molecule_parameter.enabled = True\n", - "d83acmw.head_layer.area_per_molecule_parameter.enabled = True\n", - "d83acmw.tail_layer.area_per_molecule_parameter.enabled = True\n", - "\n", "d70d2o.constrain_multiple_contrast(d13d2o)\n", "d83acmw.constrain_multiple_contrast(d70d2o)" ] @@ -571,7 +565,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.9" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/docs/src/tutorials/fitting/monolayer.ipynb b/docs/src/tutorials/fitting/monolayer.ipynb index cc521620..d0ef8aa0 100644 --- a/docs/src/tutorials/fitting/monolayer.ipynb +++ b/docs/src/tutorials/fitting/monolayer.ipynb @@ -382,7 +382,7 @@ "calculator = CalculatorFactory()\n", "model.interface = calculator\n", "fitter = MultiFitter(model)\n", - "fitter.switch_minimizer(AvailableMinimizers.LMFit_differential_evolution)\n", + "# fitter.switch_minimizer(AvailableMinimizers.LMFit_differential_evolution)\n", "analysed = fitter.fit(data)" ] }, @@ -487,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.9" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/docs/src/tutorials/fitting/repeating.ipynb b/docs/src/tutorials/fitting/repeating.ipynb index dd093c68..0ebde2e1 100644 --- a/docs/src/tutorials/fitting/repeating.ipynb +++ b/docs/src/tutorials/fitting/repeating.ipynb @@ -274,7 +274,7 @@ "outputs": [], "source": [ "fitter = MultiFitter(model)\n", - "fitter.switch_minimizer(AvailableMinimizers.LMFit_differential_evolution)\n", + "# fitter.switch_minimizer(AvailableMinimizers.LMFit_differential_evolution)\n", "analysed = fitter.fit(data)\n", "analysed" ] @@ -341,7 +341,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.9" + "version": "3.12.11" } }, "nbformat": 4, From d52794fc1661c3eb5d6c361273f4a57f4700587f Mon Sep 17 00:00:00 2001 From: rozyczko Date: Fri, 26 Sep 2025 12:28:03 +0200 Subject: [PATCH 08/19] fixed magnetism --- docs/src/tutorials/simulation/magnetism.ipynb | 72 +++++++++---------- .../calculators/refl1d/wrapper.py | 24 +++++-- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/docs/src/tutorials/simulation/magnetism.ipynb b/docs/src/tutorials/simulation/magnetism.ipynb index 82834ee2..0002733f 100644 --- a/docs/src/tutorials/simulation/magnetism.ipynb +++ b/docs/src/tutorials/simulation/magnetism.ipynb @@ -43,7 +43,8 @@ "from easyreflectometry.sample import Layer\n", "from easyreflectometry.sample import Material\n", "from easyreflectometry.sample import Multilayer\n", - "from easyreflectometry.sample import Sample" + "from easyreflectometry.sample import Sample\n", + "from easyreflectometry.calculators.refl1d.wrapper import _get_polarized_probe" ] }, { @@ -331,15 +332,17 @@ " refl1d_sld_4(100, 0, magnetism=refl1d.names.Magnetism(rhoM=10, thetaM=70)) | \n", " refl1d_vacuum(0, 0)\n", ") \n", - "probe = refl1d.names.QProbe(\n", - " Q=model_coords,\n", - " dQ=np.zeros(len(model_coords)),\n", - " intensity=1,\n", - " background=0,\n", - " )\n", + "model_name = model.unique_name\n", + "storage = {'model': {model_name: {}}}\n", + "storage['model'][model_name]['scale'] = 10.0\n", + "storage['model'][model_name]['bkg'] = 20.0\n", + "\n", + "polarized_probe = _get_polarized_probe(\n", + " q_array=model_coords,\n", + " dq_array=np.zeros(len(model_coords)),\n", + " model_name=model_name,\n", + " storage=storage)\n", "\n", - "four_probes = [probe, None, None, None]\n", - "polarized_probe = refl1d.names.PolarizedQProbe(xs=four_probes, name='polarized')\n", "experiment = refl1d.names.Experiment(probe=polarized_probe, sample=refl1d_sample)\n", "model_data_magnetism_ref1d = experiment.reflectivity()[0][1]\n", "plt.plot(model_coords, model_data_magnetism_ref1d, '-k', label='Refl1d', linewidth=4)\n", @@ -413,34 +416,27 @@ " refl1d_vacuum(0, 0)\n", ") \n", "\n", - "probe_pp = refl1d.names.QProbe(\n", - " Q=model_coords,\n", - " dQ=np.zeros(len(model_coords)),\n", - " intensity=1,\n", - " background=0,\n", - " )\n", - "probe_pm = refl1d.names.QProbe(\n", - " Q=model_coords,\n", - " dQ=np.zeros(len(model_coords)),\n", - " intensity=1,\n", - " background=0,\n", - " )\n", - "probe_mp = refl1d.names.QProbe(\n", - " Q=model_coords,\n", - " dQ=np.zeros(len(model_coords)),\n", - " intensity=1,\n", - " background=0,\n", - " )\n", - "probe_mm = refl1d.names.QProbe(\n", - " Q=model_coords,\n", - " dQ=np.zeros(len(model_coords)),\n", - " intensity=1,\n", - " background=0,\n", - " )\n", + "model_name = model.unique_name\n", + "storage = {'model': {model_name: {}}}\n", + "storage['model'][model_name]['scale'] = 10.0\n", + "storage['model'][model_name]['bkg'] = 20.0\n", "\n", - "four_probes = [probe_pp, probe_pm, probe_mp, probe_mm]\n", - "polarized_probe = refl1d.names.PolarizedQProbe(xs=four_probes, name='polarized')\n", - "experiment = refl1d.names.Experiment(probe=polarized_probe, sample=refl1d_sample)\n", + "polarized_probe = _get_polarized_probe(\n", + " q_array=model_coords,\n", + " dq_array=np.zeros(len(model_coords)),\n", + " model_name=model_name,\n", + " storage=storage)\n", + "\n", + "experiment = refl1d.names.Experiment(probe=polarized_probe, sample=refl1d_sample)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "239e2a04", + "metadata": {}, + "outputs": [], + "source": [ "model_data_magnetism_ref1d_raw_pp = experiment.reflectivity()[0][1]\n", "model_data_magnetism_ref1d_raw_pm = experiment.reflectivity()[1][1]\n", "model_data_magnetism_ref1d_raw_mp = experiment.reflectivity()[2][1]\n", @@ -555,7 +551,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv2", + "display_name": "p312", "language": "python", "name": "python3" }, @@ -569,7 +565,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index e47cf052..7acc4e83 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -185,12 +185,12 @@ def calculate(self, q_array: np.ndarray, model_name: str) -> np.ndarray: if ALL_POLARIZATIONS: raise NotImplementedError('Polarized reflectivity not yet implemented') # returns q, reflectivity - # _, reflectivity_pp = polarized_reflectivity[0] - # _, reflectivity_pm = polarized_reflectivity[1] - # _, reflectivity_mp = polarized_reflectivity[2] - # _, reflectivity_mm = polarized_reflectivity[3] + # _, reflectivity_mm = polarized_reflectivity[0] + # _, reflectivity_mp = polarized_reflectivity[1] + # _, reflectivity_pm = polarized_reflectivity[2] + # _, reflectivity_pp = polarized_reflectivity[3] else: - # Only pick the pp reflectivity + # Only pick the mm reflectivity (first component) # returns q, reflectivity _, reflectivity = polarized_reflectivity[0] @@ -260,7 +260,8 @@ def _get_polarized_probe( ) -> names.PolarizedNeutronQProbe: four_probes = [] for i in range(4): - if i == 0 or all_polarizations: + if all_polarizations: + # Create probe for all polarizations: mm, mp, pm, pp probe = _get_probe( q_array=q_array, dq_array=dq_array, @@ -270,7 +271,16 @@ def _get_polarized_probe( magnetism=True, # Enable magnetism for polarized probes ) else: - probe = None + # When all_polarizations=False, create all probes but only compute what's needed + # This ensures the PolarizedNeutronProbe is properly initialized + probe = _get_probe( + q_array=q_array, + dq_array=dq_array, + model_name=model_name, + storage=storage, + oversampling_factor=oversampling_factor, + magnetism=True, # Enable magnetism for polarized probes + ) four_probes.append(probe) # Create polarized probe and work around initialization bug From b5494c86e24c8e80ef33ffbda6052aef82102da1 Mon Sep 17 00:00:00 2001 From: Piotr Rozyczko Date: Fri, 26 Sep 2025 13:44:19 +0200 Subject: [PATCH 09/19] added id-token --- .github/workflows/documentation-build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index faaff2bd..8badb276 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -23,6 +23,13 @@ jobs: # This workflow contains a single job called "build" build_documentation: runs-on: ubuntu-latest + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + contents: read # to clone the repository + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + steps: - name: Checkout uses: actions/checkout@master From e09c99f2a88ce41b9fbe693cd37d425227dc55ee Mon Sep 17 00:00:00 2001 From: Piotr Rozyczko Date: Fri, 26 Sep 2025 13:57:18 +0200 Subject: [PATCH 10/19] added environment --- .github/workflows/documentation-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 8badb276..f447b491 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -23,6 +23,9 @@ jobs: # This workflow contains a single job called "build" build_documentation: runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: From adc72b8d861722c8486d527fce685f25db25da37 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Tue, 30 Sep 2025 08:49:41 +0200 Subject: [PATCH 11/19] test new_clear branch --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4b2159e4..a73fe699 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ requires-python = ">=3.11,<3.13" dependencies = [ - "easyscience", + "easyscience @ git+https://github.com/easyscience/corelib.git@new_clear", "scipp", "refnx", "refl1d>=1.0.0rc0", From 71dd9e33216b35455f0616d2ab29d7a335a9c013 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Tue, 30 Sep 2025 09:07:11 +0200 Subject: [PATCH 12/19] update branch name and add cairo installation for new GH image --- .github/workflows/python-ci.yml | 5 +++++ pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 2f34eb2a..45899fd7 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -43,6 +43,11 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install cairo and dependencies + if: runner.os == 'Linux' + run: | + sudo apt install libcairo2-dev + - name: Upgrade pip run: | python -m pip install --upgrade pip diff --git a/pyproject.toml b/pyproject.toml index a73fe699..fb552a6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ requires-python = ">=3.11,<3.13" dependencies = [ - "easyscience @ git+https://github.com/easyscience/corelib.git@new_clear", + "easyscience @ git+https://github.com/easyscience/corelib.git@dict_size_changed_bug", "scipp", "refnx", "refl1d>=1.0.0rc0", From 0a5362505475e42b11538c4a1c4cb102e3704efb Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 2 Oct 2025 15:32:19 +0200 Subject: [PATCH 13/19] install pycairo before xhtml2pdf --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a0c79ff5..597e625f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dependencies = [ "refnx", "refl1d>=1.0.0rc0", "orsopy", + "pycairo<1.6" "xhtml2pdf", "bumps", ] From 117e5798f242bae75dc8424305118f538f1e0a0b Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 2 Oct 2025 15:34:14 +0200 Subject: [PATCH 14/19] typo --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 597e625f..ee41012f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "refnx", "refl1d>=1.0.0rc0", "orsopy", - "pycairo<1.6" + "pycairo<1.6", "xhtml2pdf", "bumps", ] From c51cd1fb8988a9e323a151b6b212198ec457c013 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Thu, 2 Oct 2025 17:20:23 +0200 Subject: [PATCH 15/19] it's 1.16 and only on linux --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ee41012f..a8feafe3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "refnx", "refl1d>=1.0.0rc0", "orsopy", - "pycairo<1.6", + "pycairo<1.16 ; platform_system=='Linux'", "xhtml2pdf", "bumps", ] From 262546c2c1ab6379706937ebcaeb183cb5e3398f Mon Sep 17 00:00:00 2001 From: Piotr Rozyczko Date: Thu, 2 Oct 2025 17:39:26 +0200 Subject: [PATCH 16/19] it is svglib --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a8feafe3..661ee847 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "refnx", "refl1d>=1.0.0rc0", "orsopy", - "pycairo<1.16 ; platform_system=='Linux'", + "svglib<1.6 ; platform_system=='Linux'", "xhtml2pdf", "bumps", ] From bb53406e5f22868c12c3959be699c18ed1518ca2 Mon Sep 17 00:00:00 2001 From: Piotr Rozyczko Date: Fri, 3 Oct 2025 08:16:34 +0200 Subject: [PATCH 17/19] revert cairo installation for the lib. --- .github/workflows/python-ci.yml | 5 ---- pyproject.toml | 1 - .../calculators/refl1d/wrapper.py | 23 ++++++------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 45899fd7..2f34eb2a 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -43,11 +43,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install cairo and dependencies - if: runner.os == 'Linux' - run: | - sudo apt install libcairo2-dev - - name: Upgrade pip run: | python -m pip install --upgrade pip diff --git a/pyproject.toml b/pyproject.toml index e75d073c..fd1f1fd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,6 @@ dev = [ docs = [ "myst_parser", - "pycairo", "nbsphinx", "sphinx<=8.1.3", "sphinx_autodoc_typehints", diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index 7acc4e83..5e9a9677 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -185,12 +185,12 @@ def calculate(self, q_array: np.ndarray, model_name: str) -> np.ndarray: if ALL_POLARIZATIONS: raise NotImplementedError('Polarized reflectivity not yet implemented') # returns q, reflectivity - # _, reflectivity_mm = polarized_reflectivity[0] - # _, reflectivity_mp = polarized_reflectivity[1] - # _, reflectivity_pm = polarized_reflectivity[2] - # _, reflectivity_pp = polarized_reflectivity[3] + # _, reflectivity_pp = polarized_reflectivity[0] + # _, reflectivity_pm = polarized_reflectivity[1] + # _, reflectivity_mp = polarized_reflectivity[2] + # _, reflectivity_mm = polarized_reflectivity[3] else: - # Only pick the mm reflectivity (first component) + # Only pick the pp reflectivity (first component) # returns q, reflectivity _, reflectivity = polarized_reflectivity[0] @@ -260,7 +260,7 @@ def _get_polarized_probe( ) -> names.PolarizedNeutronQProbe: four_probes = [] for i in range(4): - if all_polarizations: + if i == 0 or all_polarizations: # Create probe for all polarizations: mm, mp, pm, pp probe = _get_probe( q_array=q_array, @@ -271,16 +271,7 @@ def _get_polarized_probe( magnetism=True, # Enable magnetism for polarized probes ) else: - # When all_polarizations=False, create all probes but only compute what's needed - # This ensures the PolarizedNeutronProbe is properly initialized - probe = _get_probe( - q_array=q_array, - dq_array=dq_array, - model_name=model_name, - storage=storage, - oversampling_factor=oversampling_factor, - magnetism=True, # Enable magnetism for polarized probes - ) + probe = None four_probes.append(probe) # Create polarized probe and work around initialization bug From a65411052e6f521ee06db1ec4c1ea00237d65dc6 Mon Sep 17 00:00:00 2001 From: Piotr Rozyczko Date: Fri, 3 Oct 2025 08:42:22 +0200 Subject: [PATCH 18/19] try with the master branch of corelib --- pyproject.toml | 3 ++- src/easyreflectometry/calculators/refl1d/wrapper.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fd1f1fd7..fa819adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,8 @@ classifiers = [ requires-python = ">=3.11,<3.13" dependencies = [ - "easyscience @ git+https://github.com/easyscience/corelib.git@dict_size_changed_bug", + #"easyscience @ git+https://github.com/easyscience/corelib.git@dict_size_changed_bug", + "easyscience", "scipp", "refnx", "refl1d>=1.0.0rc0", diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index 5e9a9677..e47cf052 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -190,7 +190,7 @@ def calculate(self, q_array: np.ndarray, model_name: str) -> np.ndarray: # _, reflectivity_mp = polarized_reflectivity[2] # _, reflectivity_mm = polarized_reflectivity[3] else: - # Only pick the pp reflectivity (first component) + # Only pick the pp reflectivity # returns q, reflectivity _, reflectivity = polarized_reflectivity[0] @@ -261,7 +261,6 @@ def _get_polarized_probe( four_probes = [] for i in range(4): if i == 0 or all_polarizations: - # Create probe for all polarizations: mm, mp, pm, pp probe = _get_probe( q_array=q_array, dq_array=dq_array, From 20a5466277858062639a5ec26b556805f7d40587 Mon Sep 17 00:00:00 2001 From: rozyczko Date: Tue, 21 Oct 2025 13:56:06 +0200 Subject: [PATCH 19/19] fixed magnetism notebook --- docs/src/tutorials/simulation/magnetism.ipynb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/src/tutorials/simulation/magnetism.ipynb b/docs/src/tutorials/simulation/magnetism.ipynb index 0002733f..1f35fdf1 100644 --- a/docs/src/tutorials/simulation/magnetism.ipynb +++ b/docs/src/tutorials/simulation/magnetism.ipynb @@ -418,14 +418,15 @@ "\n", "model_name = model.unique_name\n", "storage = {'model': {model_name: {}}}\n", - "storage['model'][model_name]['scale'] = 10.0\n", - "storage['model'][model_name]['bkg'] = 20.0\n", + "storage['model'][model_name]['scale'] = 1.0\n", + "storage['model'][model_name]['bkg'] = 0.0\n", "\n", "polarized_probe = _get_polarized_probe(\n", " q_array=model_coords,\n", " dq_array=np.zeros(len(model_coords)),\n", " model_name=model_name,\n", - " storage=storage)\n", + " storage=storage,\n", + " all_polarizations=True)\n", "\n", "experiment = refl1d.names.Experiment(probe=polarized_probe, sample=refl1d_sample)\n" ] @@ -551,7 +552,7 @@ ], "metadata": { "kernelspec": { - "display_name": "p312", + "display_name": "era", "language": "python", "name": "python3" }, @@ -565,7 +566,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.11" + "version": "3.11.12" } }, "nbformat": 4,