It would be better to not rely on global variables. A simple example is found in the DMSC summer school tutorial: https://github.com/ess-dmsc-dram/dmsc-school/blob/main/5-analysis/fitting.ipynb
Activity