Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WARNING: Do not edit this file manually.
# Any changes will be overwritten by Copier.
_commit: v0.12.0
_commit: v0.13.1-3-g44c0369
_src_path: gh:easyscience/templates
app_docs_url: https://easyscience.github.io/dynamics-app
app_doi: 10.5281/zenodo.18877180
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
fi
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_ENV"
echo "DOCS_VERSION=${DOCS_VERSION}" >> "$GITHUB_ENV"
# Artifact names cannot contain '/', so sanitize the (possibly slash-containing)
# branch name for use in the uploaded artifact name.
echo "ARTIFACT_SUFFIX=${RELEASE_VERSION//\//-}" >> "$GITHUB_ENV"

# Check out the repository source code.
# Note: The gh-pages branch is fetched separately later for mike deployment.
Expand Down Expand Up @@ -123,16 +126,19 @@ jobs:

# Build the static files for the documentation site for local inspection
# Input: docs/ directory containing the Markdown files
# Output: site/ directory containing the generated HTML files
# Output: docs/site/ directory containing the generated HTML files
# Also verifies that mkdocstrings generated docs/site/objects.inv.
- name: Build site for local check
run: pixi run docs-build-local
run: |
pixi run docs-build-local
pixi run docs-inventory-check

# Upload the static files from the site/ directory to be used for
# Upload the static files from the docs/site/ directory to be used for
# local check
- name: Upload built site as artifact
uses: ./.github/actions/upload-artifact
with:
name: site-local_easydynamics-lib-${{ env.RELEASE_VERSION }}
name: site-local_easydynamics-lib-${{ env.ARTIFACT_SUFFIX }}
path: docs/site/

# Create GitHub App token for pushing to gh-pages as easyscience[bot].
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pypi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ jobs:
frozen: false

- name: Init pixi project
run: pixi init easydynamics
run:
pixi init --platform linux-64 --platform osx-arm64 --platform win-64
easydynamics

- name: Set the minimum system requirements
- name: Configure pixi platforms
working-directory: easydynamics
run: pixi project system-requirements add macos 14.0
run: |
pixi workspace platform edit linux-64 --glibc 2.35 --no-install
pixi workspace platform edit osx-arm64 --macos 14.0 --no-install

- name: Add Python 3.14 from Conda
working-directory: easydynamics
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,16 @@ jobs:
echo "🔹🔸🔹🔸🔹 Python: $py_ver 🔹🔸🔹🔸🔹"

echo "Initializing pixi project"
pixi init easydynamics_py$py_ver
pixi init --platform linux-64 --platform osx-arm64 --platform win-64 easydynamics_py$py_ver
cd easydynamics_py$py_ver

echo "Configure pixi platforms"
pixi workspace platform edit linux-64 --glibc 2.35 --no-install
pixi workspace platform edit osx-arm64 --macos 14.0 --no-install

echo "Adding Python $py_ver"
pixi add "python=$py_ver"

echo "Setting macOS 14.0 as minimum required"
pixi project system-requirements add macos 14.0

echo "Looking for wheel in ../dist/py$py_ver/"
ls -l "../dist/py$py_ver/"

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ CMakeLists.txt.user*
.cache/
*.log
*.zip
.claude/
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/dynamics-lib/discussions)

Expand Down
79 changes: 29 additions & 50 deletions docs/docs/tutorials/analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,8 @@
"# Imports\n",
"import pooch\n",
"\n",
"from easydynamics.analysis.analysis import Analysis\n",
"from easydynamics.experiment import Experiment\n",
"from easydynamics.sample_model import BrownianTranslationalDiffusion\n",
"from easydynamics.sample_model import ComponentCollection\n",
"from easydynamics.sample_model import DeltaFunction\n",
"from easydynamics.sample_model import Gaussian\n",
"from easydynamics.sample_model import Lorentzian\n",
"from easydynamics.sample_model import Polynomial\n",
"from easydynamics.sample_model.background_model import BackgroundModel\n",
"from easydynamics.sample_model.instrument_model import InstrumentModel\n",
"from easydynamics.sample_model.resolution_model import ResolutionModel\n",
"from easydynamics.sample_model.sample_model import SampleModel\n",
"import easydynamics as edyn\n",
"import easydynamics.sample_model as sm\n",
"\n",
"%matplotlib widget"
]
Expand All @@ -47,7 +37,7 @@
"outputs": [],
"source": [
"# Load the vanadium data\n",
"vanadium_experiment = Experiment('Vanadium')\n",
"vanadium_experiment = edyn.Experiment('Vanadium')\n",
"file_path = pooch.retrieve(\n",
" url='https://github.com/easyscience/dynamics-lib/raw/refs/heads/master/docs/docs/tutorials/data/vanadium_data_example.h5',\n",
" known_hash='16cc1b327c303feeb88fb9dda5390dc4880b62396b1793f98c6fef0b27c7b873',\n",
Expand All @@ -66,34 +56,34 @@
"# Example of Analysis with a simple sample model and instrument model\n",
"# The scattering from vanadium is purely elastic, so we model it with a\n",
"# delta function\n",
"delta_function = DeltaFunction(display_name='DeltaFunction', area=1)\n",
"sample_model = SampleModel(\n",
"delta_function = sm.DeltaFunction(display_name='DeltaFunction', area=1)\n",
"sample_model = sm.SampleModel(\n",
" components=delta_function,\n",
")\n",
"\n",
"# The resolution is in this case modeled as a Gaussian. However, we can\n",
"# add as many components as we like to the resolution model\n",
"res_gauss = Gaussian(width=0.1)\n",
"res_gauss = sm.Gaussian(width=0.1)\n",
"res_gauss.area.fixed = True\n",
"resolution_components = ComponentCollection()\n",
"resolution_components = sm.ComponentCollection()\n",
"resolution_components.append_component(res_gauss)\n",
"resolution_model = ResolutionModel(components=resolution_components)\n",
"resolution_model = sm.ResolutionModel(components=resolution_components)\n",
"\n",
"# The background model is created in the same way. In this case, we use\n",
"# a flat background\n",
"background_model = BackgroundModel(components=Polynomial(coefficients=[0.001]))\n",
"background_model = sm.BackgroundModel(components=sm.Polynomial(coefficients=[0.001]))\n",
"\n",
"# We combine the resolution abd background model into an instrument\n",
"# model. This model also contains a small energy offset to account for\n",
"# instrument misalignment.\n",
"\n",
"instrument_model = InstrumentModel(\n",
"instrument_model = sm.InstrumentModel(\n",
" resolution_model=resolution_model,\n",
" background_model=background_model,\n",
")\n",
"\n",
"# Collect everything into an analysis object.\n",
"vanadium_analysis = Analysis(\n",
"vanadium_analysis = edyn.Analysis(\n",
" display_name='Vanadium Full Analysis',\n",
" experiment=vanadium_experiment,\n",
" sample_model=sample_model,\n",
Expand Down Expand Up @@ -180,7 +170,7 @@
"source": [
"# Now it's time to look at the data we want to fit. We first load the\n",
"# data\n",
"diffusion_experiment = Experiment('Diffusion')\n",
"diffusion_experiment = edyn.Experiment('Diffusion')\n",
"\n",
"file_path = pooch.retrieve(\n",
" url='https://github.com/easyscience/dynamics-lib/raw/refs/heads/master/docs/docs/tutorials/data/diffusion_data_example.h5',\n",
Expand All @@ -200,23 +190,23 @@
"# Now we set up the model, similarly to how we set up the model for the\n",
"# vanadium data.\n",
"\n",
"delta_function = DeltaFunction(display_name='DeltaFunction', area=0.2)\n",
"lorentzian = Lorentzian(display_name='Lorentzian', area=0.5, width=0.3)\n",
"component_collection = ComponentCollection(\n",
"delta_function = sm.DeltaFunction(display_name='DeltaFunction', area=0.2)\n",
"lorentzian = sm.Lorentzian(display_name='Lorentzian', area=0.5, width=0.3)\n",
"component_collection = sm.ComponentCollection(\n",
" components=[delta_function, lorentzian],\n",
")\n",
"\n",
"sample_model = SampleModel(\n",
"sample_model = sm.SampleModel(\n",
" components=component_collection,\n",
")\n",
"\n",
"background_model = BackgroundModel(components=Polynomial(coefficients=[0.001]))\n",
"background_model = sm.BackgroundModel(components=sm.Polynomial(coefficients=[0.001]))\n",
"\n",
"instrument_model = InstrumentModel(\n",
"instrument_model = sm.InstrumentModel(\n",
" background_model=background_model,\n",
")\n",
"\n",
"diffusion_analysis = Analysis(\n",
"diffusion_analysis = edyn.Analysis(\n",
" display_name='Diffusion Full Analysis',\n",
" experiment=diffusion_experiment,\n",
" sample_model=sample_model,\n",
Expand Down Expand Up @@ -265,17 +255,6 @@
"diffusion_analysis.plot_parameters(names=['Lorentzian width', 'Lorentzian area'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb226c8f",
"metadata": {},
"outputs": [],
"source": [
"# It will be possible to fit this to a DiffusionModel, but that will\n",
"# come later."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -286,26 +265,26 @@
"# Let us now fit directly to a diffusion model. We replace the\n",
"# Lorentzian with a Brownian translational diffusion model and keep the\n",
"# other parameters the same.\n",
"delta_function = DeltaFunction(display_name='DeltaFunction', area=0.2)\n",
"component_collection = ComponentCollection(\n",
"delta_function = sm.DeltaFunction(display_name='DeltaFunction', area=0.2)\n",
"component_collection = sm.ComponentCollection(\n",
" components=[delta_function],\n",
")\n",
"diffusion_model = BrownianTranslationalDiffusion(\n",
"diffusion_model = sm.BrownianTranslationalDiffusion(\n",
" display_name='Brownian Translational Diffusion', diffusion_coefficient=2.4e-9, scale=0.5\n",
")\n",
"\n",
"sample_model = SampleModel(\n",
"sample_model = sm.SampleModel(\n",
" components=component_collection,\n",
" diffusion_models=diffusion_model,\n",
")\n",
"\n",
"background_model = BackgroundModel(components=Polynomial(coefficients=[0.001]))\n",
"background_model = sm.BackgroundModel(components=sm.Polynomial(coefficients=[0.001]))\n",
"\n",
"instrument_model = InstrumentModel(\n",
"instrument_model = sm.InstrumentModel(\n",
" background_model=background_model,\n",
")\n",
"\n",
"diffusion_model_analysis = Analysis(\n",
"diffusion_model_analysis = edyn.Analysis(\n",
" display_name='Diffusion Full Analysis',\n",
" experiment=diffusion_experiment,\n",
" sample_model=sample_model,\n",
Expand Down Expand Up @@ -342,13 +321,13 @@
"outputs": [],
"source": [
"# Let us look at the fitted diffusion coefficient\n",
"diffusion_model.get_all_parameters()"
"diffusion_model.get_fittable_parameters()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "default",
"language": "python",
"name": "python3"
},
Expand All @@ -362,7 +341,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.4"
"version": "3.14.5"
}
},
"nbformat": 4,
Expand Down
28 changes: 11 additions & 17 deletions docs/docs/tutorials/analysis1d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@
"source": [
"import pooch\n",
"\n",
"import easydynamics as edyn\n",
"import easydynamics.sample_model as sm\n",
"from easydynamics.analysis.analysis1d import Analysis1d\n",
"from easydynamics.experiment import Experiment\n",
"from easydynamics.sample_model import DeltaFunction\n",
"from easydynamics.sample_model import Gaussian\n",
"from easydynamics.sample_model import Polynomial\n",
"from easydynamics.sample_model.background_model import BackgroundModel\n",
"from easydynamics.sample_model.instrument_model import InstrumentModel\n",
"from easydynamics.sample_model.resolution_model import ResolutionModel\n",
"from easydynamics.sample_model.sample_model import SampleModel\n",
"\n",
"%matplotlib widget"
]
Expand All @@ -38,7 +32,7 @@
"metadata": {},
"outputs": [],
"source": [
"vanadium_experiment = Experiment('Vanadium')\n",
"vanadium_experiment = edyn.Experiment('Vanadium')\n",
"\n",
"file_path = pooch.retrieve(\n",
" url='https://github.com/easyscience/dynamics-lib/raw/refs/heads/master/docs/docs/tutorials/data/vanadium_data_example.h5',\n",
Expand All @@ -56,18 +50,18 @@
"outputs": [],
"source": [
"# Example of Analysis1d with a simple sample model and instrument model\n",
"delta_function = DeltaFunction(display_name='DeltaFunction', area=1)\n",
"sample_model = SampleModel(\n",
"delta_function = sm.DeltaFunction(display_name='DeltaFunction', area=1)\n",
"sample_model = sm.SampleModel(\n",
" components=delta_function,\n",
")\n",
"\n",
"res_gauss = Gaussian(width=0.1)\n",
"resolution_model = ResolutionModel(components=res_gauss)\n",
"res_gauss = sm.Gaussian(width=0.1)\n",
"resolution_model = sm.ResolutionModel(components=res_gauss)\n",
"\n",
"\n",
"background_model = BackgroundModel(components=Polynomial(coefficients=[0.001]))\n",
"background_model = sm.BackgroundModel(components=sm.Polynomial(coefficients=[0.001]))\n",
"\n",
"instrument_model = InstrumentModel(\n",
"instrument_model = sm.InstrumentModel(\n",
" resolution_model=resolution_model,\n",
" background_model=background_model,\n",
")\n",
Expand All @@ -87,7 +81,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "default",
"language": "python",
"name": "python3"
},
Expand All @@ -101,7 +95,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.5"
"version": "3.14.6"
}
},
"nbformat": 4,
Expand Down
Loading