Mantid is a C++20 and Python 3.12 repository with a Qt GUI frontend. It is configured with CMake and uses pixi/conda for dependencies. The project provides tools for processing materials-science data from neutron scattering, muon spectroscopy, and simulation.
- Install pixi and activate the environment specified in
pixi.toml:pixi shell- or
eval $(pixi shell-hook)for non-interactive use
- Dependencies are tracked from a conda metapackage in
conda/recipes/mantid-developer.
- Inspect existing code, tests, and documentation before making changes.
- Keep changes focused on the requested behavior. Avoid unrelated refactors.
- Do not revert unrelated changes in the working tree.
- Prefer existing project patterns over introducing new abstractions.
- Avoid adding new dependencies unless they are necessary and justified.
- If a command fails, report the command, the relevant error, the likely cause, and the next step.
- Before summarizing work, check
git statusand review the relevantgit diff. - Final summaries should include changed files, tests run, tests not run, release note status, and documentation status.
- Configure:
- Linux:
cmake --preset=linux . && cd build/ - Windows:
cmake --preset=win-ninja . && cd build/ - macOS Apple Silicon:
cmake --preset=osx-arm64 . && cd build/
- Linux:
- If unsure which preset to use, check
CMakePresets.json. - Build (run from the build directory):
- Framework:
ninja Framework - Workbench GUI:
ninja workbench - Tests:
ninja AllTests
- Framework:
- Mantid typically uses out of source builds. If build files related to ninja and cmake cannot be found, ask the user to grant access to the external build process.
- Ninja commands are typically ran from the build directory. If using pixi, you must specify the directory containing the
pixi.tomlfile using the--manifest-pathflag. - Do not make direct changes to files in the build directory. These are generated as part of the build process.
- Mantid uses CMake to define build targets and test targets.
- When adding, moving, or removing C++ source, header, test, or resource files, update the relevant
CMakeLists.txt. - Ensure new
src,inc,test, and related files are included in the appropriate library, executable, or test target.
Agents can run both unit and system tests for Python and C++ changes.
- When making code changes, add or update test coverage for the changed behavior.
- Prefer running the smallest relevant set of tests. The full test suite is large and can take a long time.
- For C++ changes, build the relevant test target and run the corresponding test executable from the build
bindirectory. Pass a test name or filter argument where the executable supports it. - For Python changes, run the relevant Python unit test file or test case. Ensure
PYTHONPATHincludes the buildbindirectory so Mantid modules resolve correctly. - For system-level behavior, run only matching system tests with:
python Testing/SystemTests/scripts/runSystemTests.py -R <regex>
- If
pixi shellis not active, usepixi runto run tests, ensuring that conda packages are on the path. The Python executable from the active pixi environment can also be used. - Run broader
ctestor./systemtestcommands only when the change has broad impact or focused tests are insufficient. - Choose tests based on the changed behavior:
- C++ algorithm changes usually need the relevant C++ unit test executable and any matching system test.
- Python algorithm changes usually need the relevant Python unit test file or test case and any matching system test.
- GUI changes usually need the relevant model, presenter, widget, or workflow tests.
- If the build environment is unavailable, state which tests should be run and why they were not run.
- If a test is changed to make it pass, explicitly explain why the changed expectation is valid.
- Unit test standards are documented in Unit Test Standards.
- Coding standards are documented in Mantid Standards.
- Prefer targeted formatting or static checks for touched files first; run broader checks such as
pre-commit run --all-fileswhen practical.
- User documentation lives in docs.
- Developer documentation lives in dev-docs.
- New Mantid algorithms must include user-facing algorithm documentation under docs/source/algorithms.
- Algorithm documentation requirements are described in Algorithm Documentation.
- General documentation guidance is in Documentation Guide For Devs.
- For algorithm behavior or property changes, update both code-level summaries/property descriptions and the relevant
.rstdocumentation. - For GUI or workflow changes, update user documentation when users need to understand new or changed behavior.
- Release notes live under docs/source/release.
- Follow the Release Notes Guide.
- Every user-facing change must include a release note unless the guide clearly says one is not required.
- Add release notes to the next release directory, using the relevant
New_featuresorBugfixessubdirectory. - Write release notes for scientific users, not developers.
- Pure internal refactors, tests, or developer-documentation changes usually do not need release notes.
- Run
clang-tidyusing the configuration in.clang-tidywhere relevant. - Format using
pre-commit run --all-files. - Follow the PR template in .github/PULL_REQUEST_TEMPLATE.md.
- Ensure relevant tests, docs, and release notes are included before review.
- Do not include generated build or documentation outputs unless the project explicitly requires them.
.github/workflowsbuild configuration for GitHub Actions.buildconfig/Jenkinsbuild configuration for Jenkins CI.buildconfig/CMakecustom CMake modules.conda/recipesrecipes for conda packages.dev-docsdeveloper documentation.docsuser documentation and release notes.Frameworknon-GUI C++ and Python framework code.instrumentXML files describing facilities, instruments, and sample environments.qtGUI code.scriptsPython code.Testingtest data and system test framework.toolssmall tools for maintaining code and report generation.