Skip to content

Commit

Permalink
Merge pull request #341 from scipp/drop-py39
Browse files Browse the repository at this point in the history
Drop Python 3.9 and make Ruff happy
  • Loading branch information
jl-wynen authored May 22, 2024
2 parents 253d295 + 3feae9b commit 9f8066b
Show file tree
Hide file tree
Showing 109 changed files with 743 additions and 763 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: d91bf92
_commit: 78693de
_src_path: https://github.com/scipp/copier_template.git
description: Visualization library for Scipp
max_python: '3.12'
min_python: '3.9'
min_python: '3.10'
namespace_package: ''
nightly_deps: scipp
orgname: scipp
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/copier.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
name: docs_html
path: html/

- uses: JamesIves/github-pages-deploy-action@v4.5.0
- uses: JamesIves/github-pages-deploy-action@v4.6.0
if: ${{ inputs.publish }}
with:
branch: gh-pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-version-ci
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9
3.10
29 changes: 8 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,21 @@ repos:
- id: trailing-whitespace
args: [ --markdown-linebreak-ext=md ]
exclude: '\.svg'
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
hooks:
- id: nbstripout
types: [ "jupyter" ]
args: [ "--drop-empty-cells",
"--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
types: ["python"]
additional_dependencies: ["flake8-bugbear==23.9.16"]
- repo: https://github.com/pycqa/bandit
rev: 1.7.5
hooks:
- id: bandit
additional_dependencies: ["bandit[toml]"]
args: ["-c", "pyproject.toml"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: ruff
args: [ --fix ]
types_or: [ python, pyi, jupyter ]
- id: ruff-format
types_or: [ python, pyi ]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand Down
3 changes: 2 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ requirements:
- setuptools
- setuptools_scm
run:
- python>=3.9
- python>=3.10

{% for package in dependencies %}
- {% if package == "graphviz" %}python-graphviz{% else %}{{ package }}{% endif %}
{% endfor %}
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
sys.path.insert(0, os.path.abspath('.'))

# General information about the project.
project = u'Plopp'
copyright = u'2024 Scipp contributors'
author = u'Scipp contributors'
project = 'Plopp'
copyright = '2024 Scipp contributors'
author = 'Scipp contributors'

html_show_sourcelink = True

Expand Down
2 changes: 1 addition & 1 deletion docs/developer/coding-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Code formatting

There are no explicit code formatting conventions since we use `black` to enforce a format.
There are no explicit code formatting conventions since we use `ruff` to enforce a format.

## Docstring format

Expand Down
2 changes: 1 addition & 1 deletion docs/developer/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Alternatively, if you want a different workflow, take a look at ``tox.ini`` or `
Run the tests using
```sh
tox -e py39
tox -e py310
```
(or just `tox` if you want to run all environments).
Expand Down
14 changes: 6 additions & 8 deletions docs/gallery/interactive-masking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"source": [
"%matplotlib widget\n",
"import plopp as pp\n",
"import scipp as sc\n",
"import numpy as np"
"import scipp as sc"
]
},
{
Expand Down Expand Up @@ -170,8 +169,6 @@
},
"outputs": [],
"source": [
"from plopp.widgets import Box\n",
"\n",
"data_node = pp.Node(da)\n",
"\n",
"\n",
Expand All @@ -195,7 +192,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fcf38064-eafe-407e-818c-e3516bd33195",
"id": "c3c1343d-845b-4a1f-9f28-978837169aa1",
"metadata": {
"editable": true,
"nbsphinx": "hidden",
Expand All @@ -206,15 +203,15 @@
},
"outputs": [],
"source": [
"from ipywidgets import HBox\n",
"\n",
"r.value = True\n",
"\n",
"r._tool.click(50, 200)\n",
"r._tool.click(200, 250)\n",
"r._tool.click(30, 50)\n",
"r._tool.click(250, 170)\n",
"\n",
"from ipywidgets import HBox\n",
"\n",
"fig.children = [\n",
" fig.top_bar,\n",
" HBox([fig.left_bar, fig.canvas.to_image(), fig.right_bar]),\n",
Expand Down Expand Up @@ -320,7 +317,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/gallery/masking-a-range.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"%matplotlib widget\n",
"import plopp as pp\n",
"import scipp as sc\n",
"import numpy as np\n",
"import ipywidgets as ipw"
]
},
Expand Down Expand Up @@ -180,7 +179,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions docs/gallery/peeling-layers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"outputs": [],
"source": [
"import plopp as pp\n",
"import scipp as sc\n",
"import numpy as np"
"import scipp as sc"
]
},
{
Expand Down Expand Up @@ -129,7 +128,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
8 changes: 5 additions & 3 deletions docs/gallery/polar-plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"\n",
"# Make the plot and tweak the axes\n",
"p = pp.plot(da, ax=ax)\n",
"ax.set_xlim(0, 2*np.pi)\n",
"ax.set_xlim(0, 2 * np.pi)\n",
"ax.grid(True)\n",
"p"
]
Expand Down Expand Up @@ -147,8 +147,10 @@
"phi = np.radians(np.linspace(0, 90, N))\n",
"da = sc.DataArray(\n",
" data=sc.array(dims=['phi', 'theta'], values=r, unit='m'),\n",
" coords={'theta': sc.array(dims=['theta'], values=theta, unit='rad'),\n",
" 'phi': sc.array(dims=['phi'], values=phi, unit='rad')},\n",
" coords={\n",
" 'theta': sc.array(dims=['theta'], values=theta, unit='rad'),\n",
" 'phi': sc.array(dims=['phi'], values=phi, unit='rad'),\n",
" },\n",
")\n",
"\n",
"# Make axes\n",
Expand Down
27 changes: 19 additions & 8 deletions docs/gallery/rectangle-selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
{
"cell_type": "markdown",
"id": "da024b16-3a9d-4761-983b-ecb94ef192ad",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"# Rectangle selection\n",
"\n",
Expand All @@ -27,8 +33,7 @@
"source": [
"%matplotlib widget\n",
"import plopp as pp\n",
"import scipp as sc\n",
"import numpy as np"
"import scipp as sc"
]
},
{
Expand Down Expand Up @@ -161,21 +166,26 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4b0f4619-6d13-4acf-867e-36ae9f234040",
"id": "8a372fcb-ffdf-47af-84b3-588926391e8d",
"metadata": {
"nbsphinx": "hidden"
"editable": true,
"nbsphinx": "hidden",
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"from ipywidgets import HBox\n",
"\n",
"r.value = True\n",
"\n",
"r._tool.click(50, 200)\n",
"r._tool.click(200, 250)\n",
"r._tool.click(30, 50)\n",
"r._tool.click(250, 170)\n",
"\n",
"from ipywidgets import HBox\n",
"\n",
"f1 = box[0]\n",
"f1.children = [\n",
" f1.top_bar,\n",
Expand Down Expand Up @@ -245,7 +255,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
24 changes: 15 additions & 9 deletions docs/gallery/tiled-random-samples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"import numpy as np\n",
"import scipp as sc\n",
"import plopp as pp\n",
"from typing import Callable, Generator"
"from collections.abc import Callable, Generator"
]
},
{
Expand Down Expand Up @@ -49,21 +49,26 @@
" np.random.wald: {'mean': [1], 'scale': [16, 32, 64]},\n",
" np.random.weibull: {'a': [2, 4, 8, 16]},\n",
" np.random.f: {'dfnum': [100], 'dfden': [100]},\n",
" np.random.rayleigh: {'scale': [2, 3, 4]}\n",
" np.random.rayleigh: {'scale': [2, 3, 4]},\n",
"}\n",
"\n",
"\n",
"def generate_kwargs(arguments_map: dict[str, list]) -> Generator[dict, None, None]:\n",
" from itertools import product\n",
"\n",
" key_arg_pairs = [[(key, val) for val in values] for key, values in arguments_map.items()]\n",
" key_arg_pairs = [\n",
" [(key, val) for val in values] for key, values in arguments_map.items()\n",
" ]\n",
" for arguments in product(*key_arg_pairs):\n",
" yield {str(args[0]): args[1] for args in arguments}\n",
"\n",
"\n",
"def key_arg_name(key: str, arg) -> str:\n",
" return \": \".join([key, str(arg)])\n",
"\n",
"\n",
"def keys_args_name(**kwargs) -> str:\n",
" return \",\".join([key_arg_name(key, arg) for key, arg in kwargs.items()])\n"
" return \",\".join([key_arg_name(key, arg) for key, arg in kwargs.items()])"
]
},
{
Expand All @@ -75,18 +80,19 @@
"# Collect samples\n",
"def sample_and_hist(pdf: Callable, size: int, **kwargs):\n",
" samples = sc.array(dims=['event'], values=pdf(size=size, **kwargs), unit='1')\n",
" \n",
" return samples.hist(event=10)/len(samples)\n",
"\n",
"plots = dict()\n",
" return samples.hist(event=10) / len(samples)\n",
"\n",
"\n",
"plots = {}\n",
"\n",
"for pdf, arguments_map in pdf_maps.items():\n",
" hists = {\n",
" keys_args_name(**kwargs): sample_and_hist(pdf, size=10_000, **kwargs)\n",
" for kwargs in generate_kwargs(arguments_map) \n",
" for kwargs in generate_kwargs(arguments_map)\n",
" }\n",
" plot = pp.plot(hists, title=f\"{pdf.__name__} distribution\", alpha=0.8, linewidth=4)\n",
" plots[pdf.__name__] = plot\n"
" plots[pdf.__name__] = plot"
]
},
{
Expand Down
Loading

0 comments on commit 9f8066b

Please sign in to comment.