Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ipynb filter=strip-notebook-output
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**

...

**To Reproduce**

...

**Expected behavior**

...

**Proposed solution**

...

**Additional context**

...
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Describe the feature**

...


**Proposed implementation**

...

**Additional context**

...
27 changes: 18 additions & 9 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
name: Python CI
name: Testing

on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel

jobs:
test:
runs-on: ubuntu-latest

# strategy:
# matrix:
# python-version: ['3.12']
steps:
- name: Check out the code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Specify the Python version, e.g., '3.8'
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install ".[dev]"

- name: Run tests
run: |
pytest # or replace with your testing command
coverage run -m pytest .
coverage report --sort=cover

- name: Test tutorials
run: |
jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300
53 changes: 53 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy docs to GitHub Pages

on:
push:
branches: ["devel", "main"] # TODO: Set to main only after release
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install ".[docs]"

- name: Build Sphinx docs
run: |
cd docs
make html

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload built docs
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html/

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Python Package

on:
push:
branches:
- main

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build the package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__ # Use API token
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*

62 changes: 62 additions & 0 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Static analysis

on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel

jobs:
static-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Download and run cloc
run: |
curl -s https://raw.githubusercontent.com/AlDanial/cloc/master/cloc > cloc
chmod +x cloc
./cloc --version
./cloc $(git ls-files)

- name: Code formatting with black
run: |
pip install black
pip install "black[jupyter]"
black --check src/
black --check tutorials/

- name: Code formatting with isort
run: |
pip install isort
isort --check src/
isort --check tutorials/

- name: Code formatting with prospector
continue-on-error: true
run: |
pip install mypy
mypy src/

- name: Code formatting with prospector
continue-on-error: true
run: |
pip install prospector
prospector src/

- name: Code formatting with ruff
continue-on-error: true
run: |
pip install ruff
ruff check src/

- name: Code formatting with pylint
continue-on-error: true
run: |
pip install pylint
pylint src/
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # Use the latest stable version
hooks:
- id: check-added-large-files # Prevent giant files from being committed.
args: ["--maxkb=1000"]
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: check-toml # Attempts to load all TOML files to verify syntax.
- id: check-yaml # Attempts to load all yaml files to verify syntax.
args: ["--unsafe"]

- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
hooks:
- id: nbstripout # remove jupyter notebook cell output
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# maxplotlib

This is a wrapper for matplotlib so I can produce figures with consistent formatting. It also has some pretty nice additions such as using layers and exporting to tikz.

Related packages: [maxtikzlib](https://github.com/max-models/maxtikzlib) and [maxtexlib](https://github.com/max-models/maxtexlib).

## Install

Create and activate python environment
Expand All @@ -16,8 +20,10 @@ Install the code and requirements with pip
pip install -e .
```

Run the code with
Additional dependencies for developers can be installed with

```
maxplotlib
```
pip install -e ".[dev]"
```

Some examples can be found in `tutorials/`
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading
Loading