How can we share useful functions between demonstration notebooks when I want them to be self contained?
@DavidT3 is already working on this.
Since May 13, 2026.
Assessment
This issue has not been assessed yet.
Description
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?
- Dominant language
- Python
- Stars
- 6
- Forks
- 3
- Avg merge
- 23h 20m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from heasarc/heasarc-tutorials
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
heasarc/heasarc-tutorials#317 ·
-
Villanova workshop - Write workshop overview in the index fileMay be free again @abasuzych claimed this 34 days ago, and no pull request is open. Openenhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
heasarc/heasarc-tutorials#307 · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
heasarc/heasarc-tutorials#308 ·
-
Villanova workshop - Add expansion measurement worksheetMay be free again @DavidT3 claimed this 60 days ago, and no pull request is open. Opendoc-content enhancement
heasarc/heasarc-tutorials#303 · 1 assignee ·
-
Villanova workshop - Add GIF worksheetMay be free again @DavidT3 claimed this 60 days ago, and no pull request is open. Open
heasarc/heasarc-tutorials#302 · 1 assignee ·
All issues in heasarc/heasarc-tutorials
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
OpenFreeEnergy/openfe#2371 ·
Maintainers usually reply within 2 days
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
NCATSTranslator/Babel#1269 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
404 on sample dataOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100