Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
766e920
[skip ci] add notebook tests to github worflow, fix some notebook errors
mj-gomes Jul 13, 2026
82b229b
test workflow
mj-gomes Jul 13, 2026
62f6c8a
fix psi computation in ecliptic->galactic pointing rotation
mj-gomes Jul 15, 2026
00397fc
Merge remote-tracking branch 'origin/fix_e2g_psi_rotation' into add_n…
mj-gomes Jul 16, 2026
af9adb9
merge the changes in coordinates.py from PR543 and revert changes in …
mj-gomes Jul 16, 2026
410029d
update notebooks with w.r.t previous commit, reduce size of mock jone…
mj-gomes Jul 16, 2026
4a6c22c
some ruff formatting on the notebooks
mj-gomes Jul 16, 2026
0679bf1
change jones params file to .csv to prevent deformatting
mj-gomes Jul 16, 2026
c489f6f
format
mj-gomes Jul 16, 2026
2ce9d21
push forgotten changed file
mj-gomes Jul 16, 2026
a267258
[skipci] remove mpi from notebooks workflow
mj-gomes Jul 16, 2026
2a13528
[skipci] make skipci command also ignore notebook tests
mj-gomes Jul 16, 2026
24d4c0e
[skipnb] test skipnb and remove exclude from worflow
mj-gomes Jul 16, 2026
d5fb8ab
reduce notebook sims duration to make tests faster
mj-gomes Jul 16, 2026
023e6e2
add ignore ty error in notebook, reduce time of convolution notebook
mj-gomes Jul 16, 2026
fae0a7e
restore coordinates rotation from master branch
mj-gomes Sep 3, 2026
2aef601
restore changed tests
mj-gomes Sep 3, 2026
cad7a33
[skipci] re-render notebooks with correct outputs
mj-gomes Sep 3, 2026
3550fa3
Merge branch 'master' into add_notebooks_to_github_actions
mj-gomes Sep 3, 2026
e5e867c
Drop metadata from notebooks
ggalloni Sep 17, 2026
946eccf
Trim notebook and jobs
ggalloni Sep 17, 2026
9801d72
Ignore notebooks for docs
ggalloni Sep 17, 2026
0c485b1
Add deps to render notebooks in docs
ggalloni Sep 17, 2026
323fe1f
Add notebooks to docs
ggalloni Sep 17, 2026
9b1ca1c
Drop metadata
ggalloni Sep 17, 2026
3db79da
Update deps
ggalloni Sep 17, 2026
e6efccc
Ignore outputs of doctests
ggalloni Sep 17, 2026
657cf84
Drop comment
ggalloni Sep 17, 2026
016bbff
[skipci] Avoid notebooks to write cache
ggalloni Sep 17, 2026
d943d66
[skipci] Simplify workflow
ggalloni Sep 17, 2026
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
75 changes: 75 additions & 0 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Notebook Tests

on: [push]

jobs:
tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest]
mpi: ["none"]
python: ["3.10"]

# Only run notebook tests if there is no [skipnb] or [skip nb] in the commit message
if: |
!startsWith(github.event.head_commit.message, '[skip nb]') &&
!startsWith(github.event.head_commit.message, '[skipnb]') &&
!startsWith(github.event.head_commit.message, '[skip ci]') &&
!startsWith(github.event.head_commit.message, '[skipci]')

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}
enable-cache: true
save-cache: false
prune-cache: false
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Restore virtual environment
uses: actions/cache/restore@v6
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }}

- name: Restore PySM3 data files
id: cache-pysm3
uses: actions/cache/restore@v6
with:
path: ~/pysm3-data
key: pysm3-data-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}

- name: Register PySM3 data path
run: |
echo "PYSM_LOCAL_DATA=$HOME/pysm3-data" >> $GITHUB_ENV

- name: Download PySM3 data files
if: steps.cache-pysm3.outputs.cache-hit != 'true'
run: git clone --depth 1 https://github.com/galsci/pysm-data "$PYSM_LOCAL_DATA"

- name: Install basic dependencies (FFTW, IMO)
run: |
./bin/install-deps.sh ${{ matrix.mpi }}
mkdir -p $HOME/.config/litebird_imo
echo -e "[[repositories]]\nlocation = \"$(pwd)/test/mock_imo/\"\nname = \"Mock IMO\"" | tee $HOME/.config/litebird_imo/imo.toml

- name: Install litebird_sim dependencies
run: uv sync --extra dev --extra docs --locked
env:
DUCC0_OPTIMIZATION: none

- name: Notebook Tests
run: uv run python -m pytest --nbmake -n auto --durations=5 -vv notebooks/*.ipynb
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ singularity/*.img

# The documentation converted to any format should not be committed
docs/build/
# Written by the doctests in docs/source/tutorial.rst
docs/tut02/
# Notebooks copied in by docs/source/conf.py
docs/source/tutorials/

# Claude Code stuff
/.claude
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ repos:
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
- repo: https://github.com/kynan/nbstripout
# Keeps the notebook outputs (they are what gets rendered in the docs) but
# strips execution counts and kernel metadata, which otherwise churn on every
# re-run and make notebook diffs unreadable.
rev: 0.9.1
hooks:
- id: nbstripout
args: ["--keep-output", "--extra-keys", "metadata.kernelspec metadata.language_info.version"]
10 changes: 10 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import shutil
import sys
from pathlib import Path

sys.path.insert(0, os.path.abspath(os.path.join("..", "..")))
sys.path.append(str(Path("_ext").resolve()))

_notebook_src = Path(__file__).parent.parent.parent / "notebooks"
_notebook_dst = Path(__file__).parent / "tutorials"
_notebook_dst.mkdir(exist_ok=True)
for _nb in _notebook_src.glob("*.ipynb"):
shutil.copy2(_nb, _notebook_dst / _nb.name)

# -- Project information -----------------------------------------------------

project = "LBS"
Expand All @@ -40,8 +47,11 @@
"sphinx.ext.napoleon",
"sphinxcontrib.contentui",
"matplotlib.sphinxext.plot_directive",
"myst_nb",
]

nb_execution_mode = "off"

bibtex_bibfiles = ["refs.bib"]


Expand Down
4 changes: 2 additions & 2 deletions docs/source/hwp_sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ Examples
-------------

Examples can be seen in the notebooks:
1 - `Performing a simulation with explicit HWP harmonics expansion <https://github.com/litebird/litebird_sim/blob/master/notebooks/litebird_sim_hwp_harmonics_example.ipynb>`_
2 - `Performing band integration with a Jones Matrix <https://github.com/litebird/litebird_sim/blob/master/notebooks/litebird_sim_hwp_band_integration.ipynb>`_
1 - :doc:`Performing a simulation with explicit HWP harmonics expansion <tutorials/litebird_sim_hwp_harmonics_example>`
2 - :doc:`Performing band integration with a Jones Matrix <tutorials/litebird_sim_hwp_band_integration>`



Expand Down
16 changes: 16 additions & 0 deletions docs/source/notebooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. _tutorial_notebooks:

Example notebooks
=================

The following Jupyter notebooks are shipped in the ``notebooks/`` folder of
the repository. They are rendered here with the outputs produced when they
were last run, and they are executed on every push by the ``Notebook Tests``
workflow, so the code in them is guaranteed to run against the current
version of the framework.

.. toctree::
:maxdepth: 1
:glob:

tutorials/*
1 change: 1 addition & 0 deletions docs/source/part6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Tutorials
:maxdepth: 1

tutorial.rst
notebooks.rst
7 changes: 4 additions & 3 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Tutorial
This section contains a short tutorial that describes how to get ready
to use the framework. It assumes that you have already installed the
``litebird_sim`` framework; refer to :ref:`installation_procedure`.
For a nice and exhaustive example on how to use the framework in the
LiteBIRD case see the `example notebook <https://github.com/litebird
/litebird_sim/blob/master/notebooks/litebird_sim_example.ipynb>`_.
For a nice and exhaustive example on how to use the framework in the
LiteBIRD case see :doc:`the example notebook
<tutorials/litebird_sim_example>`, and :ref:`tutorial_notebooks` for the
other notebooks shipped with the framework.

A «Hello world» example
-----------------------
Expand Down
Loading