Guidance for AI coding agents working in the Basix repository.
Basix is a finite element definition and tabulation runtime library. It has
a C++ core (cpp/) and a Python interface (python/) built with nanobind,
and is one of the FEniCSx components (alongside UFL, FFCx, DOLFINx).
Basix follows the same design and coding style as DOLFINx — when in doubt about a style or API design choice, prefer consistency with DOLFINx conventions over introducing a new pattern.
cpp/basix/— C++ core library (element definitionse-*.cpp/h, cell geometry, quadrature, polysets, interpolation, dof transformations, etc.).cpp/CMakeLists.txt— C++ library build.python/basix/— Python package (thin wrappers around the C++ core).python/basix/wrappers/basix_wrappers.cpp— nanobind bindings exposing the C++ core to Python; the shared helpers and templates live alongside it inpython/basix/wrappers/basix_wrappers/basix_wrappers.h. The header sits inside the Python package so thatwheel.packagesships it; downstream nanobind wrappers locate it withbasix.get_include().test/— Python unit tests (pytest), plustest/test_cmakeandtest/test_pkgconfigintegration tests for the installed C++ library.demo/— C++ and Python demos, also exercised in CI.doc/— Doxygen (C++) and Sphinx (Python) documentation sources.
Standard install (builds C++ and Python together):
pip install .Editable/development install:
cd python
pip -v install --check-build-dependencies -Cbuild-dir="build" \
-Ccmake.build-type="Developer" -Cinstall.strip=false \
--no-build-isolation -e .(--no-build-isolation requires build dependencies to already be installed,
e.g. via pip install --group build; see python/pyproject.toml.)
C++ only:
cd cpp
cmake -DCMAKE_BUILD_TYPE=Release -B build-dir -S .
cmake --build build-dirRequires a C++20 compiler, BLAS, and LAPACK.
Dependency groups (build, docs, lint, test, ci) use PEP 735
syntax and require pip >= 25.1 (or another PEP 735-compliant build
frontend) for the --group flag.
Python unit tests (from repo root, after installing with pip install --group test .):
pytest test/Run before opening a PR — CI enforces all of these:
ruff format . # Python formatting
ruff check . # Python linting
mypy python/basix # type checking
mypy demo/python
gersemi --check . # CMake file formatting (2-space indent, see .gersemirc)C++ formatting follows .clang-format; clang-tidy runs in CI with
WarningsAsErrors: "*" (performance checks only, see .clang-tidy).
Ruff config (pyproject.toml): line length 100, Google-style docstrings
(D rules apply outside test/, demo/, doc/).
cpp/basix/mdspan.hppis a vendored third-party header (reference implementation ofstd::mdspan) — never edit it. It's also excluded fromclang-tidyviaHeaderFilterRegexin.clang-tidy.- C++ source files use a
// Copyright (c) <years> <authors>+ FEniCS Project +SPDX-License-Identifier: MITheader block. - New finite elements go in
cpp/basix/e-<name>.{cpp,h}and are wired intoelement-families.hand the Python/nanobind wrapper as needed. - License: MIT.
INSTALL.md— detailed build/install/test instructions.CONTRIBUTING.md— PR process and linting expectations..github/workflows/pythonapp.yml— canonical CI steps (lint, build, test, docs) — the most reliable source of exact commands.- Issue tracker: https://github.com/FEniCS/basix/issues