Usually if I wanted to share functions between notebooks I'd make some common.py file and add it to the system path e.g. (ripped from one of my research notebook repos):
import pandas as pd
pd.set_option('display.max_columns', 500)
import numpy as np
from astropy.units import Quantity
from astropy.cosmology import LambdaCDM
import os
# This adds the directory above to the path, allowing me to import the common functions that I've written in
# common.py - this just saves me repeating boring code and makes sure its all consistent
import sys
sys.path.insert(0, '..')
from common import xcs_cosmo, lx_norm, m_norm
import xga
from xga.relations.fit import scaling_relation_lira
However, I specifically diverged from how the Fornax notebooks work (and I think how IRSA does it) and don't use files to declare functions, instead they are defined in a collapsed section of the notebook.
Great, other than when we want multiple notebooks to have the same functions - then we have to maintain them in multiple places.
I don't have a good solution for this yet, other than post-processing the notebooks with a github action to replace any declarations of a commonly-named function when it changes in some centralized file where it is maintained?
Usually if I wanted to share functions between notebooks I'd make some common.py file and add it to the system path e.g. (ripped from one of my research notebook repos):
However, I specifically diverged from how the Fornax notebooks work (and I think how IRSA does it) and don't use files to declare functions, instead they are defined in a collapsed section of the notebook.
Great, other than when we want multiple notebooks to have the same functions - then we have to maintain them in multiple places.
I don't have a good solution for this yet, other than post-processing the notebooks with a github action to replace any declarations of a commonly-named function when it changes in some centralized file where it is maintained?