diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 5a741554..f447b491 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -23,6 +23,16 @@ 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: + 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 @@ -34,16 +44,21 @@ 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: Install Jupyter kernel + run: | + python -m ipykernel install --user --name=python3 + - 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 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/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, diff --git a/docs/src/tutorials/simulation/magnetism.ipynb b/docs/src/tutorials/simulation/magnetism.ipynb index 82834ee2..1f35fdf1 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,28 @@ " 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'] = 1.0\n", + "storage['model'][model_name]['bkg'] = 0.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", + " all_polarizations=True)\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 +552,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv2", + "display_name": "era", "language": "python", "name": "python3" }, @@ -569,7 +566,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.11.12" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index a0c79ff5..fa819adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,11 +29,13 @@ classifiers = [ requires-python = ">=3.11,<3.13" dependencies = [ + #"easyscience @ git+https://github.com/easyscience/corelib.git@dict_size_changed_bug", "easyscience", "scipp", "refnx", "refl1d>=1.0.0rc0", "orsopy", + "svglib<1.6 ; platform_system=='Linux'", "xhtml2pdf", "bumps", ] @@ -60,7 +62,7 @@ dev = [ docs = [ "myst_parser", "nbsphinx", - "sphinx==8.1.3", + "sphinx<=8.1.3", "sphinx_autodoc_typehints", "sphinx_book_theme", "sphinx-copybutton", @@ -142,7 +144,7 @@ python = PLATFORM = ubuntu-latest: linux macos-latest: macos - windows-latest: windows + windows-latest: 2022 [testenv] passenv = CI