Skip to content

Commit

Permalink
BEHAVIOR: insert parity prefactor as sympy.Rational (#322)
Browse files Browse the repository at this point in the history
* DX: add doc `tox -e docnb-force` job that always executes all notebooks
  • Loading branch information
redeboer committed Sep 3, 2022
1 parent bd7bacc commit f4fc68f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
19 changes: 12 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/ampform/helicity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,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:
Expand All @@ -751,7 +751,7 @@ def __generate_amplitude_prefactor(
raw_suffix
]
if coefficient_suffix != raw_suffix:
return prefactor
return sp.Rational(prefactor)
return None


Expand Down
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4fc68f

Please sign in to comment.