Skip to content

Commit 53cbc93

Browse files
committed
fix: improve Handles class, and add pre-commit command to Makefile
1 parent 27711ca commit 53cbc93

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
run-pre-commit-ruff-black:
2+
uv run pre-commit run --all-files
13
run-local-mkdocs-server:
24
uv run mkdocs serve

examples/violin-plot.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"\n",
7676
"\n",
7777
"# === True value plot ===\n",
78-
"(mu_plot,) = ax.plot(t, mu_arr, \"rx\", label=r\"True Voltage $v_\\text{true}(t)$\")\n",
78+
"mu_plot = ax.plot(t, mu_arr, \"rx\", label=r\"True Voltage $v_\\text{true}(t)$\")\n",
7979
"# Add true value plot to handles for legend\n",
8080
"handles.append(mu_plot)\n",
8181
"\n",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "physics-plot"
3-
version = "0.1.0.post3"
3+
version = "0.2.0"
44
description = "matplotlib styles and utils"
55
readme = "README.md"
66
authors = [

src/physics_plot/utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ def __init__(self, *args):
1111
"""
1212
super().__init__(*args)
1313

14+
def append(self, object):
15+
"""Append an object to the handle list.
16+
If the object is a single-element list, append its only element
17+
instead.
18+
19+
Parameters
20+
----------
21+
object : Any
22+
Object to append to the handle list.
23+
24+
Returns
25+
-------
26+
None
27+
"""
28+
if isinstance(object, list) and len(object) == 1:
29+
super().append(object[0])
30+
else:
31+
super().append(object)
32+
1433
def append_violinplot(self, violinplot, label):
1534
"""Append a legend patch constructed from a violin plot.
1635

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)