Skip to content
Open
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
7 changes: 4 additions & 3 deletions .github/workflows/build-ultraplot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
DISABLE_BASELINE_CACHE: "true"

jobs:
build-ultraplot:
Expand All @@ -45,7 +46,7 @@ jobs:
--verbose
python=${{ inputs.python-version }}
matplotlib=${{ inputs.matplotlib-version }}
cache-environment: true
cache-environment: false
cache-downloads: false

- name: Build Ultraplot
Expand Down Expand Up @@ -87,14 +88,14 @@ jobs:
--verbose
python=${{ inputs.python-version }}
matplotlib=${{ inputs.matplotlib-version }}
cache-environment: true
cache-environment: false
cache-downloads: false

# Cache Baseline Figures (Restore step)
- name: Cache Baseline Figures
id: cache-baseline
uses: actions/cache@v4
if: ${{ env.IS_PR }}
if: ${{ false }}
with:
path: ./ultraplot/tests/baseline # The directory to cache
# Key is based on OS, Python/Matplotlib versions, and the base commit SHA
Expand Down
42 changes: 41 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,49 @@ jobs:
test-mode: ${{ needs.select-tests.outputs.mode }}
test-nodeids: ${{ needs.select-tests.outputs.tests }}

unit-tests:
name: Unit Tests (coverage focus)
needs:
- run-if-changes
if: always() && needs.run-if-changes.outputs.run == 'true'
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: mamba-org/setup-micromamba@v2.0.7
with:
environment-file: ./environment.yml
init-shell: bash
create-args: >-
--verbose
python=3.11
matplotlib=3.9
cache-environment: false
cache-downloads: false

- name: Build Ultraplot
run: |
pip install --no-build-isolation --no-deps .

- name: Run unit tests
run: |
pytest -n auto --cov=ultraplot --cov-branch --cov-report term-missing --cov-report=xml -m "not mpl_image_compare" ultraplot/tests

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Ultraplot/ultraplot

build-success:
needs:
- build
- unit-tests
- run-if-changes
if: always()
runs-on: ubuntu-latest
Expand All @@ -203,7 +243,7 @@ jobs:
if [[ '${{ needs.run-if-changes.outputs.run }}' == 'false' ]]; then
echo "No changes detected, tests skipped."
else
if [[ '${{ needs.build.result }}' == 'success' ]]; then
if [[ '${{ needs.build.result }}' == 'success' && '${{ needs.unit-tests.result }}' == 'success' ]]; then
echo "All tests passed successfully!"
else
echo "Tests failed!"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
--verbose
python=3.11
matplotlib=3.9
cache-environment: true
cache-environment: false
cache-downloads: false

- name: Build Ultraplot
Expand Down
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ python:
install:
- method: pip
path: .
extra_requirements:
- all
32 changes: 32 additions & 0 deletions docs/examples/plot_types/07_radar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Radar chart
===========

UltraPlot wrapper around pyCirclize's radar chart helper.
"""

import pandas as pd

import ultraplot as uplt

data = pd.DataFrame(
{
"Design": [3.5, 4.0],
"Speed": [4.2, 3.1],
"Reliability": [4.6, 4.1],
"Support": [3.2, 4.4],
},
index=["Model A", "Model B"],
)

fig, ax = uplt.subplots(proj="polar", refwidth=3.6)
ax.radar_chart(
data,
vmin=0,
vmax=5,
fill=True,
marker_size=4,
grid_interval_ratio=0.2,
)
ax.format(title="Product radar")
fig.show()
21 changes: 21 additions & 0 deletions docs/examples/plot_types/08_chord_diagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Chord diagram
=============

UltraPlot wrapper around pyCirclize chord diagrams.
"""

import pandas as pd

import ultraplot as uplt

matrix = pd.DataFrame(
[[10, 6, 2], [6, 12, 4], [2, 4, 8]],
index=["A", "B", "C"],
columns=["A", "B", "C"],
)

fig, ax = uplt.subplots(proj="polar", refwidth=3.6)
ax.chord_diagram(matrix, ticks_interval=None, space=4)
ax.format(title="Chord diagram")
fig.show()
15 changes: 15 additions & 0 deletions docs/examples/plot_types/09_phylogeny.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Phylogeny
=========

UltraPlot wrapper around pyCirclize phylogeny plots.
"""

import ultraplot as uplt

newick = "((A,B),C);"

fig, ax = uplt.subplots(proj="polar", refwidth=3.2)
ax.phylogeny(newick, leaf_label_size=10)
ax.format(title="Phylogeny")
fig.show()
34 changes: 34 additions & 0 deletions docs/examples/plot_types/10_circos_bed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Circos from BED
===============

Build sectors from a BED file and render on UltraPlot polar axes.
"""

import tempfile
from pathlib import Path

import numpy as np

import ultraplot as uplt

bed_text = "chr1\t0\t100\nchr2\t0\t140\n"

with tempfile.TemporaryDirectory() as tmpdir:
bed_path = Path(tmpdir) / "mini.bed"
bed_path.write_text(bed_text, encoding="utf-8")

fig, ax = uplt.subplots(proj="polar", refwidth=3.6)
ax = ax[0] # pycirclize expects a PolarAxes, not a SubplotGrid wrapper
circos = ax.circos_bed(bed_path, plot=False)

for sector in circos.sectors:
x = np.linspace(sector.start, sector.end, 8)
y = np.linspace(0, 50, 8)
track = sector.add_track((60, 90), r_pad_ratio=0.1)
track.axis()
track.line(x, y)

circos.plotfig(ax=ax)
ax.format(title="BED sectors")
fig.show()
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ dependencies:
- lxml-html-clean
- pip:
- git+https://github.com/ultraplot/UltraTheme.git
- pycirclize
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ dependencies= [
]
dynamic = ["version"]

[project.optional-dependencies]
circos = ["pycirclize>=1.10.1"]
all = ["pycirclize>=1.10.1"]

[project.urls]
"Documentation" = "https://ultraplot.readthedocs.io"
"Issue Tracker" = "https://github.com/ultraplot/ultraplot/issues"
Expand Down
Loading
Loading