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 .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.ipynb filter=strip-notebook-output
*.ipynb filter=strip-notebook-output
2 changes: 1 addition & 1 deletion .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
coverage run -m pytest .
coverage report --sort=cover

- name: Test tutorials
run: |
jupyter nbconvert --to notebook --execute tutorials/*.ipynb \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ jobs:
TWINE_USERNAME: __token__ # Use API token
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*

64 changes: 10 additions & 54 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,6 @@ jobs:
./cloc --version
./cloc $(git ls-files)

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

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

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

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

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Type check with mypy
continue-on-error: true
run: |
pip install mypy
mypy src/

prospector:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -103,11 +52,18 @@ jobs:
with:
python-version: "3.11"

- name: Lint with ruff
continue-on-error: true
- name: Linting with ruff (including import sorting)
run: |
pip install ruff
ruff check src/
ruff check .

- name: Code formatting with ruff
run: ruff format --check .

- name: Check statement order
run: |
pip install ssort
ssort --check --diff .

pylint:
runs-on: ubuntu-latest
Expand Down
30 changes: 21 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # Use the latest stable version
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- 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"]

args: [--maxkb=500]
exclude: ^(uv\.lock|docs/package-lock\.json)$ # generated lock files
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
rev: 0.9.1
hooks:
- id: nbstripout # remove jupyter notebook cell output
- id: nbstripout # strip jupyter notebook output
- repo: https://github.com/bwhmather/ssort
rev: 0.17.0
hooks:
- id: ssort # order statements so names are defined before they are used
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.3
hooks:
- id: ruff-check # lint, including import sorting (the I rules)
args: [--fix]
- id: ruff-format
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,20 @@ providing access to any Matplotlib API without requiring a maxplotlib
wrapper:

``` python
canvas.plot(matplotlib_customizations={
"figure": {
"suptitle": "My figure",
},
"axes": {
"tick_params": {
"axis": "both",
"which": "major",
"length": 6,
canvas.plot(
matplotlib_customizations={
"figure": {
"suptitle": "My figure",
},
},
})
"axes": {
"tick_params": {
"axis": "both",
"which": "major",
"length": 6,
},
},
}
)
```

For dynamic customization, the same option also accepts a function:
Expand All @@ -100,6 +102,7 @@ def customize(fig, axes):
for ax in axes.flat:
ax.tick_params(axis="both", which="major", length=6)


canvas.plot(matplotlib_customizations=customize)
```

Expand Down Expand Up @@ -188,7 +191,7 @@ print(terminal_fig.build(keep_colors=False))
```

Trigonometry
Runtime
Runtime
┌┬─────────────────┬─────────────────┬─────────────────┬─────────────────┬┐
1.00┼ ▞▞ sin(x) ──▗▄▞▀▀▀▀▀▙▄▖────────────┼─────────────────┼─────────────▄▄▀▀▀┤
│ ▞▞ cos(x) ▄▀▘ │ ▝▀▄ │ │ ▄▞▀ ││
Expand All @@ -208,8 +211,8 @@ print(terminal_fig.build(keep_colors=False))
││ │ ▀▄▖ │ ▗▄▀ ▀▄▖ │ ▗▄▀▘ ││
-1.00┼┼─────────────────┼────────────▝▀▚▄▄▄▄▄▞▀▘───────▝▀▜▄▄▄▄▄▞▀▘────────────┼┤
└┼─────────────────┼─────────────────┼─────────────────┼─────────────────┼┘
0.0 1.6 3.1 4.7 6.3
Duration Time
0.0 1.6 3.1 4.7 6.3
Duration Time

Or plot with the TikZ backend:

Expand Down Expand Up @@ -283,7 +286,7 @@ ax.set_legend(True)
canvas.show(backend="plotext")
```

Terminal plot
Terminal plot
┌──────────────────────────────────────────────────────────────────────────┐
3.16┤ ▞▞ sqrt(x) ▄▞│
│ │▗▄▞▀ │
Expand All @@ -303,8 +306,8 @@ canvas.show(backend="plotext")
│┼ ▗▄▄▞▀▀▀▀▀ │
0.93┤│▀▀▘ │
└┬─────────────────┬──────────────────┬─────────────────┬─────────────────┬┘
1.0 1.8 3.2 5.6 10.0
y x
1.0 1.8 3.2 5.6 10.0
y x

<maxplotlib.backends.plotext.figure.PlotextFigure at 0x1102a0690>

Expand Down Expand Up @@ -383,7 +386,9 @@ wave = xr.DataArray(
attrs={"long_name": "Potential", "units": "V"},
)

wave.maxplot.pcolormesh(col="t", col_wrap=3, canvas_kwargs={"width": "16cm", "ratio": 0.6}).show()
wave.maxplot.pcolormesh(
col="t", col_wrap=3, canvas_kwargs={"width": "16cm", "ratio": 0.6}
).show()
```

![](README_files/figure-commonmark/cell-20-output-1.png)
Expand Down
29 changes: 17 additions & 12 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@ any Matplotlib API without requiring a maxplotlib wrapper:

```{python}
#| output: false
canvas.plot(matplotlib_customizations={
"figure": {
"suptitle": "My figure",
},
"axes": {
"tick_params": {
"axis": "both",
"which": "major",
"length": 6,
canvas.plot(
matplotlib_customizations={
"figure": {
"suptitle": "My figure",
},
},
})
"axes": {
"tick_params": {
"axis": "both",
"which": "major",
"length": 6,
},
},
}
)
```

For dynamic customization, the same option also accepts a function:
Expand All @@ -100,6 +102,7 @@ def customize(fig, axes):
for ax in axes.flat:
ax.tick_params(axis="both", which="major", length=6)


canvas.plot(matplotlib_customizations=customize)
```

Expand Down Expand Up @@ -310,7 +313,9 @@ wave = xr.DataArray(
attrs={"long_name": "Potential", "units": "V"},
)

wave.maxplot.pcolormesh(col="t", col_wrap=3, canvas_kwargs={"width": "16cm", "ratio": 0.6}).show()
wave.maxplot.pcolormesh(
col="t", col_wrap=3, canvas_kwargs={"width": "16cm", "ratio": 0.6}
).show()
```

The same works through Canvas methods, e.g. `canvas.plot(da, hue="species")`,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ canvas.plot_many(
The same canvas renders with every backend:

```python
canvas.show(backend="plotly") # an interactive Plotly figure
canvas.show(backend="plotly") # an interactive Plotly figure
canvas.show(backend="plotext") # a plot in the terminal
canvas.savefig("sine.pdf", backend="tikzfigure") # TikZ code, compiled with LaTeX
```
Expand Down
11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ docs = [
dev = [
"maxplotlibx[test,docs]",
"ruff",
"black[jupyter]",
"isort",
"jupyterlab",
"nbstripout",
"pre-commit",
Expand All @@ -53,11 +51,8 @@ dev = [
[tool.setuptools.packages.find]
where = ["src"]

[tool.black]
line-length = 88

[tool.ruff]
line-length = 88

[tool.isort]
profile = "black"
# formatting: `ruff format`; import sorting: the isort rules of `ruff check`
# an explicit rule set: ruff's default one grows between releases
lint.select = ["E4", "E7", "E9", "F", "I"]
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pytest.ini
[pytest]
addopts = -ra -q
pythonpath = src
pythonpath = src
Loading
Loading