Skip to content

Commit 5643ff6

Browse files
authored
Merge branch 'main' into fix-legend-indexing-and-placement
2 parents 9ac7440 + 5007f1e commit 5643ff6

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

.github/workflows/build-ultraplot.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
4444
- name: Test Ultraplot
4545
run: |
46-
pytest --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot
46+
pytest -n auto --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml ultraplot
4747
4848
- name: Upload coverage reports to Codecov
4949
uses: codecov/codecov-action@v5
@@ -71,29 +71,55 @@ jobs:
7171
cache-environment: true
7272
cache-downloads: false
7373

74+
# Cache Baseline Figures (Restore step)
75+
- name: Cache Baseline Figures
76+
id: cache-baseline
77+
uses: actions/cache@v4
78+
with:
79+
path: ./ultraplot/tests/baseline # The directory to cache
80+
# Key is based on OS, Python/Matplotlib versions, and the PR number
81+
key: ${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}
82+
restore-keys: |
83+
${{ runner.os }}-baseline-pr-${{ github.event.pull_request.number }}-${{ inputs.python-version }}-${{ inputs.matplotlib-version }}-
84+
85+
# Conditional Baseline Generation (Only runs on cache miss)
7486
- name: Generate baseline from main
87+
# Skip this step if the cache was found (cache-hit is true)
88+
if: steps.cache-baseline.outputs.cache-hit != 'true'
7589
run: |
76-
mkdir -p baseline
90+
mkdir -p ultraplot/tests/baseline
91+
# Checkout the base branch (e.g., 'main') to generate the official baseline
7792
git fetch origin ${{ github.event.pull_request.base.sha }}
7893
git checkout ${{ github.event.pull_request.base.sha }}
94+
95+
# Install the Ultraplot version from the base branch's code
96+
pip install --no-build-isolation --no-deps .
97+
98+
# Generate the baseline images and hash library
7999
python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
80-
pytest -W ignore \
81-
--mpl-generate-path=./baseline/ \
100+
pytest -x -n auto -W ignore \
101+
--mpl-generate-path=./ultraplot/tests/baseline/ \
82102
--mpl-default-style="./ultraplot.yml"\
83103
ultraplot/tests
84-
git checkout ${{ github.sha }} # Return to PR branch
85104
105+
# Return to the PR branch for the rest of the job
106+
git checkout ${{ github.sha }}
107+
108+
# Image Comparison (Uses cached or newly generated baseline)
86109
- name: Image Comparison Ultraplot
87110
run: |
111+
# Re-install the Ultraplot version from the current PR branch
112+
pip install --no-build-isolation --no-deps .
113+
88114
mkdir -p results
89115
python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
90-
pytest -W ignore \
91-
--mpl \
92-
--mpl-baseline-path=./baseline/ \
93-
--mpl-results-path=./results/ \
94-
--mpl-generate-summary=html \
95-
--mpl-default-style="./ultraplot.yml" \
96-
ultraplot/tests
116+
pytest -x -n auto -W ignore -n auto\
117+
--mpl \
118+
--mpl-baseline-path=./ultraplot/tests/baseline \
119+
--mpl-results-path=./results/ \
120+
--mpl-generate-summary=html \
121+
--mpl-default-style="./ultraplot.yml" \
122+
ultraplot/tests
97123
98124
# Return the html output of the comparison even if failed
99125
- name: Upload comparison failures

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
- pytest
1313
- pytest-mpl
1414
- pytest-cov
15+
- pytest-xdist
1516
- jupyter
1617
- pip
1718
- pint

ultraplot/axes/cartesian.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,7 @@ def get_tightbbox(self, renderer, *args, **kwargs):
16201620
return super().get_tightbbox(renderer, *args, **kwargs)
16211621

16221622

1623+
# tmp
16231624
# Apply signature obfuscation after storing previous signature
16241625
# NOTE: This is needed for __init__, altx, and alty
16251626
CartesianAxes._format_signatures[CartesianAxes] = inspect.signature(

0 commit comments

Comments
 (0)