Skip to content

Commit

Permalink
Merge pull request #767 from AFM-SPM/ns-rse/scientific-python-pre-commit
Browse files Browse the repository at this point in the history
No substantial change to code all linting changes so merging without approval.

+ [codespell](https://github.com/codespell-project/codespell) checks spelling in code files.
+ [prettier](https://github.com/prettier/prettier) lints files other than Python.
  • Loading branch information
ns-rse authored Dec 19, 2023
2 parents 3f94eb5 + 3adbc6c commit 67e298b
Show file tree
Hide file tree
Showing 40 changed files with 268 additions and 236 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# codespell
e9f1c8fa0904d643285901110e7a026f3427dc15

# ruff - isort and numpy linting
9e0502b9cce2257d6234f118091cb75dd07c21ee
8d1729e7a4132e88562a8f6b1514a95abd8878c1
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Bug report
description: Create a report to help us improve
title: '[Bug]: '
labels: 'bug'
title: "[Bug]: "
labels: "bug"
assignees:
- ''
- ""
body:
- type: markdown
attributes:
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Feature request
description: Suggest an idea for this project
title: '[feature] : '
labels: 'enhancement'
title: "[feature] : "
labels: "enhancement"
assignees:
- ''
- ""
body:
- type: markdown
attributes:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ORDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
ARCHIVE_NAME: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}
steps:
- name: prepare-data-folder
run : mkdir 'data'
run: mkdir 'data'
- name: download-archive
run: |
curl -sL "${{ github.event.release.zipball_url }}" > "$ARCHIVE_NAME".zip
Expand All @@ -23,6 +23,6 @@ jobs:
uses: figshare/github-upload-action@v1
with:
FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }}
FIGSHARE_ENDPOINT: 'https://api.figshare.com/v2'
FIGSHARE_ENDPOINT: "https://api.figshare.com/v2"
FIGSHARE_ARTICLE_ID: 22633528
DATA_DIR: 'data'
DATA_DIR: "data"
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
tags:
- v*
workflow_dispatch: # Uncomment line if you also want to trigger action manually
workflow_dispatch: # Uncomment line if you also want to trigger action manually

jobs:
build-release:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/sphinx_docs_to_gh_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
# Uncomment if only tagged releases are to have documentation built
# tags:
# - v*
workflow_dispatch: # Uncomment line if you also want to trigger action manually
workflow_dispatch: # Uncomment line if you also want to trigger action manually

jobs:
sphinx_docs_to_gh-pages:
Expand All @@ -32,8 +32,8 @@ jobs:
# defined as it defaults to 'main'.
branch: main
dir_docs: docs
sphinxapiexclude: '../*setup* ../*tests* ../*.ipynb ../demo.py ../make_baseline.py ../jupyter_notebook_config.py ../demo_ftrs.py'
sphinxapiopts: '--separate -o . ../'
sphinxopts: ''
sphinxapiexclude: "../*setup* ../*tests* ../*.ipynb ../demo.py ../make_baseline.py ../jupyter_notebook_config.py ../demo_ftrs.py"
sphinxapiopts: "--separate -o . ../"
sphinxopts: ""
multiversion: true
multiversionopts: ''
multiversionopts: ""
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ['3.9', '3.10', '3.11']
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
27 changes: 22 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
rev: v4.5.0 # Use the ref you want to point at
hooks:
- id: check-case-conflict
- id: check-docstring-first
Expand Down Expand Up @@ -33,17 +33,34 @@ repos:
rev: v0.1.8
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix, --show-fixes ]
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.0
hooks:
- id: black
types: [python]
additional_dependencies: ['click==8.0.4']
additional_dependencies: ["click==8.0.4"]
args: ["--extend-exclude", "topostats/plotting.py"]
- id: black-jupyter

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.12.0

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
Expand All @@ -60,7 +77,7 @@ repos:

ci:
autofix_prs: true
autofix_commit_msg: '[pre-commit.ci] Fixing issues with pre-commit'
autofix_commit_msg: "[pre-commit.ci] Fixing issues with pre-commit"
autoupdate_schedule: weekly
autoupdate_commit_msg: '[pre-commit.ci] pre-commit-autoupdate'
autoupdate_commit_msg: "[pre-commit.ci] pre-commit-autoupdate"
skip: [pylint] # Optionally list ids of hooks to skip on CI
8 changes: 7 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
Expand All @@ -19,7 +25,7 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: '3.8'
version: "3.8"
install:
- method: pip
path: .
Expand Down
14 changes: 7 additions & 7 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ authors:
family-names: Pyne
email: a.l.pyne@sheffield.ac.uk
affiliation: The University of Sheffield
orcid: 'https://orcid.org/0000-0002-2658-8987'
orcid: "https://orcid.org/0000-0002-2658-8987"
- given-names: Robert
family-names: Turner
email: r.d.turner@sheffield.ac.uk
affiliation: The University of Sheffield
orcid: 'https://orcid.org/0000-0002-1353-1404'
orcid: "https://orcid.org/0000-0002-1353-1404"
- given-names: Neil
family-names: Shephard
email: n.shephard@sheffield.ac.uk
affiliation: The University of Sheffield
orcid: 'https://orcid.org/0000-0001-8301-6857'
orcid: "https://orcid.org/0000-0001-8301-6857"
- given-names: Syliva
family-names: Whittle
email: sylvia.whittle@sheffield.ac.uk
affiliation: The University of Sheffield
orcid: 'https://orcid.org/0009-0008-9164-9513'
orcid: "https://orcid.org/0009-0008-9164-9513"
- given-names: Max
family-names: Gamill
email: mcgamill1@sheffield.ac.uk
affiliation: The University of Sheffield
orcid: 'https://orcid.org/0009-0007-3250-5299'
orcid: "https://orcid.org/0009-0007-3250-5299"
- email: mdu12@sheffield.ac.uk
affiliation: The University of Sheffield
given-names: Mingxue
family-names: Du
orcid: 'https://orcid.org/0009-0008-9452-5719'
orcid: "https://orcid.org/0009-0008-9452-5719"
identifiers:
- type: doi
value: 10.15131/shef.data.22633528.v1
Expand All @@ -53,4 +53,4 @@ keywords:
license: GPL-3.0
commit: cd0ec35a5071deb7f6f8ef6dce6598a542cb059b
version: 2.1.0
date-released: '2023-05-18'
date-released: "2023-05-18"
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ status](https://results.pre-commit.ci/badge/github/AFM-SPM/TopoStats/main.svg)](

| [Installation](#installation) | [Tutorials and Examples](#tutorials-and-examples) | [Contributing](contributing.md) |
[Licence](#licence) | [Citation](#citation) |

</div>

--------------------------------------------------------------------------------
---

An AFM image analysis program to batch process data and obtain statistics from images.

Expand All @@ -37,7 +38,7 @@ There is more complete documentation on the projects [documentation website](htt

TopoStats is available via PyPI and can be installed in your Virtual Environment with...

``` bash
```bash
pip install topostats
```

Expand All @@ -54,15 +55,15 @@ A default configuration is loaded automatically and so the simplest method of pr
`run_topostats` in the same directory as your scans _after_ having activated the virtual environment in which you have
installed TopoStats

``` bash
```bash
run_topostats
```

If you have your own YAML configuration file (see [Usage : Configuring
TopoStats](https://afm-spm.github.io/TopoStats/main/usage.html#configuring_topostats)) then invoke `run_topostats` and use
the argument for `--config <config_file>.yaml` that points to your file.

``` bash
```bash
# Edit and save my_config.yaml then run TopoStats with this configuration file
run_topostats --config my_config.yaml
```
Expand All @@ -71,19 +72,19 @@ The configuration file is validated before analysis begins and if there are prob
are hopefully useful in resolving the error(s) in your modified configuration.

You can generate a sample configuration file using the `--create-config-file` argument which takes a single argument,
the name of the file to save the configuration to (e.g. `config.yaml` or `settings.yaml`). This will _not_ run any
the name of the file to save the configuration to (e.g. `config.yaml` or `settings.yaml`). This will _not_ run any
analyses but will instead write the default configuration to the file `config.yaml` in the current directory.

**NB** - This feature is only available in versions > v2.0.0 as it was introduced after v2.0.0 was released.

``` bash
```bash
run_topostats --create-config-file config.yaml
```

### Notebooks

Example Jupyter Notebooks are in have been developed that show how to use TopoStats package interactively which is
useful when you are unsure of what parameters are most suited to your scans. Other notebooks exist which show how to
useful when you are unsure of what parameters are most suited to your scans. Other notebooks exist which show how to
produce plots of the summary grain and tracing statistics or how to generate plots of scans from processed images which
saves having to run the processing again. See the documentation on
[Notebooks](https://afm-spm.github.io/TopoStats/main/notebooks.html) for further details.
Expand Down
Loading

0 comments on commit 67e298b

Please sign in to comment.