
ICCS - University of Cambridge
ICCS - University of Cambridge
In scientific research, a result is:
We will use the definitions used in The Turing Way
For a result to be reproducible, it should be possible for someone else to:
Any time, anywhere!
In the context of scientific computing/analysis, we want to be able to:
By making our work reproducible, we ensure that both these things are not just possible, but straightforward!
Perception of reproducibility:

Reasons for non-reproducibility:

Other findings:
Throughout the rest of this session, we will walk through the steps that we can take to go from an ad hoc collection of scripts into a reproducible scientific workflow!
Reproducibility must haves:

git by xkcd used under cc by-nc 2.5
.git folder at the root which does all the git magic behind the scenes.Then initialise the folder
.git
A hidden .git folder has been created in your folder. This contains everything Git needs to work.
git has four main states that your files can be in:
git statusgit status
Highlights your working branch -> main
Reports commit status -> none yet
Highlights untracked files -> new.txt
Proposes adding these to git with git add
git addgit add
Moves file(s) into “Staging area” ready for commit
Commit your file to the local git repo
git commit: tells git you want to commit-m "Commit message": adds a human-readable description to the log of this commit. This is important as it tells you and others what the commit intent is.Writing meaningful commit message
There are many conventions and good practices to write good commit messages. Based on scope of the project and other factors particular conventions are chosen.
git log
Displays commits in reverse chronological order.
Includes full identifier, author and date
git log --graph shows the dependencies of commits in graph view
main branch.
1. Initially, ‘main’ points to the most recent commit.
2. Upon creation, ‘my-branch’ points to the same commit.
3. As new commits are made ‘my-branch’ updates to point to these.
git branch my-new-branchgit switch my-new-branchNote
Older versions of git may need to use checkout (-b) instead of switch (-c)
Note
You can use git switch - as a shortcut for returning to the previous branch.
Feature branching
Tip
Keep branches short-lived. Long branches with large changes become harder and harder to merge.
DON’T do this:
Our repository should only contain:
There will be some exceptions to this rule, but for the vast majority of cases it will be true.
.gitignore to automatically ignore any unwanted files
git bisect)
git worktree add --help
Hopefully, at this point in the week, you will all be comfortable with version control!
The exercises in this course will work on improving an example set of python scripts, to make them more reproducible!
These scripts are hosted on the same GitHub repository as these slides: (https://github.com/Cambridge-ICCS/ReproducibilityInComputingCourse) Specifically in the directory exercises/problem.
Tasks:
git repository on your local machinegit for version control!
numpy, Eigen
numpy 2.3.9

cargo, Julia’s Pkg, uv for Python
pixi, but conda is most available
Returning to the Python scripts, try to answer the following questions:
xarraymatplotlibnetcdf4 / h5netcdf!The last dependency is tricky, because it is not required by xarray, unless you want to read/write netcdf files! If we include the dependencies of the dependencies (e.g. numpy, which xarray and matplotlib both rely on without importing it directly in our scripts), the list is even longer!
ValueError: found the following matches with the input file in xarray's IO backends: ['netcdf4', 'h5netcdf']. But their dependencies may not be installed, see:
https://docs.xarray.dev/en/stable/user-guide/io.html
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
HadCRUT.5.0.0.0_analysis_summary-series_global_annual.ncHadCRUT.5.0.0.0_analysis_summary-series_northern-hemisphere_annual.ncHadCRUT.5.0.0.0_analysis_summary-series_southern-hemisphere_annual.ncHadCRUT.5.0.0.0_analysis_summary-series_global_monthly.ncAutomation is important in scientific computing:
By automating tasks as much as possible, we make it easier to perform the actions and produce the results we want
There are many benefits to automating workflows:
flowchart TB I[Load Data] --> A[Compute A] I --> B[Compute B] B --> C[Compute C] A --> D[Produce Plot] B --> E[Produce Plot] C --> F[Produce Plot]
Tests are your “reproducibility insurance”
Flags (hopefully) when something is dodgy in your codebase
Improve reliability and trustworthiness

tests/ directorytest_assert keyword to validate an expression is true
terminal
What if we implemented add wrong?
pytest.mark.parametrize decorator:
add(x,0) == xadd(x, y) == add(y, x)add(x, add(y, z)) == add(add(x, y), z)Easier to test this:
Than this:
In the example repository, there is a file called ‘climate_model.py’. This file contains some functions that are used in ‘plot4.py’
Task:

def energy_balanced_temperature(emissivity, albedo):
"""
The temperature of Earth assuming 0D energy balance model
Parameters
----------
emissivity: float
Effective emissivity of the Earth
albedo: float
Effective albedo of the Earth
Returns
-------
temperature: float
Temperature of Earth's surface assuming 0D energy balance model [K]
"""
return (SOLAR_CONSTANT * (1.0 - albedo) / (4.0 * emissivity * SIGMA))**0.25Tasks:
Use an documentation tool, such as Sphinx, to automate building the documentation.
The FAIR principles were first introduced for data, and later adapted for research software (FAIR4RS) 1.
FAIR stands for

Software, and its metadata, are easy for humans and machines to find.
Software, and its metadata, are retrievable via standardised protocols.
Software interoperates with other software by exchanging data and/or metadata, and/or through interaction via a application programming interfaces (APIs), described through standards.
Software is both usable (can be executed) and reusable (can be understood, modified, built upon, or incorporated into other software).
Various groups and organisations work for better reproducibility.
Conferences and journals start to ask for software, data etc. to back up research findings.
Software sustainability and research software engineering have become a thing (internationally).
But still not widely known outside of the bubble!
Peer-led consortium within the UK, international networks
National Steering Group, local and institutional groups
Training, events, engaging with stakeholders




SC (formerly Supercomputing), The International Conference for High Performance Computing Networking, Storage, and Analysis
Initiative started in 2015
Then gradually made mandatory for more categories/prizes
AD/AE committee evaluates appendices and recommends ACM badge awards
Reproducibility challenge introduced 2021
Challenge: Reproduce the results of a paper in one day!
Started in 2016 and 2017 as satellite events of OpenCon (inspired by a course by Owen Petchey)
Developed further by Anna Krystalli in her SSI fellowship
More events, a team formed, remote ReproHacks became a thing….
ReproHack Hub launched in 2021

JOSS
ReScience C
CODECHECK
ML Reproducibility Challenge
Climate Informatics Reproducibility Challenge
…
Primary benefits:
Additional benefits:
Register your interest here:


Comments