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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# https://github.com/PyCQA/flake8/issues/234
[flake8]
exclude = docs,venv
max-line-length = 100
max-line-length = 100
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body:
cachedir: .pytest_cache
rootdir: /root/shared
plugins: anyio-3.6.1, cov-3.0.0
collected 1 item
collected 1 item

test/test_code.py::test_addition PASSED
============================================== 1 passed in 0.01s ===============================================
Expand All @@ -49,7 +49,7 @@ body:
placeholder: i.e. "I'm Ubuntu 20.04" or "Im using Windows 11"
- type: textarea
id: extra
attributes:
attributes:
label: Additional information
description: If you have any additional information, please add it here.
placeholder: You can drag and drop files here to attach them
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Install dependencies
run: python -m pip install ".[test,docs]"

- name: Build docs
run: make doc

Expand All @@ -32,4 +32,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.PUBLISH_DIR }}
publish_dir: ${{ env.PUBLISH_DIR }}
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-docstring-first
- id: debug-statements
- id: requirements-txt-fixer

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.8.3
hooks:
- id: reorder-python-imports

- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: flake8

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.3.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.0.0
hooks:
- id: setup-cfg-fmt

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.981
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ authors:
orcid: "https://orcid.org/0000-0001-6489-8858"
title: "Template for reproducible research"
version: 0.1.0
date-released: 2022-09-13
date-released: 2022-09-13
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Contributing

To contribute to this repository:
To contribute to this repository:
1. Create a [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of the repository.
2. [Clone](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository) the forked repository.
3. Checkout a new branch (using `git checkout -b name_of_branch`), where name of branch should be replaced by `your_github_username/description_of_feature`. For instance, `jorgensd/add_guidelines`.
4. Add your contribution and push it to your fork.
5. Make a [pull request from your fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ USER root
RUN chown -R ${NB_UID} ${HOME}

USER ${NB_USER}
ENTRYPOINT []
ENTRYPOINT []
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# List of Python demos (without file extenion) from the repo `demo` to include in the jupyterbook.
# List of Python demos (without file extenion) from the repo `demo` to include in the jupyterbook.
# These files should be listed in `docs/_toc.yml`
DEMOS = demo

doc: # Generate Sphinx HTML documentation, including API docs
doc: # Generate Sphinx HTML documentation, including API docs
# We use --set-kernel with jupytext to make it possible for binder to pick it up
@for demo in ${DEMOS}; do \
jupytext --to=ipynb --set-kernel=python3 demo/$$demo.py --output=docs/$$demo.ipynb ;\
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ The documentation for this repository can be found [here](https://jorgensd.githu
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jorgensd/reproducibility/gh-pages?labpath=_sources)
[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://jorgensd.github.io/reproducibility)
[![MIT License](https://img.shields.io/github/license/jorgensd/reproducibility)](LICENSE)

4 changes: 0 additions & 4 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
#
# SPDX-License-Identifier: MIT
# -

# + [markdown]
# We start a new cell explicitly by using the "+" sign and can explicitly end
# it by using the "-" sign.
# -

# If we do not use explicit indicators for starting or ending a cell, it creates a
# new cell whenever there is a blank line

# This is a new cell

# Comments can be added to code by not adding a new line before the code
import mypackage

Expand Down
3 changes: 0 additions & 3 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ sphinx:
- 'sphinx.ext.autodoc'
- 'sphinx.ext.napoleon'
- 'sphinx.ext.viewcode'



1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parts:
- file: "part1/linting"
- file: "part1/typing"
- file: "part1/testing"
- file: "part1/pre_commit.md"

- caption: Github tools
chapters:
Expand Down
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ API Reference
=============

.. automodule:: mypackage
:members:
:members:
10 changes: 5 additions & 5 deletions docs/part1/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ We recommend using the source layout. See [this chapter](https://py-pkgs.org/04-
A [toml](https://toml.io/en/) (Tom's Obivous Minimal Language) file is a plain-text file, consisting of [tables](https://toml.io/en/v1.0.0#table)
which are a selection of key-value pairs.

An example is
An example is
```toml
[project]
name = "catch_us"
authors = [
{name = "Per Ulv", email = "per@acme.no"},
{name = "Bippe Stankelbein", email = "bippe@roadrunner.no"}
]
version = "x.y.z"
version = "x.y.z"
description = "Meep Meep"
# "readme" the description field in your package,
# "readme" the description field in your package,
# see: https://python-poetry.org/docs/pyproject/#readme
readme = "README.md"
readme = "README.md"
requires-python = ">=3.8"
# Path to license file, see: https://spdx.org/licenses/
# for a selection of licenses
Expand Down Expand Up @@ -51,4 +51,4 @@ test = ["pytest"]
Then, when installing the package, you call `pip3 install .[test]` instead of `pip3 install .` to get the additional dependencies.

### Other tables
For options related to coverage reports and code consistency, see the [Coverage](./coverage) and [Linting](./linting.md) section, respectively.
For options related to coverage reports and code consistency, see the [Coverage](./coverage) and [Linting](./linting.md) section, respectively.
21 changes: 21 additions & 0 deletions docs/part1/pre_commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Pre-commit hooks

Using pre-commit hooks is a great way to make sure that the code you commit to the repo follows some common style. This way, you will not end up changing the style back and forth when collaborating with other people.

The file `.pre-commit-config.yaml` in the root of the repo contains a set of default pre-commit hooks. You can find more hooks in the [pre-commit home page](https://pre-commit.com/hooks.html).

To install the pre-commit hook you first need to install pre-commit
```
python -m pip install pre-commit
```
and then install the pre-commit hook
```
pre-commit install
```
The pre-commit hook will only run on the files you commit to the repo. To run the pre-commit hook on all the files in your repo, you can execute the command.
```
pre-commit run --all
```

## Running pre-commit in CI
You can also run the pre-commit hooks as a part of your continuous integration. You can check out the [GitHub action](https://github.com/pre-commit/action), or you can set up at webhook using [pre-commit.ci](https://pre-commit.ci).
2 changes: 1 addition & 1 deletion docs/part1/testing.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Testing
# Testing
2 changes: 1 addition & 1 deletion docs/part1/typing.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Python typing
# Python typing
3 changes: 1 addition & 2 deletions docs/part2/citeable.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Make a repository citable
The easiest way to make your repository citable is to add a `CITATION.cff` file to the repository, as it is supported by both
The easiest way to make your repository citable is to add a `CITATION.cff` file to the repository, as it is supported by both
[Zenodo's](https://zenodo.org/) and it's [Github integration](https://docs.github.com/en/repositories/archiving-a-github-repository/referencing-and-citing-content) and [Github](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files) itself.

1 change: 0 additions & 1 deletion docs/part2/github.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Github tools

2 changes: 0 additions & 2 deletions docs/part2/issues.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Issue template
See [Adding an issue template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository) for more information.


2 changes: 1 addition & 1 deletion docs/part3/auto_api.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Auto-generation
# Auto-generation
2 changes: 1 addition & 1 deletion docs/part3/auto_demos.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ This is illustrated in the following auto-converted demo.

# Auto-conversion of demos

In the [Makefile](https://github.com/jorgensd/reproducibility/blob/main/Makefile) one can find the instructions for auto-converting the demos and building the book.
In the [Makefile](https://github.com/jorgensd/reproducibility/blob/main/Makefile) one can find the instructions for auto-converting the demos and building the book.
3 changes: 1 addition & 2 deletions docs/part3/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

## `_toc.yml`

## `_config.yml`

## `_config.yml`
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ authors = [
{name = "Jørgen S. Dokken", email = "dokken@simula.no"},
{name = "Henrik N. Finsberg", email = "henriknf@simula.no"}
]
version = "0.1.0"
version = "0.1.0"
description = "Minimal package for adding two numbers"
# "readme" the description field in your package, see: https://python-poetry.org/docs/pyproject/#readme
readme = "README.md"
readme = "README.md"
requires-python = ">=3.8"
# Path to license file, see: https://spdx.org/licenses/ for options
license = {file = "LICENSE"}
Expand Down Expand Up @@ -46,7 +46,7 @@ pypi = [
[tool.mypy]
ignore_missing_imports = true # Does not show errors when importing untyped libraries
exclude = [ # We only want mypy to consider files that are not generated in installing or building documentation
"docs/",
"docs/",
"build/"
]
files = [ # Folder to which files that should be checked by mypy
Expand All @@ -58,4 +58,4 @@ files = [ # Folder to which files that should be checked by mypy
addopts = "--cov=mypackage --cov-report html --cov-report term-missing -v"
testpaths = [
"test"
]
]
5 changes: 2 additions & 3 deletions src/mypackage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

# Copyright (C) 2022 Jørgen Schartum Dokken
#
# This file is part of my_package
# SPDX-License-Identifier: MIT

import importlib.metadata

from .functions import addition, print_add
from .functions import addition
from .functions import print_add

__version__ = importlib.metadata.version(__package__)

Expand Down
6 changes: 2 additions & 4 deletions src/mypackage/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# Copyright (C) 2022 Jørgen Schartum Dokken
#
# This file is part of mypackage
Expand All @@ -9,12 +7,12 @@


def addition(a: int, b: int) -> int:
""" Computes a+b """
"""Computes a+b"""
return a + b


def print_add(a: int, b: int) -> int:
""" Computes and prints a + b"""
"""Computes and prints a + b"""
c = a + b
print(c)
return c
1 change: 0 additions & 1 deletion test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# This file is part of my_package
# SPDX-License-Identifier: MIT

from mypackage import addition


Expand Down