diff --git a/docs/conf.py b/docs/conf.py index 34966c2d0..c82f0849b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -338,16 +338,21 @@ def get_minor_version(package_name: str) -> str: "https://suchung.web.cern.ch", ] + # Settings for myst_nb +def get_execution_mode() -> str: + if "FORCE_EXECUTE_NB" in os.environ: + print("\033[93;1mWill run ALL Jupyter notebooks!\033[0m") + return "force" + if "EXECUTE_NB" in os.environ: + return "cache" + return "off" + + +nb_execution_mode = get_execution_mode() nb_execution_timeout = -1 nb_output_stderr = "remove" - -nb_execution_mode = "off" -EXECUTE_NB = False -if "EXECUTE_NB" in os.environ: - print("\033[93;1mWill run Jupyter notebooks!\033[0m") - EXECUTE_NB = True - nb_execution_mode = "cache" +EXECUTE_NB = nb_execution_mode != "off" # Settings for myst-parser myst_enable_extensions = [ diff --git a/src/ampform/helicity/__init__.py b/src/ampform/helicity/__init__.py index 398e77cd4..642524e3d 100644 --- a/src/ampform/helicity/__init__.py +++ b/src/ampform/helicity/__init__.py @@ -540,7 +540,7 @@ def __generate_helicity_coupling( def __generate_amplitude_prefactor( self, transition: StateTransition - ) -> float | None: + ) -> sp.Rational | None: prefactor = get_prefactor(transition) if prefactor != 1.0: for node_id in transition.topology.nodes: @@ -552,7 +552,7 @@ def __generate_amplitude_prefactor( raw_suffix ] if coefficient_suffix != raw_suffix: - return prefactor + return sp.Rational(prefactor) return None diff --git a/tox.ini b/tox.ini index db350826b..330bed006 100644 --- a/tox.ini +++ b/tox.ini @@ -100,6 +100,20 @@ commands = -b html \ docs/ docs/_build/html +[testenv:docnb-force] +description = + Execute ALL Jupyter notebooks and build documentation with Sphinx +allowlist_externals = + sphinx-build +passenv = + READTHEDOCS_VERSION + TERM +setenv = + FORCE_EXECUTE_NB = yes + PYTHONHASHSEED = 0 +commands = + sphinx-build -nW --keep-going -b html docs/ docs/_build/html + [testenv:jcache] description = Inspect Jupyter cache