Skip to content

Commit 3828f07

Browse files
authored
Merge branch 'main' into refactor/ultra-colorbar
2 parents 2fee9c4 + e92fe33 commit 3828f07

60 files changed

Lines changed: 813 additions & 46 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-ultraplot.yml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,22 @@ jobs:
135135
echo "TEST_NODEIDS=${TEST_NODEIDS}"
136136
# Save PR-selected nodeids for reuse after checkout (if provided)
137137
if [ "${TEST_MODE}" = "selected" ] && [ -n "${TEST_NODEIDS}" ]; then
138-
printf "%s\n" ${TEST_NODEIDS} > /tmp/pr_selected_nodeids.txt
138+
python -c 'import json, os
139+
raw = os.environ.get("TEST_NODEIDS", "").strip()
140+
nodeids = []
141+
if raw and raw != "[]":
142+
try:
143+
parsed = json.loads(raw)
144+
except json.JSONDecodeError:
145+
parsed = raw.split()
146+
if isinstance(parsed, str):
147+
parsed = [parsed]
148+
if isinstance(parsed, list):
149+
nodeids = [item for item in parsed if isinstance(item, str) and item]
150+
with open("/tmp/pr_selected_nodeids.txt", "w", encoding="utf-8") as fh:
151+
for nodeid in nodeids:
152+
fh.write(f"{nodeid}\n")
153+
print(f"Selected nodeids parsed: {len(nodeids)}")'
139154
else
140155
: > /tmp/pr_selected_nodeids.txt
141156
fi
@@ -152,26 +167,22 @@ jobs:
152167
python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
153168
if [ "${TEST_MODE}" = "selected" ] && [ -s /tmp/pr_selected_nodeids.txt ]; then
154169
status=0
155-
filter_nodeids() {
156-
local filtered=""
157-
for nodeid in $(cat /tmp/pr_selected_nodeids.txt); do
158-
local path="${nodeid%%::*}"
159-
if [ -f "$path" ]; then
160-
filtered="${filtered} ${nodeid}"
161-
fi
162-
done
163-
echo "${filtered}"
164-
}
165-
FILTERED_NODEIDS="$(filter_nodeids)"
166-
echo "FILTERED_NODEIDS_BASE=${FILTERED_NODEIDS}"
167-
if [ -z "${FILTERED_NODEIDS}" ]; then
170+
mapfile -t FILTERED_NODEIDS < <(
171+
while IFS= read -r nodeid; do
172+
[ -z "$nodeid" ] && continue
173+
path="${nodeid%%::*}"
174+
[ -f "$path" ] && printf '%s\n' "$nodeid"
175+
done < /tmp/pr_selected_nodeids.txt
176+
)
177+
echo "FILTERED_NODEIDS_BASE_COUNT=${#FILTERED_NODEIDS[@]}"
178+
if [ "${#FILTERED_NODEIDS[@]}" -eq 0 ]; then
168179
echo "No valid nodeids found on base; skipping baseline generation."
169180
else
170181
echo "=== Memory before baseline generation ===" && free -h
171182
pytest -n ${PYTEST_WORKERS} --dist loadfile --tb=short --disable-warnings -W ignore \
172183
--mpl-generate-path=./ultraplot/tests/baseline/ \
173184
--mpl-default-style="./ultraplot.yml" \
174-
${FILTERED_NODEIDS} || status=$?
185+
"${FILTERED_NODEIDS[@]}" || status=$?
175186
echo "=== Memory after baseline generation ===" && free -h
176187
if [ "$status" -eq 4 ] || [ "$status" -eq 5 ]; then
177188
echo "No tests collected from selected nodeids on base; skipping baseline generation."
@@ -213,19 +224,15 @@ jobs:
213224
echo "TEST_NODEIDS=${TEST_NODEIDS}"
214225
if [ "${TEST_MODE}" = "selected" ] && [ -s /tmp/pr_selected_nodeids.txt ]; then
215226
status=0
216-
filter_nodeids() {
217-
local filtered=""
218-
for nodeid in $(cat /tmp/pr_selected_nodeids.txt); do
219-
local path="${nodeid%%::*}"
220-
if [ -f "$path" ]; then
221-
filtered="${filtered} ${nodeid}"
222-
fi
223-
done
224-
echo "${filtered}"
225-
}
226-
FILTERED_NODEIDS="$(filter_nodeids)"
227-
echo "FILTERED_NODEIDS_PR=${FILTERED_NODEIDS}"
228-
if [ -z "${FILTERED_NODEIDS}" ]; then
227+
mapfile -t FILTERED_NODEIDS < <(
228+
while IFS= read -r nodeid; do
229+
[ -z "$nodeid" ] && continue
230+
path="${nodeid%%::*}"
231+
[ -f "$path" ] && printf '%s\n' "$nodeid"
232+
done < /tmp/pr_selected_nodeids.txt
233+
)
234+
echo "FILTERED_NODEIDS_PR_COUNT=${#FILTERED_NODEIDS[@]}"
235+
if [ "${#FILTERED_NODEIDS[@]}" -eq 0 ]; then
229236
echo "No valid nodeids found on PR branch; skipping image comparison."
230237
exit 0
231238
else
@@ -236,7 +243,7 @@ jobs:
236243
--mpl-results-path=./results/ \
237244
--mpl-generate-summary=html \
238245
--mpl-default-style="./ultraplot.yml" \
239-
${FILTERED_NODEIDS} || status=$?
246+
"${FILTERED_NODEIDS[@]}" || status=$?
240247
echo "=== Memory after image comparison ===" && free -h
241248
if [ "$status" -eq 4 ] || [ "$status" -eq 5 ]; then
242249
echo "No tests collected from selected nodeids; skipping image comparison."

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
run: |
7575
if [ "${{ github.event_name }}" != "pull_request" ]; then
7676
echo "mode=full" >> $GITHUB_OUTPUT
77-
echo "tests=" >> $GITHUB_OUTPUT
77+
echo "tests=[]" >> $GITHUB_OUTPUT
7878
exit 0
7979
fi
8080
@@ -104,7 +104,7 @@ jobs:
104104
import json
105105
data = json.load(open(".ci/selection.json", "r", encoding="utf-8"))
106106
print(f"mode={data['mode']}")
107-
print("tests=" + " ".join(data.get("tests", [])))
107+
print("tests=" + json.dumps(data.get("tests", []), separators=(",", ":")))
108108
PY
109109
cat .ci/selection.out >> $GITHUB_OUTPUT
110110

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ ci:
1111

1212
repos:
1313
- repo: https://github.com/psf/black-pre-commit-mirror
14-
rev: 25.12.0
14+
rev: 26.1.0
1515
hooks:
1616
- id: black

docs/2dplots.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@
344344
ax.pcolormesh(data, cmap="magma", colorbar="b")
345345
ax = fig.subplot(gs[1], title="Logarithmic normalizer with norm='log'")
346346
ax.pcolormesh(data, cmap="magma", norm="log", colorbar="b")
347+
fig.show()
347348

348349

349350
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -431,6 +432,7 @@
431432
ax.colorbar(m, loc="b")
432433
ax.format(title=f"{mode.title()}-skewed + {fair} scaling")
433434
i += 1
435+
fig.show()
434436

435437
# %% [raw] raw_mimetype="text/restructuredtext"
436438
# .. _ug_discrete:
@@ -531,6 +533,7 @@
531533
colorbar="b",
532534
colorbar_kw={"locator": 180},
533535
)
536+
fig.show()
534537

535538
# %% [raw] raw_mimetype="text/restructuredtext" tags=[]
536539
# .. _ug_autonorm:

docs/basics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
# fig = uplt.figure(suptitle='Single subplot') # equivalent to above
8787
# ax = fig.subplot(xlabel='x axis', ylabel='y axis')
8888
ax.plot(data, lw=2)
89+
fig.show()
8990

9091

9192
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -184,6 +185,7 @@
184185
ylabel="ylabel",
185186
)
186187
axs[2].plot(data, lw=2)
188+
fig.show()
187189
# fig.save('~/example2.png') # save the figure
188190
# fig.savefig('~/example2.png') # alternative
189191

@@ -301,6 +303,7 @@
301303
axs[1, :1].format(fc="sky blue")
302304
axs[-1, -1].format(fc="gray4", grid=False)
303305
axs[0].plot((state.rand(50, 10) - 0.5).cumsum(axis=0), cycle="Grays_r", lw=2)
306+
fig.show()
304307

305308

306309
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -361,6 +364,7 @@
361364
suptitle="Quick plotting demo",
362365
)
363366
fig.colorbar(m, loc="b", label="label")
367+
fig.show()
364368

365369

366370
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -565,3 +569,4 @@
565569
for ax, style in zip(axs, styles):
566570
ax.format(style=style, xlabel="xlabel", ylabel="ylabel", title=style)
567571
ax.plot(data, linewidth=3)
572+
fig.show()

docs/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# Import statements
1515
import datetime
16+
import logging
1617
import os
1718
import re
1819
import subprocess
@@ -78,18 +79,25 @@ def __getattr__(self, name):
7879
except Exception:
7980
pass
8081

82+
# Silence font discovery warnings like "findfont: Font family ..."
83+
for _logger_name in ("matplotlib", "matplotlib.font_manager"):
84+
_logger = logging.getLogger(_logger_name)
85+
_logger.setLevel(logging.ERROR)
86+
_logger.propagate = False
87+
8188
# Suppress deprecated rc key warnings from local configs during docs builds.
8289
try:
8390
from ultraplot.internals.warnings import UltraPlotWarning
8491

92+
warnings.filterwarnings("ignore")
8593
warnings.filterwarnings(
8694
"ignore",
87-
message=r"The rc setting 'colorbar.rasterize' was deprecated.*",
8895
category=UltraPlotWarning,
8996
)
9097
except Exception:
9198
pass
9299

100+
93101
# Print available system fonts
94102
from matplotlib.font_manager import fontManager
95103
from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey
@@ -103,6 +111,10 @@ def _reset_ultraplot(gallery_conf, fname):
103111
import ultraplot as uplt
104112
except Exception:
105113
return
114+
for _logger_name in ("matplotlib", "matplotlib.font_manager"):
115+
_logger = logging.getLogger(_logger_name)
116+
_logger.setLevel(logging.ERROR)
117+
_logger.propagate = False
106118
uplt.rc.reset()
107119

108120

@@ -349,6 +361,9 @@ def _reset_ultraplot(gallery_conf, fname):
349361

350362
nbsphinx_execute = "auto"
351363

364+
# Suppress warnings in nbsphinx kernels without injecting visible cells.
365+
os.environ["PYTHONWARNINGS"] = "ignore"
366+
352367
# Sphinx gallery configuration
353368
sphinx_gallery_conf = {
354369
"doc_module": ("ultraplot",),

docs/sphinxext/custom_roles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
Custom :rc: and :rcraw: roles for rc settings.
44
"""
5+
56
import os
67

78
from docutils import nodes

docs/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
mean_temps = [14.0, 14.2, 14.5, 15.0, 15.5] # warming trend
429429
data = [state.normal(temp, 0.8, 500) for temp in mean_temps]
430430

431-
fig, axs = uplt.subplots(ncols=2, figsize=(11, 5))
431+
fig, axs = uplt.subplots(ncols=2, share=0)
432432
axs.format(abc="A.", abcloc="ul", suptitle="Categorical vs Continuous positioning")
433433

434434
# Categorical positioning (default)

ultraplot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
A succinct matplotlib wrapper for making beautiful, publication-quality graphics.
44
"""
5+
56
from __future__ import annotations
67

78
import sys

ultraplot/_lazy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
Helpers for lazy attribute loading in :mod:`ultraplot`.
44
"""
5+
56
from __future__ import annotations
67

78
import ast

0 commit comments

Comments
 (0)