Skip to content

Commit

Permalink
Merge 6b2a99c into 17f68b0
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranAngevaare committed Feb 21, 2023
2 parents 17f68b0 + 6b2a99c commit 38c93a8
Show file tree
Hide file tree
Showing 84 changed files with 280 additions and 8,101 deletions.
9 changes: 3 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ updates:
directory: "/"
schedule:
interval: "monthly"
assignees:
- JoranAngevaare
open-pull-requests-limit: 5
# Maintain the requirements requirements folder
- package-ecosystem: "pip"
directory: "/extra_requirements"
schedule:
# Check for updates to requirements every week
interval: "daily"
interval: "monthly"
# Raise pull requests for version updates
# to pip against the `develop` branch
target-branch: "master"
open-pull-requests-limit: 15
assignees:
- JoranAngevaare
open-pull-requests-limit: 5
15 changes: 11 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ on:

jobs:
update:
name: "${{ matrix.test }}_py${{ matrix.python-version }}"
runs-on: ubuntu-latest
name: "${{matrix.os}} ${{ matrix.test }}_py${{ matrix.python-version }}"
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: False
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
os: ["ubuntu-latest" , "macos-latest" ]
python-version: [ "3.8", "3.9", "3.10", "3.11"]
test: [ 'coveralls' ]
env:
NUMBA_DISABLE_JIT: 1
Expand All @@ -29,11 +30,17 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Checkout repo
uses: actions/checkout@v3
- name: Install requirements
- name: Install latex (mac)
if: matrix.os == 'macos-latest'
run: brew install --cask basictex
- name: install latex (linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
# sudo apt install texlive-full
sudo apt install texlive texlive-latex-extra texlive-fonts-recommended dvipng cm-super
- name: install dependencies
run: |
pip install -r extra_requirements/requirements-tests.txt
python setup.py develop
- name: Test package
Expand Down
124 changes: 121 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,125 @@
# ThesisPlots

Collection of plots of dissertation thesis
Collection of plots of dissertation thesis, simplified version of the [original repository](https://github.com/JoranAngevaare/thesis_plots)

[![Coverage Status](https://coveralls.io/repos/github/JoranAngevaare/thesis_plots/badge.svg?branch=master)](https://coveralls.io/github/JoranAngevaare/thesis_plots?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/joranangevaare/thesis_plots/badge)](https://www.codefactor.io/repository/github/joranangevaare/thesis_plots)
[![Coverage Status](https://coveralls.io/repos/github/XAMS-nikhef/thesis_plots/badge.svg?branch=master)](https://coveralls.io/github/XAMS-nikhef/thesis_plots?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/XAMS-nikhef/thesis_plots/badge)](https://www.codefactor.io/repository/github/XAMS-nikhef/thesis_plots)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6527303.svg)](https://doi.org/10.5281/zenodo.6527303)


## Use case
If you want to organize your thesis plots in an easily reproducible manner, this might be a nice example for you.

**Getting started**
```
# Clone the repository to your own github account, and copy it locally (or on a cluster)
# clone the repository
git clone git@github.com:<YOUR_GITHUB_ACCOUNT>/thesis_plots.git
# install the repository and it's dependencies. You can either do this in your own or
pip install -e thesis_plots
```

Additionally, you want to setup latex such that you can use it to rended axis labels etc.
There is an example in the [pytest](https://github.com/XAMS-nikhef/thesis_plots/blob/master/.github/workflows/pytest.yml) script for `linux` and
`macos` (I'm sorry Windows users maybe you want to install a [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) anyway 😉).
The latex rendering on `macos` is still untested at the time of writing.


Now you can add new notebooks in the notebooks folder.
If you are happy with a new plot you made, you can upload it using the normal git commands:
```
cd thesis_plots
# Check which changes you made
git status
git diff
# Make a new branch
git checkout -b <NEW_PROJECT>
# Now add and commit to the repository
git add <THE FILES YOU WANT TO ADD>
git commit -m "<SOME DISCRIPTION>"
git push --set-upstream origin <NEW_PROJECT>
```
This will crate a new branch on your repository which you can now view on you page `https://github.com/<YOUR_GITHUB_ACCOUNT>/thesis_plots`

## Changing the setup
In the file ``main.py`` you can customize the default style of plots that are set by the function `setup_plt`.
The documentation on this is on [Matplotlib](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.rc.html).

## Example usage
Imagine that you made a new notebook with the following code in the notebook `notebooks/normal_distribution.ipynb`:
```python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
import thesis_plots
distribution = np.random.normal(loc = 1, scale = 2, size = (2, 100_000))

# Load your plotting style
thesis_plots.setup_plt()

# Make the plot
plt.hist2d(*distribution,
norm=LogNorm(),
bins=25,
cmap='custom_map');
plt.colorbar(label=thesis_plots.mathrm('Counts/bin'))
plt.xlabel(thesis_plots.mathrm('X (some unit)'))
plt.ylabel(thesis_plots.mathrm('Y (some unit)'))
plt.title(thesis_plots.mathrm('Normal distribution'))
```

You can upload this notebook directly (following the commands above) or you can create a new module:
```
mkdir thesis_plots/normal_distribution
touch thesis_plots/normal_distribution/normal_distribution_plot.py
touch thesis_plots/normal_distribution/__init__.py
```
In `thesis_plots/__init__.py` you would add a line `from .normal_distribution import *`.
In `touch thesis_plots/normal_distribution/__init__.py` you will import the `normal_distribution_plot.py` file similar to
```python
from . import normal_distribution_plot
from .normal_distribution_plot import *
```

And in `thesis_plots/normal_distribution/normal_distribution_plot.py` you would make a function/class for the code you just wrote
```python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
import thesis_plots

def plot_normal_distribution():
distribution = np.random.normal(loc = 1, scale = 2, size = (2, 100_000))

# Make the plot
plt.hist2d(*distribution,
norm=LogNorm(),
bins=25,
cmap='custom_map');
plt.colorbar(label=thesis_plots.mathrm('Counts/bin'))
plt.xlabel(thesis_plots.mathrm('X (some unit)'))
plt.ylabel(thesis_plots.mathrm('Y (some unit)'))
plt.title(thesis_plots.mathrm('Normal distribution'))
```

This greatly simplifies your notebook, where you can now reduce the code to:

```python
import thesis_plots
# Load your plotting style
thesis_plots.setup_plt()
thesis_plots.normal_distribution.plot_normal_distribution()
```

## Advanced features
- Every time you make (or merge) a pull request, you will test making the plots on github actions. This prevents you
from writing buggy code or forgetting to upload a data file.
- If you want to add data files, you can for instance do that in `data`, see the Lambda CDM example.
- You can setup a coverage report on `https://coveralls.io/github/<YOUR_GITHUB_USER>/thesis_plots` this allows you to view if all your code is actually used (and therefore useful)
- You can add tests in the `tests` folder, these are run as well when you commit to github.

201 changes: 0 additions & 201 deletions data/lz_limit/Fig2_NRefficiency.txt

This file was deleted.

Loading

0 comments on commit 38c93a8

Please sign in to comment.