diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4ac1fbc..a6ceeebd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,8 +42,7 @@ Please make sure you follow the EasyScience organization-wide If you are not planning to contribute code, you may want to: - šŸž Report a bug — see [Reporting Issues](#11-reporting-issues) -- šŸ›” Report a security issue — see - [Security Issues](#12-security-issues) +- šŸ›” Report a security issue — see [Security Issues](#12-security-issues) - šŸ’¬ Ask a question or start a discussion at [Project Discussions](https://github.com/easyscience/reflectometry-lib/discussions) diff --git a/docs/docs/tutorials/simulation/bilayer.ipynb b/docs/docs/tutorials/simulation/bilayer.ipynb index 5f37b010..987cd8e1 100644 --- a/docs/docs/tutorials/simulation/bilayer.ipynb +++ b/docs/docs/tutorials/simulation/bilayer.ipynb @@ -331,7 +331,7 @@ "q = np.linspace(0.005, 0.3, 500)\n", "\n", "# Calculate reflectometry\n", - "reflectivity = model.interface().reflectity_profile(q, model.unique_name)\n", + "reflectivity = model.interface().reflectivity_profile(q, model.unique_name)\n", "\n", "# Plot\n", "plt.figure(figsize=(10, 6))\n", @@ -391,7 +391,7 @@ "outputs": [], "source": [ "# First, compute reflectivity with current conformal roughness (3.0 ƅ)\n", - "reflectivity_conformal = model.interface().reflectity_profile(q, model.unique_name)\n", + "reflectivity_conformal = model.interface().reflectivity_profile(q, model.unique_name)\n", "\n", "# Disable conformal roughness to allow independent roughness per layer\n", "bilayer.conformal_roughness = False\n", @@ -406,7 +406,7 @@ "bilayer.back_head_layer.roughness.value = 4.0\n", "\n", "# Compute reflectivity with variable roughness\n", - "reflectivity_variable_roughness = model.interface().reflectity_profile(q, model.unique_name)\n", + "reflectivity_variable_roughness = model.interface().reflectivity_profile(q, model.unique_name)\n", "\n", "# Plot comparison\n", "plt.figure(figsize=(10, 6))\n", @@ -629,8 +629,8 @@ "outputs": [], "source": [ "# Calculate reflectivity for both contrasts\n", - "reflectivity_d2o = model.interface().reflectity_profile(q, model.unique_name)\n", - "reflectivity_h2o = model_h2o.interface().reflectity_profile(q, model_h2o.unique_name)\n", + "reflectivity_d2o = model.interface().reflectivity_profile(q, model.unique_name)\n", + "reflectivity_h2o = model_h2o.interface().reflectivity_profile(q, model_h2o.unique_name)\n", "\n", "plt.figure(figsize=(10, 6))\n", "plt.semilogy(q, reflectivity_d2o, 'b-', linewidth=2, label='Dā‚‚O contrast')\n", diff --git a/docs/docs/tutorials/simulation/magnetism.ipynb b/docs/docs/tutorials/simulation/magnetism.ipynb index 8efdb9e4..ef226c41 100644 --- a/docs/docs/tutorials/simulation/magnetism.ipynb +++ b/docs/docs/tutorials/simulation/magnetism.ipynb @@ -252,7 +252,7 @@ "model.resolution_function = PercentageFwhm(0)\n", "model_interface = model.interface()\n", "model_interface.magnetism = False\n", - "model_data_no_magnetism_ref1d_easy = model.interface().reflectity_profile(\n", + "model_data_no_magnetism_ref1d_easy = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -284,7 +284,7 @@ "model.interface = interface\n", "model_interface = model.interface()\n", "model_interface.include_magnetism = True\n", - "model_data_magnetism = model.interface().reflectity_profile(\n", + "model_data_magnetism = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -301,7 +301,7 @@ "model_interface._wrapper.update_layer(\n", " list(model_interface._wrapper.storage['layer'].keys())[2], magnetism_rhoM=5, magnetism_thetaM=175\n", ")\n", - "model_data_magnetism_layer_1 = model.interface().reflectity_profile(\n", + "model_data_magnetism_layer_1 = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -365,7 +365,7 @@ "model_interface._wrapper.update_layer(\n", " list(model_interface._wrapper.storage['layer'].keys())[2], magnetism_rhoM=5, magnetism_thetaM=175\n", ")\n", - "model_data_magnetism_easy = model.interface().reflectity_profile(\n", + "model_data_magnetism_easy = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -478,7 +478,7 @@ "interface.switch('refnx')\n", "model.interface = interface\n", "model_interface = model.interface()\n", - "model_data_no_magnetism_refnx = model.interface().reflectity_profile(\n", + "model_data_no_magnetism_refnx = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -488,7 +488,7 @@ "interface.switch('refl1d')\n", "model.interface = interface\n", "model_interface = model.interface()\n", - "model_data_no_magnetism_ref1d = model.interface().reflectity_profile(\n", + "model_data_no_magnetism_ref1d = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -518,7 +518,7 @@ "model.interface = interface\n", "model_interface = model.interface()\n", "model_interface.magnetism = True\n", - "model_data_magnetism = model.interface().reflectity_profile(\n", + "model_data_magnetism = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -529,7 +529,7 @@ "model.interface = interface\n", "model_interface = model.interface()\n", "model_interface.magnetism = False\n", - "model_data_no_magnetism = model.interface().reflectity_profile(\n", + "model_data_no_magnetism = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", diff --git a/docs/docs/tutorials/simulation/resolution_functions.ipynb b/docs/docs/tutorials/simulation/resolution_functions.ipynb index d46a76cb..cc7abe10 100644 --- a/docs/docs/tutorials/simulation/resolution_functions.ipynb +++ b/docs/docs/tutorials/simulation/resolution_functions.ipynb @@ -310,7 +310,7 @@ " num=1000,\n", " )\n", " model.resolution_function = resolution_function_dict[key]\n", - " model_data = model.interface().reflectity_profile(\n", + " model_data = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", " )\n", @@ -363,14 +363,14 @@ ")\n", "\n", "model.resolution_function = resolution_function_dict[key]\n", - "model_data = model.interface().reflectity_profile(\n", + "model_data = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", "plt.plot(model_coords, model_data, 'k-', label='Variable', linewidth=5)\n", "\n", "model.resolution_function = PercentageFwhm(1.0)\n", - "model_data = model.interface().reflectity_profile(\n", + "model_data = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -402,7 +402,7 @@ ")\n", "\n", "model.resolution_function = resolution_function_dict[key]\n", - "model_data = model.interface().reflectity_profile(\n", + "model_data = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", @@ -415,7 +415,7 @@ "data_points.append(reference_data) # R\n", "data_points.append(reference_variances) # sQz (variance of Qz)\n", "model.resolution_function = Pointwise(q_data_points=data_points)\n", - "model_data = model.interface().reflectity_profile(\n", + "model_data = model.interface().reflectivity_profile(\n", " model_coords,\n", " model.unique_name,\n", ")\n", diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index f75e4657..1cd19cde 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -208,7 +208,8 @@ nav: - Elements: - Layers: - Layer: api-reference/elements/layer.md - - Layer Area Per Molecule: api-reference/elements/layer_area_per_molecule.md + - Layer Area Per Molecule: + api-reference/elements/layer_area_per_molecule.md - Materials: - Material: api-reference/elements/material.md - Material Density: api-reference/elements/material_density.md diff --git a/pixi.lock b/pixi.lock index 6b3a38bc..983bc0bd 100644 --- a/pixi.lock +++ b/pixi.lock @@ -1,8 +1,21 @@ version: 7 platforms: - name: linux-64 -- name: osx-arm64 + virtual-packages: + - __unix=0=0 + - __linux=4.18 + - __glibc=2.28 + - __archspec=0=x86_64 +- name: p1 + subdir: osx-arm64 + virtual-packages: + - __osx=14.0 + - __unix=0=0 + - __archspec=0=m1 - name: win-64 + virtual-packages: + - __win=10.0 + - __archspec=0=x86_64 environments: default: channels: @@ -189,8 +202,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/webencodings-0.5.1-pyhd8ed1ab_3.conda - conda: https://conda.anaconda.org/conda-forge/noarch/websocket-client-1.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -326,7 +339,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/fb/86/dd6e5db36df29e76c7a7699123569a4a18c1623ce68d826ed96c62643cae/mdit_py_plugins-0.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fb/d9/8f612389178e1e1800aaed85537b024ebe28b9a82fff6a015825e51a8877/refl1d-1.0.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fd/20/2870f2e63da2b74eda896053809065769b256646bb3f4b74e06d013ad590/uritools-6.1.0-py3-none-any.whl - osx-arm64: + p1: - conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_2.conda - conda: https://conda.anaconda.org/conda-forge/noarch/annotated-types-0.7.0-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda @@ -500,8 +513,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zeromq-4.3.5-h4818236_10.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -801,8 +814,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-0.2.5-h6a83c73_3.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zeromq-4.3.5-h507cc87_10.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.7-h534d264_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -1124,8 +1137,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/webencodings-0.5.1-pyhd8ed1ab_3.conda - conda: https://conda.anaconda.org/conda-forge/noarch/websocket-client-1.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/06/8a/5e156e31ba656ce93c1cc895dd8f051ec351cb382940dca655aaec475005/python_bidi-0.6.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl @@ -1259,7 +1272,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/fb/86/dd6e5db36df29e76c7a7699123569a4a18c1623ce68d826ed96c62643cae/mdit_py_plugins-0.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fb/d9/8f612389178e1e1800aaed85537b024ebe28b9a82fff6a015825e51a8877/refl1d-1.0.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fd/20/2870f2e63da2b74eda896053809065769b256646bb3f4b74e06d013ad590/uritools-6.1.0-py3-none-any.whl - osx-arm64: + p1: - conda: https://conda.anaconda.org/conda-forge/noarch/annotated-types-0.7.0-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/appnope-0.1.4-pyhd8ed1ab_1.conda @@ -1429,8 +1442,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zeromq-4.3.5-h4818236_10.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/07/c7/deb8c5e604404dbf10a3808a858946ca3547692ff6316b698945bb72177e/python_socketio-5.16.1-py3-none-any.whl @@ -1724,8 +1737,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-0.2.5-h6a83c73_3.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zeromq-4.3.5-h507cc87_10.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.7-h534d264_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/02/05/d60c732b56da5085175c07c74b2df4e6d181b0c9a61e1691474f06ef4b39/lxml-6.1.0-cp311-cp311-win_amd64.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -2047,8 +2060,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/webencodings-0.5.1-pyhd8ed1ab_3.conda - conda: https://conda.anaconda.org/conda-forge/noarch/websocket-client-1.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -2184,7 +2197,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/fb/86/dd6e5db36df29e76c7a7699123569a4a18c1623ce68d826ed96c62643cae/mdit_py_plugins-0.5.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fb/d9/8f612389178e1e1800aaed85537b024ebe28b9a82fff6a015825e51a8877/refl1d-1.0.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fd/20/2870f2e63da2b74eda896053809065769b256646bb3f4b74e06d013ad590/uritools-6.1.0-py3-none-any.whl - osx-arm64: + p1: - conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_2.conda - conda: https://conda.anaconda.org/conda-forge/noarch/annotated-types-0.7.0-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda @@ -2358,8 +2371,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zeromq-4.3.5-h4818236_10.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -2659,8 +2672,8 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-0.2.5-h6a83c73_3.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zeromq-4.3.5-h507cc87_10.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.7-h534d264_6.conda - - pypi: . - - pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 + - pypi: ./ + - pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 - pypi: https://files.pythonhosted.org/packages/00/bb/90ba423612b6aa0adccc6b1874bcd4a9b44b660c0c16f346611e00f64ac3/backrefs-7.0-py313-none-any.whl - pypi: https://files.pythonhosted.org/packages/01/7c/fa07d3da2b6253eb8474be16eab2eadf670460e364ccc895ca7ff388ee30/oscrypto-1.3.0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/04/11/432f32f8097b03e3cd5fe57e88efb685d964e2e5178a48ed61e841f7fdce/pyyaml_env_tag-1.1-py3-none-any.whl @@ -3070,7 +3083,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/f7/00/bbca25f8a2372465cdf93138c1e1e38dff045fb0afef1488f395d0afcb3b/ncrystal-4.4.2-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fb/12/5911ae3eeec47800503a238d971e51722ccea5feb8569b735184d5fcdbc0/toolz-1.1.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/fb/76/641ae371508676492379f16e2fa48f4e2c11741bd63c48be4b12a6b09cba/aiosignal-1.4.0-py3-none-any.whl - osx-arm64: + p1: - conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_2.conda - conda: https://conda.anaconda.org/conda-forge/noarch/annotated-types-0.7.0-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda @@ -8297,12 +8310,13 @@ packages: purls: [] size: 388453 timestamp: 1764777142545 -- pypi: . +- pypi: ./ name: easyreflectometry requires_dist: - bumps - - easyscience @ git+https://github.com/easyscience/corelib@develop + - easyscience @ git+https://github.com/easyscience/corelib.git@develop - orsopy + - plotly - pooch - refl1d>=1.0.0 - refnx @@ -8344,7 +8358,7 @@ packages: - validate-pyproject[all] ; extra == 'dev' - versioningit ; extra == 'dev' requires_python: '>=3.11' -- pypi: git+https://github.com/easyscience/corelib?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 +- pypi: git+https://github.com/easyscience/corelib.git?rev=develop#aadbd4891b94f6aa18187d48be8c2ab6f81113b0 name: easyscience version: 2.3.1+dev8 requires_dist: diff --git a/src/easyreflectometry/calculators/calculator_base.py b/src/easyreflectometry/calculators/calculator_base.py index e2a92804..06fa5f07 100644 --- a/src/easyreflectometry/calculators/calculator_base.py +++ b/src/easyreflectometry/calculators/calculator_base.py @@ -189,7 +189,7 @@ def remove_item_from_model(self, item_id: str, model_id: str) -> None: """ self._wrapper.remove_item(item_id, model_id) - def reflectity_profile(self, x_array: np.ndarray, model_id: str) -> np.ndarray: + def reflectivity_profile(self, x_array: np.ndarray, model_id: str) -> np.ndarray: """Determines the reflectivity profile for the given range and model. Parameters diff --git a/src/easyreflectometry/calculators/factory.py b/src/easyreflectometry/calculators/factory.py index c3e1479c..b1c1b170 100644 --- a/src/easyreflectometry/calculators/factory.py +++ b/src/easyreflectometry/calculators/factory.py @@ -40,6 +40,6 @@ def fit_func(self) -> Callable: def __fit_func(*args, **kwargs): """Fit func.""" - return self().reflectity_profile(*args, **kwargs) + return self().reflectivity_profile(*args, **kwargs) return __fit_func diff --git a/src/easyreflectometry/fitting.py b/src/easyreflectometry/fitting.py index 83a3f6eb..3cb0ecb3 100644 --- a/src/easyreflectometry/fitting.py +++ b/src/easyreflectometry/fitting.py @@ -384,8 +384,8 @@ def mcmc_sample( — the population already exists in the saved state. :param progress_callback: Optional callback for progress updates during sampling. Forwarded to the core MultiFitter. - :return: Dictionary with keys ``'draws'``, ``'param_names'``, ``'state'``, - and ``'logp'``. + :return: Dictionary with keys ``'draws'``, ``'param_names'``, + ``'internal_bumps_object'``, and ``'logp'``. :raises RuntimeError: If the current minimizer is not a BUMPS instance. """ minimizer = self.easy_science_multi_fitter.minimizer @@ -494,19 +494,3 @@ def switch_minimizer(self, minimizer: AvailableMinimizers) -> None: Minimizer to be switched to. """ self.easy_science_multi_fitter.switch_minimizer(minimizer) - - -def _flatten_list(this_list: list) -> list: - """Flatten nested lists. - - Parameters - ---------- - this_list : list - List to be flattened. - - Returns - ------- - list - Flattened list. - """ - return np.array([item for sublist in this_list for item in sublist]) diff --git a/src/easyreflectometry/limits.py b/src/easyreflectometry/limits.py index 001bba64..8962ab9b 100644 --- a/src/easyreflectometry/limits.py +++ b/src/easyreflectometry/limits.py @@ -31,14 +31,19 @@ def apply_default_limits(parameter: Parameter, kind: str) -> None: def _apply_percentage_limits(parameter: Parameter) -> None: - """Set min to 50% and max to 200% of the current value, only if current bounds are inf.""" + """Set bounds to 50%-200% of the current value, only if current bounds are inf. + + For negative values 0.5*value > 2*value, so the candidates are ordered + to keep min <= value <= max. + """ value = parameter.value if value == 0.0: return + low, high = sorted((0.5 * value, 2.0 * value)) if np.isinf(parameter.min): - parameter.min = 0.5 * value + parameter.min = low if np.isinf(parameter.max): - parameter.max = 2.0 * value + parameter.max = high def _apply_fixed_limits(parameter: Parameter, low: float, high: float) -> None: diff --git a/src/easyreflectometry/model/model.py b/src/easyreflectometry/model/model.py index da1396d0..5aa32833 100644 --- a/src/easyreflectometry/model/model.py +++ b/src/easyreflectometry/model/model.py @@ -148,12 +148,12 @@ def background(self, value: float) -> None: # ----- assembly management ----- - def add_assemblies(self, *assemblies: list[BaseAssembly]) -> None: + def add_assemblies(self, *assemblies: BaseAssembly) -> None: """Add assemblies to the model sample. Parameters ---------- - *assemblies : list[BaseAssembly] + *assemblies : BaseAssembly Assemblies to add to model sample. """ if not assemblies: diff --git a/src/easyreflectometry/model/resolution_functions.py b/src/easyreflectometry/model/resolution_functions.py index fe5d2254..c723bf14 100644 --- a/src/easyreflectometry/model/resolution_functions.py +++ b/src/easyreflectometry/model/resolution_functions.py @@ -10,6 +10,7 @@ from __future__ import annotations +from abc import ABC from abc import abstractmethod from typing import List from typing import Optional @@ -20,7 +21,7 @@ DEFAULT_RESOLUTION_FWHM_PERCENTAGE = 5.0 -class ResolutionFunction: +class ResolutionFunction(ABC): @abstractmethod def smearing(self, q: Union[np.array, float]) -> np.array: ... diff --git a/src/easyreflectometry/project.py b/src/easyreflectometry/project.py index 5ae272a6..fe4af1bf 100644 --- a/src/easyreflectometry/project.py +++ b/src/easyreflectometry/project.py @@ -346,29 +346,30 @@ def path_json(self): """Path json.""" return self.path / 'project.json' + def _get_or_add_material_index(self, name: str, sld: float, isld: float) -> int: + """Return the index of the named material, adding it to the project + materials first if not present. This mutates ``self._materials``.""" + names = [material.name for material in self._materials] + if name not in names: + self._materials.add_material(Material(name=name, sld=sld, isld=isld)) + names.append(name) + return names.index(name) + def get_index_air(self) -> int: - """Get index air.""" - if 'Air' not in [material.name for material in self._materials]: - self._materials.add_material(Material(name='Air', sld=0.0, isld=0.0)) - return [material.name for material in self._materials].index('Air') + """Index of the Air material, adding it to the project if missing.""" + return self._get_or_add_material_index('Air', sld=0.0, isld=0.0) def get_index_si(self) -> int: - """Get index si.""" - if 'Si' not in [material.name for material in self._materials]: - self._materials.add_material(Material(name='Si', sld=2.07, isld=0.0)) - return [material.name for material in self._materials].index('Si') + """Index of the Si material, adding it to the project if missing.""" + return self._get_or_add_material_index('Si', sld=2.07, isld=0.0) def get_index_sio2(self) -> int: - """Get index sio2.""" - if 'SiO2' not in [material.name for material in self._materials]: - self._materials.add_material(Material(name='SiO2', sld=3.47, isld=0.0)) - return [material.name for material in self._materials].index('SiO2') + """Index of the SiO2 material, adding it to the project if missing.""" + return self._get_or_add_material_index('SiO2', sld=3.47, isld=0.0) def get_index_d2o(self) -> int: - """Get index d2o.""" - if 'D2O' not in [material.name for material in self._materials]: - self._materials.add_material(Material(name='D2O', sld=6.36, isld=0.0)) - return [material.name for material in self._materials].index('D2O') + """Index of the D2O material, adding it to the project if missing.""" + return self._get_or_add_material_index('D2O', sld=6.36, isld=0.0) def load_orso_file(self, path: Union[Path, str]) -> None: """Load an ORSO file and optionally create a model and a data from it.""" @@ -386,7 +387,6 @@ def load_orso_file(self, path: Union[Path, str]) -> None: self._experiments[0].name = 'Experiment from ORSO' self._experiments[0].model = self.models[0] self._with_experiments = True - pass def set_sample_from_orso(self, sample: Sample) -> None: """Replace the current project model collection with a single model built from an ORSO-parsed sample. @@ -665,7 +665,7 @@ def model_data_for_model_at_index(self, index: int = 0, q_range: Optional[np.arr if q_range is None: q_range = np.linspace(self.q_min, self.q_max, self.q_resolution) self.models[index].interface = self._calculator - reflectivity = self.models[index].interface().reflectity_profile(q_range, self._models[index].unique_name) + reflectivity = self.models[index].interface().reflectivity_profile(q_range, self._models[index].unique_name) return DataSet1D( name=f'Reflectivity for Model {index}', x=q_range, @@ -868,10 +868,10 @@ def as_dict(self, include_materials_not_in_model=False): self._as_dict_add_materials_not_in_model_dict(project_dict) if self._with_experiments: self._as_dict_add_experiments(project_dict) - if self.fitter is not None: - project_dict['fitter_minimizer'] = self.fitter.easy_science_multi_fitter.minimizer.name - elif self._minimizer_selection is not None: - project_dict['fitter_minimizer'] = self._minimizer_selection.name + # Read the minimizer without touching the lazy `fitter` property: + # serialization must not construct a MultiFitter as a side effect. + if self.minimizer is not None: + project_dict['fitter_minimizer'] = self.minimizer.name if self._calculator is not None: project_dict['calculator'] = self._calculator.current_interface_name if self._colors is not None: diff --git a/src/easyreflectometry/sample/elements/materials/material_mixture.py b/src/easyreflectometry/sample/elements/materials/material_mixture.py index 1ab76ddc..b5b88e27 100644 --- a/src/easyreflectometry/sample/elements/materials/material_mixture.py +++ b/src/easyreflectometry/sample/elements/materials/material_mixture.py @@ -152,17 +152,16 @@ def fraction(self, value: float) -> None: # ----- derived sld / isld parameters (shared shape with Material) ----- # # These are *derived* via the constraints set up in `_materials_constraints` - # (not constructor arguments) so we expose them as floats to match the - # legacy MaterialMixture API. The underlying Parameter objects remain - # available as `self._sld` / `self._isld`. + # (not constructor arguments), so unlike Material there are no setters: + # their values follow the child materials and the fraction. @property - def sld(self) -> float: - return self._sld.value + def sld(self) -> Parameter: + return self._sld @property - def isld(self) -> float: - return self._isld.value + def isld(self) -> Parameter: + return self._isld # ----- calculator binding ----- @@ -171,8 +170,8 @@ def _get_linkable_attributes(self): Override of the inherited `BaseCore._get_linkable_attributes`, which walks `get_all_variables()` and would otherwise expose the **child** - materials' sld/isld (because our own `sld` / `isld` are floats, not - Parameters). The calculator's `InterfaceFactoryTemplate.generate_bindings` + materials' sld/isld alongside the mixed ones. The calculator's + `InterfaceFactoryTemplate.generate_bindings` matches by parameter `name`; without this override it binds to `material_a.sld` and reflectivity is computed off the wrong SLD. """ diff --git a/src/easyreflectometry/special/calculations.py b/src/easyreflectometry/special/calculations.py index 07844d3c..9c6e43c2 100644 --- a/src/easyreflectometry/special/calculations.py +++ b/src/easyreflectometry/special/calculations.py @@ -44,11 +44,13 @@ def neutron_scattering_length(formula: str) -> complex: scattering_length = 0 + 0j for key, value in formula_as_dict.items(): scattering_length += pt.elements.symbol(key).neutron.b_c * value + # b_c_i is the imaginary (absorption) part of the bound coherent + # scattering length, not the incoherent scattering length. if pt.elements.symbol(key).neutron.b_c_i: - inc = pt.elements.symbol(key).neutron.b_c_i + imag = pt.elements.symbol(key).neutron.b_c_i else: - inc = 0 - scattering_length += inc * 1j * value + imag = 0 + scattering_length += imag * 1j * value return scattering_length * 1e-5 @@ -63,7 +65,7 @@ def molecular_weight(formula: str) -> float: Returns ------- float - Molecular weight of the material in kilograms. + Molecular weight of the material in u (g/mol). """ formula_as_dict = parse_formula(formula) mw = 0 diff --git a/tests/calculators/refl1d/test_refl1d_calculator.py b/tests/calculators/refl1d/test_refl1d_calculator.py index 50de2db4..a27d1f7a 100644 --- a/tests/calculators/refl1d/test_refl1d_calculator.py +++ b/tests/calculators/refl1d/test_refl1d_calculator.py @@ -27,7 +27,7 @@ def test_init(self): assert_equal(p._model_link['background'], 'bkg') assert_equal(p.name, 'refl1d') - def test_reflectity_profile(self): + def test_reflectivity_profile(self): p = Refl1d() p._wrapper.create_material('Material1') p._wrapper.update_material('Material1', rho=0.000, irho=0.000) @@ -63,7 +63,7 @@ def test_reflectity_profile(self): 1.3093e-07, 1.0520e-07, ] - assert_almost_equal(p.reflectity_profile(q, 'MyModel'), expected, decimal=4) + assert_almost_equal(p.reflectivity_profile(q, 'MyModel'), expected, decimal=4) def test_calculate2(self): p = Refl1d() @@ -95,7 +95,7 @@ def test_calculate2(self): p._wrapper.add_item('Item3', 'MyModel') p._wrapper.update_item('Item2', repeat=10) q = np.linspace(0.001, 0.3, 10) - actual = p.reflectity_profile(q, 'MyModel') + actual = p.reflectivity_profile(q, 'MyModel') expected = [ 9.9949e-01, 8.7414e-03, @@ -140,7 +140,7 @@ def test_calculate_magnetic(self): p._wrapper.add_item('Item2', 'MyModel') p._wrapper.add_item('Item3', 'MyModel') q = np.linspace(0.001, 0.3, 10) - actual = p.reflectity_profile(q, 'MyModel') + actual = p.reflectivity_profile(q, 'MyModel') expected = [ 9.99491251e-01, 1.08413641e-02, diff --git a/tests/calculators/refnx/test_refnx_calculator.py b/tests/calculators/refnx/test_refnx_calculator.py index baeb9296..e4efae68 100644 --- a/tests/calculators/refnx/test_refnx_calculator.py +++ b/tests/calculators/refnx/test_refnx_calculator.py @@ -27,7 +27,7 @@ def test_init(self): assert_equal(p._model_link['background'], 'bkg') assert_equal(p.name, 'refnx') - def test_reflectity_profile(self): + def test_reflectivity_profile(self): p = Refnx() p._wrapper.create_material('Material1') p._wrapper.update_material('Material1', real=0.000, imag=0.000) @@ -62,7 +62,7 @@ def test_reflectity_profile(self): 1.26726993e-07, 1.01842852e-07, ] - assert_almost_equal(p.reflectity_profile(q, 'MyModel'), expected) + assert_almost_equal(p.reflectivity_profile(q, 'MyModel'), expected) def test_calculate2(self): p = Refnx() @@ -105,7 +105,7 @@ def test_calculate2(self): 3.4981523e-07, 2.5424356e-07, ] - assert_almost_equal(p.reflectity_profile(q, 'MyModel'), expected) + assert_almost_equal(p.reflectivity_profile(q, 'MyModel'), expected) def test_sld_profile(self): p = Refnx() diff --git a/tests/model/test_model.py b/tests/model/test_model.py index b11149c1..0c83d5dc 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -427,8 +427,8 @@ def test_dict_round_trip(interface): if interface is not None: assert model.interface().name == model_from_dict.interface().name assert_almost_equal( - model.interface().reflectity_profile([0.3], model.unique_name), - model_from_dict.interface().reflectity_profile([0.3], model_from_dict.unique_name), + model.interface().reflectivity_profile([0.3], model.unique_name), + model_from_dict.interface().reflectivity_profile([0.3], model_from_dict.unique_name), ) diff --git a/tests/model/test_resolution_functions.py b/tests/model/test_resolution_functions.py index b8a4ea18..1391949b 100644 --- a/tests/model/test_resolution_functions.py +++ b/tests/model/test_resolution_functions.py @@ -38,7 +38,7 @@ def test_as_dict(self): resolution_function = PercentageFwhm(1.0) # Then Expect - resolution_function.as_dict() == {'smearing': 'PercentageFwhm', 'constant': 1.0} + assert resolution_function.as_dict() == {'smearing': 'PercentageFwhm', 'constant': 1.0} def test_dict_round_trip(self): # When @@ -67,7 +67,7 @@ def test_as_dict(self): resolution_function = LinearSpline(q_data_points=[0, 10], fwhm_values=[5, 10]) # Then Expect - resolution_function.as_dict() == { + assert resolution_function.as_dict() == { 'smearing': 'LinearSpline', 'q_data_points': [0, 10], 'fwhm_values': [5, 10], @@ -117,7 +117,12 @@ def test_as_dict(self): resolution_function = Pointwise(q_data_points=self.data_points) # Then Expect - assert resolution_function.as_dict(), {'smearing': 'Pointwise', 'q_data_points': [0, 10]} + assert resolution_function.as_dict() == { + 'smearing': 'Pointwise', + 'q_data_points': self.data_points[0], + 'R_data_points': self.data_points[1], + 'sQz_data_points': self.data_points[2], + } def test_dict_round_trip(self): # When diff --git a/tests/sample/elements/layers/test_layer_area_per_molecule.py b/tests/sample/elements/layers/test_layer_area_per_molecule.py index 0d466be7..7fe04009 100644 --- a/tests/sample/elements/layers/test_layer_area_per_molecule.py +++ b/tests/sample/elements/layers/test_layer_area_per_molecule.py @@ -27,8 +27,8 @@ def test_default(self): assert p.roughness.value == 3.3 assert str(p.roughness.unit) == 'ƅ' assert p.roughness.fixed is True - assert_almost_equal(p.material.sld, 2.268770124481328) - assert_almost_equal(p.material.isld, 0) + assert_almost_equal(p.material.sld.value, 2.268770124481328) + assert_almost_equal(p.material.isld.value, 0) assert p.material.name == 'C10H18NO8P in D2O' assert p.solvent.sld.value == 6.36 assert p.solvent.isld.value == 0 @@ -69,7 +69,7 @@ def test_from_pars_constraint(self): ) assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule.value == 50 - assert_almost_equal(p.material.sld, 0.31494833333333333) + assert_almost_equal(p.material.sld.value, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 @@ -77,10 +77,10 @@ def test_from_pars_constraint(self): assert p.solvent_fraction.value == 0.5 p.area_per_molecule = 30 assert p.area_per_molecule.value == 30 - assert_almost_equal(p.material.sld, 0.7119138888888887) + assert_almost_equal(p.material.sld.value, 0.7119138888888887) p.thickness.value = 10 assert p.thickness.value == 10 - assert_almost_equal(p.material.sld, 0.9103966666666665) + assert_almost_equal(p.material.sld.value, 0.9103966666666665) @unittest.skip('Instantiation of LayerAreaPerMolecule fails, despite working everywhere else.') def test_solvent_change(self): @@ -97,7 +97,7 @@ def test_solvent_change(self): assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule.value == 50 print(p.material) - assert_almost_equal(p.material.sld, 0.31494833333333333) + assert_almost_equal(p.material.sld.value, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 @@ -107,7 +107,7 @@ def test_solvent_change(self): p.solvent = d2o assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule.value == 50 - assert_almost_equal(p.material.sld, 3.762948333333333) + assert_almost_equal(p.material.sld.value, 3.762948333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == 6.335 @@ -127,7 +127,7 @@ def test_molecular_formula_change(self): ) assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule.value == 50 - assert_almost_equal(p.material.sld, 0.31494833333333333) + assert_almost_equal(p.material.sld.value, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 @@ -138,7 +138,7 @@ def test_molecular_formula_change(self): p.molecular_formula = 'C8O10D12P' assert p.molecular_formula == 'C8O10D12P' assert p.area_per_molecule.value == 50 - assert_almost_equal(p.material.sld, 1.3558483333333333) + assert_almost_equal(p.material.sld.value, 1.3558483333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 diff --git a/tests/sample/elements/materials/test_material_mixture.py b/tests/sample/elements/materials/test_material_mixture.py index 3c2a3f65..d3912b7d 100644 --- a/tests/sample/elements/materials/test_material_mixture.py +++ b/tests/sample/elements/materials/test_material_mixture.py @@ -15,8 +15,8 @@ def test_default(self) -> None: material_mixture = MaterialMixture() assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.186) - assert_almost_equal(material_mixture.isld, 0) + assert_almost_equal(material_mixture.sld.value, 4.186) + assert_almost_equal(material_mixture.isld.value, 0) assert str(material_mixture._sld.unit) == '1/ƅ^2' assert str(material_mixture._isld.unit) == '1/ƅ^2' @@ -24,12 +24,12 @@ def test_default_constraint(self) -> None: material_mixture = MaterialMixture() assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.186) - assert_almost_equal(material_mixture.isld, 0) + assert_almost_equal(material_mixture.sld.value, 4.186) + assert_almost_equal(material_mixture.isld.value, 0) material_mixture.material_a.sld.value = 0 material_mixture.material_b.isld.value = -1 - assert_almost_equal(material_mixture.sld, 2.093) - assert_almost_equal(material_mixture.isld, -0.5) + assert_almost_equal(material_mixture.sld.value, 2.093) + assert_almost_equal(material_mixture.isld.value, -0.5) assert str(material_mixture._sld.unit) == '1/ƅ^2' assert str(material_mixture._isld.unit) == '1/ƅ^2' @@ -38,59 +38,59 @@ def test_fraction_constraint(self): q = Material(6.908, -0.278, 'Boron') material_mixture = MaterialMixture(p, q, 0.2) assert material_mixture.fraction.value == 0.2 - assert_almost_equal(material_mixture.sld, 4.7304) - assert_almost_equal(material_mixture.isld, -0.0556) + assert_almost_equal(material_mixture.sld.value, 4.7304) + assert_almost_equal(material_mixture.isld.value, -0.0556) material_mixture._fraction.value = 0.5 assert material_mixture.fraction.value == 0.5 - assert_almost_equal(material_mixture.sld, 5.54700) - assert_almost_equal(material_mixture.isld, -0.1390) + assert_almost_equal(material_mixture.sld.value, 5.54700) + assert_almost_equal(material_mixture.isld.value, -0.1390) def test_material_a_change(self) -> None: material_mixture = MaterialMixture() assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.186) - assert_almost_equal(material_mixture.isld, 0) + assert_almost_equal(material_mixture.sld.value, 4.186) + assert_almost_equal(material_mixture.isld.value, 0) q = Material(6.908, -0.278, 'Boron') material_mixture.material_a = q assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 5.54700) - assert_almost_equal(material_mixture.isld, -0.1390) + assert_almost_equal(material_mixture.sld.value, 5.54700) + assert_almost_equal(material_mixture.isld.value, -0.1390) def test_material_b_change(self) -> None: material_mixture = MaterialMixture() assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.186) - assert_almost_equal(material_mixture.isld, 0) + assert_almost_equal(material_mixture.sld.value, 4.186) + assert_almost_equal(material_mixture.isld.value, 0) q = Material(6.908, -0.278, 'Boron') material_mixture.material_b = q assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 5.54700) - assert_almost_equal(material_mixture.isld, -0.1390) + assert_almost_equal(material_mixture.sld.value, 5.54700) + assert_almost_equal(material_mixture.isld.value, -0.1390) def test_material_b_change_double(self) -> None: material_mixture = MaterialMixture() assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.186) - assert_almost_equal(material_mixture.isld, 0) + assert_almost_equal(material_mixture.sld.value, 4.186) + assert_almost_equal(material_mixture.isld.value, 0) q = Material(6.908, -0.278, 'Boron') material_mixture.material_b = q assert material_mixture.name == 'EasyMaterial/Boron' assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 5.54700) - assert_almost_equal(material_mixture.isld, -0.1390) + assert_almost_equal(material_mixture.sld.value, 5.54700) + assert_almost_equal(material_mixture.isld.value, -0.1390) r = Material(0.00, 0.00, 'ACMW') material_mixture.material_b = r assert material_mixture.name == 'EasyMaterial/ACMW' assert material_mixture.fraction.value == 0.5 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 2.0930) - assert_almost_equal(material_mixture.isld, 0.0000) + assert_almost_equal(material_mixture.sld.value, 2.0930) + assert_almost_equal(material_mixture.isld.value, 0.0000) def test_from_pars(self): p = Material() @@ -98,8 +98,8 @@ def test_from_pars(self): material_mixture = MaterialMixture(p, q, 0.2) assert material_mixture.fraction.value == 0.2 assert str(material_mixture._fraction.unit) == 'dimensionless' - assert_almost_equal(material_mixture.sld, 4.7304) - assert_almost_equal(material_mixture.isld, -0.0556) + assert_almost_equal(material_mixture.sld.value, 4.7304) + assert_almost_equal(material_mixture.isld.value, -0.0556) assert str(material_mixture._sld.unit) == '1/ƅ^2' assert str(material_mixture._isld.unit) == '1/ƅ^2' @@ -158,7 +158,7 @@ def test_calculator_binding_uses_mixed_sld(self) -> None: mixture = MaterialMixture(material_a, material_b, fraction=0.25, interface=interface) # 2 * 0.75 + 6 * 0.25 = 1.5 + 1.5 = 3.0 - assert_almost_equal(mixture.sld, 3.0) + assert_almost_equal(mixture.sld.value, 3.0) wrapper_material = interface()._wrapper.storage['material'][mixture.unique_name] assert_almost_equal(wrapper_material.real.value, 3.0) assert_almost_equal(wrapper_material.imag.value, 0.0) @@ -173,8 +173,8 @@ def test_mutation_propagates_after_round_trip(self) -> None: global_object.map._clear() q = MaterialMixture.from_dict(p_dict) - assert_almost_equal(q.sld, 3.0) + assert_almost_equal(q.sld.value, 3.0) q.fraction = 0.8 # 2 * 0.2 + 6 * 0.8 = 0.4 + 4.8 = 5.2 - assert_almost_equal(q.sld, 5.2) + assert_almost_equal(q.sld.value, 5.2) diff --git a/tests/test_project.py b/tests/test_project.py index ec85b3f2..b1ae72eb 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -476,7 +476,7 @@ def test_as_dict_minimizer(self): project = Project() project._fitter = MagicMock() project._fitter.easy_science_multi_fitter = MagicMock() - project._fitter.easy_science_multi_fitter.minimizer = AvailableMinimizers.LMFit + project._fitter.easy_science_multi_fitter.minimizer.enum = AvailableMinimizers.LMFit # Then project_dict = project.as_dict() diff --git a/tests/test_topmost_nesting.py b/tests/test_topmost_nesting.py index 622991b2..1003efe5 100644 --- a/tests/test_topmost_nesting.py +++ b/tests/test_topmost_nesting.py @@ -47,8 +47,8 @@ def test_copy(): assert model._resolution_function.smearing(5.5) == model_copy._resolution_function.smearing(5.5) assert model.interface().name == model_copy.interface().name assert_almost_equal( - model.interface().reflectity_profile([0.3], model.unique_name), - model_copy.interface().reflectity_profile([0.3], model_copy.unique_name), + model.interface().reflectivity_profile([0.3], model.unique_name), + model_copy.interface().reflectivity_profile([0.3], model_copy.unique_name), ) assert model.unique_name != model_copy.unique_name assert model.name == model_copy.name