Debug mode in PyTensor

Finally, getting back to the PyTensor tracebak, the relevant lines you want to zoom in when you see such an error are these (I reran your first example):

 File "/home/ricardo/miniconda3/envs/colgate-shelf-sow2/lib/python3.11/site-packages/pytensor/tensor/random/basic.py", line 375, in rng_fn_scipy
    return stats.halfnorm.rvs(loc, scale, random_state=rng, size=size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ricardo/miniconda3/envs/colgate-shelf-sow2/lib/python3.11/site-packages/scipy/stats/_distn_infrastructure.py", line 1057, in rvs
    raise ValueError(message)
ValueError: Domain error in arguments. The `scale` parameter must be positive for all distributions, and many distributions have restrictions on shape parameters. Please see the `scipy.stats.halfnorm` documentation for details.
Apply node that caused the error: halfnormal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(<Generator(PCG64) at 0x7FA1EC6DBD80>), [], 11, 0.0, -1)

Which you can reproduce manually

import scipy.stats as st

st.halfnorm.rvs(0, -1)