mapyta 0.9.0__tar.gz → 0.10.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/PKG-INFO +1 -1
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/map.py +116 -10
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/pyproject.toml +1 -1
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_map.py +128 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.github/workflows/docs-preview.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.github/workflows/docs.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.github/workflows/lint.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.github/workflows/publish.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.github/workflows/tests.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.gitignore +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.pre-commit-config.yaml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/.ruff.toml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/LICENSE +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/README.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/.nav.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/images/favicon.ico +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/images/logo-dark-mode.svg +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/images/mapyta-logo-dark-mode.svg +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/images/mapyta-logo-light-mode.svg +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/javascripts/katex.js +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/stylesheets/extra.css +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/main.html +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_scripts/__init__.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_scripts/generate_index.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_scripts/generate_reference_pages.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/.nav.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/advanced.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/animated.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/choropleth.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/clusters.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/configuration.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/coordinates.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/dataframe.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/drawing.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/export.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/faq.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/first-map.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/geodataframe.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/geometries.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/heatmaps.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/index.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/layers.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/markers.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/min-zoom.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/open-data.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/search.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/text-annotations.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/tutorial/tooltips-popups.md +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/__init__.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/config.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/coordinates.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/dataframe.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/export.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/geojson.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/markdown.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/markers.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/mouse_position.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/style.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/mapyta/tiles.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/properdocs.yml +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/__init__.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/conftest.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_data.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_dataframe.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_draw.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_export.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_geometry.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_layers.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_map_creation.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_markers.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_merge_and_chaining.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/tests/test_utilities.py +0 -0
- {mapyta-0.9.0 → mapyta-0.10.0.dev1}/uv.lock +0 -0
|
@@ -1477,19 +1477,127 @@ class Map:
|
|
|
1477
1477
|
-------
|
|
1478
1478
|
branca.colormap.LinearColormap
|
|
1479
1479
|
"""
|
|
1480
|
+
return cm.LinearColormap(colors=self._resolve_colors(colors), vmin=vmin, vmax=vmax, caption=caption)
|
|
1481
|
+
|
|
1482
|
+
def _resolve_colors(self, colors: list[str] | str | None) -> list[str]:
|
|
1483
|
+
"""Resolve a palette name, explicit color list, or ``None`` to a concrete low→high ramp.
|
|
1484
|
+
|
|
1485
|
+
Parameters
|
|
1486
|
+
----------
|
|
1487
|
+
colors : list[str] | str | None
|
|
1488
|
+
Palette name (e.g. ``"blues"``), list of hex colors, or ``None`` for the
|
|
1489
|
+
default palette.
|
|
1490
|
+
|
|
1491
|
+
Returns
|
|
1492
|
+
-------
|
|
1493
|
+
list[str]
|
|
1494
|
+
The resolved low→high color ramp.
|
|
1495
|
+
|
|
1496
|
+
Raises
|
|
1497
|
+
------
|
|
1498
|
+
ValueError
|
|
1499
|
+
If ``colors`` names an unknown palette or is an empty list.
|
|
1500
|
+
"""
|
|
1480
1501
|
if isinstance(colors, str):
|
|
1481
1502
|
palette = PALETTES.get(colors)
|
|
1482
1503
|
if palette is None:
|
|
1483
1504
|
valid = ", ".join(f'"{k}"' for k in sorted(PALETTES))
|
|
1484
1505
|
raise ValueError(f"Unknown palette {colors!r}. Available palettes: {valid}")
|
|
1485
|
-
|
|
1486
|
-
|
|
1506
|
+
return palette
|
|
1507
|
+
if colors is not None:
|
|
1487
1508
|
if not colors:
|
|
1488
1509
|
raise ValueError("colors list must not be empty")
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1510
|
+
return colors
|
|
1511
|
+
return PALETTES["ylrd"]
|
|
1512
|
+
|
|
1513
|
+
def _register_colormap(self, colormap: cm.LinearColormap | cm.StepColormap) -> None:
|
|
1514
|
+
"""Add ``colormap`` to the folium map and track it so legends merge correctly."""
|
|
1515
|
+
colormap.add_to(self._map)
|
|
1516
|
+
self._colormaps.append(colormap)
|
|
1517
|
+
|
|
1518
|
+
def add_colorbar(
|
|
1519
|
+
self,
|
|
1520
|
+
colors: list[str] | str | None,
|
|
1521
|
+
vmin: float,
|
|
1522
|
+
vmax: float,
|
|
1523
|
+
legend_name: str,
|
|
1524
|
+
) -> cm.LinearColormap:
|
|
1525
|
+
"""Add a standalone color-scale legend (colorbar) to the map.
|
|
1526
|
+
|
|
1527
|
+
Unlike :meth:`add_choropleth` and :meth:`from_geodataframe`, this adds a
|
|
1528
|
+
legend on its own — for maps whose features are coloured by hand (e.g.
|
|
1529
|
+
:meth:`add_circle` / :meth:`add_point` with per-feature styles). The
|
|
1530
|
+
returned colormap is callable: ``colormap(value)`` yields the hex colour
|
|
1531
|
+
for ``value``, so callers colour their own features consistently with
|
|
1532
|
+
the legend without rebuilding the scale.
|
|
1533
|
+
|
|
1534
|
+
The legend is a readable HTML ``<div>`` pinned to the bottom-right of the
|
|
1535
|
+
map (a horizontal gradient bar with the ``legend_name`` above and evenly
|
|
1536
|
+
spaced value ticks below), rather than branca's default SVG colorbar. Two
|
|
1537
|
+
consequences follow: ``legend_name`` may contain inline HTML such as
|
|
1538
|
+
``<sub>``/``<sup>`` (rendered, not shown literally), and the legend sits
|
|
1539
|
+
clear of the top-centre :paramref:`title` instead of overlapping it.
|
|
1540
|
+
|
|
1541
|
+
Parameters
|
|
1542
|
+
----------
|
|
1543
|
+
colors : list[str] | str | None
|
|
1544
|
+
Palette name (e.g. ``"blues"``), list of hex colors, or ``None`` for
|
|
1545
|
+
the default palette. Same handling as :meth:`add_choropleth`.
|
|
1546
|
+
vmin, vmax : float
|
|
1547
|
+
Color scale range.
|
|
1548
|
+
legend_name : str
|
|
1549
|
+
Legend label. May contain inline HTML (e.g. ``"R<sub>c;cal</sub>"``).
|
|
1550
|
+
|
|
1551
|
+
Returns
|
|
1552
|
+
-------
|
|
1553
|
+
branca.colormap.LinearColormap
|
|
1554
|
+
The colormap added to the map. Call it with a value to get a colour.
|
|
1555
|
+
"""
|
|
1556
|
+
color_list = self._resolve_colors(colors)
|
|
1557
|
+
colormap = cm.LinearColormap(colors=color_list, vmin=vmin, vmax=vmax, caption=legend_name)
|
|
1558
|
+
# Track the colormap (for merge), but render our own HTML legend rather than
|
|
1559
|
+
# branca's SVG colorbar via ``_register_colormap`` — see the method docstring.
|
|
1560
|
+
self._colormaps.append(colormap)
|
|
1561
|
+
self._add_html_colorbar(colors=color_list, vmin=vmin, vmax=vmax, legend_name=legend_name)
|
|
1562
|
+
return colormap
|
|
1563
|
+
|
|
1564
|
+
@staticmethod
|
|
1565
|
+
def _format_legend_value(value: float) -> str:
|
|
1566
|
+
"""Format a colorbar tick: a thousands-separated integer, else two decimals."""
|
|
1567
|
+
rounded = round(value, 2)
|
|
1568
|
+
if rounded.is_integer():
|
|
1569
|
+
return f"{int(rounded):,}"
|
|
1570
|
+
return f"{rounded:,.2f}"
|
|
1571
|
+
|
|
1572
|
+
def _add_html_colorbar(self, colors: list[str], vmin: float, vmax: float, legend_name: str) -> None:
|
|
1573
|
+
"""Render the HTML colorbar legend (gradient bar + caption + ticks) bottom-right.
|
|
1574
|
+
|
|
1575
|
+
Parameters
|
|
1576
|
+
----------
|
|
1577
|
+
colors : list[str]
|
|
1578
|
+
The resolved low→high color ramp. Always holds at least two colours
|
|
1579
|
+
(branca's ``LinearColormap`` rejects fewer in :meth:`add_colorbar`).
|
|
1580
|
+
vmin, vmax : float
|
|
1581
|
+
Color scale range, used for the five evenly spaced value ticks.
|
|
1582
|
+
legend_name : str
|
|
1583
|
+
Legend label; inline HTML is preserved (e.g. ``<sub>``).
|
|
1584
|
+
"""
|
|
1585
|
+
last = len(colors) - 1
|
|
1586
|
+
stops = ", ".join(f"{color} {index / last * 100:.0f}%" for index, color in enumerate(colors))
|
|
1587
|
+
gradient = f"linear-gradient(to right, {stops})"
|
|
1588
|
+
tick_count = 5
|
|
1589
|
+
ticks = "".join(f"<span>{self._format_legend_value(vmin + (vmax - vmin) * step / (tick_count - 1))}</span>" for step in range(tick_count))
|
|
1590
|
+
legend_html = (
|
|
1591
|
+
'<div style="position:fixed;bottom:14px;right:14px;'
|
|
1592
|
+
"z-index:1000;background:rgba(255,255,255,0.92);padding:6px 12px;border-radius:6px;"
|
|
1593
|
+
"box-shadow:0 2px 6px rgba(0,0,0,0.3);font-family:Arial,sans-serif;font-size:12px;"
|
|
1594
|
+
'color:#333;pointer-events:none;">'
|
|
1595
|
+
f'<div style="text-align:center;font-weight:bold;margin-bottom:4px;">{legend_name}</div>'
|
|
1596
|
+
f'<div style="width:260px;height:12px;border-radius:2px;background:{gradient};"></div>'
|
|
1597
|
+
f'<div style="display:flex;justify-content:space-between;margin-top:3px;">{ticks}</div>'
|
|
1598
|
+
"</div>"
|
|
1599
|
+
)
|
|
1600
|
+
self._map.get_root().html.add_child(folium.Element(legend_html)) # ty: ignore[unresolved-attribute]
|
|
1493
1601
|
|
|
1494
1602
|
def add_choropleth( # noqa: C901, PLR0913, PLR0912, PLR0915
|
|
1495
1603
|
self,
|
|
@@ -1653,8 +1761,7 @@ class Map:
|
|
|
1653
1761
|
tooltip=tooltip,
|
|
1654
1762
|
)
|
|
1655
1763
|
layer.add_to(self._target())
|
|
1656
|
-
|
|
1657
|
-
self._colormaps.append(colormap)
|
|
1764
|
+
self._register_colormap(colormap)
|
|
1658
1765
|
|
|
1659
1766
|
try:
|
|
1660
1767
|
layer_bounds = layer.get_bounds()
|
|
@@ -2304,8 +2411,7 @@ class Map:
|
|
|
2304
2411
|
vmax=vmax,
|
|
2305
2412
|
caption=legend_name or color_column,
|
|
2306
2413
|
)
|
|
2307
|
-
|
|
2308
|
-
m._colormaps.append(colormap)
|
|
2414
|
+
m._register_colormap(colormap)
|
|
2309
2415
|
|
|
2310
2416
|
# Iterate rows
|
|
2311
2417
|
for idx, row in gdf.iterrows():
|
|
@@ -5410,3 +5410,131 @@ class TestCSSMarkerStyle:
|
|
|
5410
5410
|
m.to_html(out)
|
|
5411
5411
|
html = out.read_text(encoding="utf-8")
|
|
5412
5412
|
assert "font-size:20px" in html
|
|
5413
|
+
|
|
5414
|
+
|
|
5415
|
+
# ===================================================================
|
|
5416
|
+
# Scenarios for add_colorbar (standalone color-scale legend).
|
|
5417
|
+
# ===================================================================
|
|
5418
|
+
|
|
5419
|
+
|
|
5420
|
+
class TestAddColorbar:
|
|
5421
|
+
"""Tests for the standalone ``add_colorbar`` color-scale legend."""
|
|
5422
|
+
|
|
5423
|
+
def test_registers_and_returns_callable_colormap(self) -> None:
|
|
5424
|
+
"""
|
|
5425
|
+
Scenario: A standalone colorbar is added to a map.
|
|
5426
|
+
|
|
5427
|
+
Given: An empty map
|
|
5428
|
+
When: add_colorbar is called with a value range
|
|
5429
|
+
Then: The returned colormap is callable and is registered on the map
|
|
5430
|
+
"""
|
|
5431
|
+
# Arrange - Given
|
|
5432
|
+
m = Map()
|
|
5433
|
+
|
|
5434
|
+
# Act - When
|
|
5435
|
+
colormap = m.add_colorbar(colors=None, vmin=0.0, vmax=100.0, legend_name="Capacity [kN]")
|
|
5436
|
+
|
|
5437
|
+
# Assert - Then
|
|
5438
|
+
assert len(m._colormaps) == 1, "Colormap should be registered for merge/standalone tracking"
|
|
5439
|
+
assert isinstance(colormap(50.0), str), "Returned colormap must be callable and yield a colour string"
|
|
5440
|
+
|
|
5441
|
+
def test_legend_caption_renders_in_html(self) -> None:
|
|
5442
|
+
"""
|
|
5443
|
+
Scenario: The colorbar legend appears in the rendered map.
|
|
5444
|
+
|
|
5445
|
+
Given: A map with a colorbar whose caption is set
|
|
5446
|
+
When: The map is rendered to HTML
|
|
5447
|
+
Then: The caption text appears in the output
|
|
5448
|
+
"""
|
|
5449
|
+
# Arrange - Given
|
|
5450
|
+
m = Map()
|
|
5451
|
+
|
|
5452
|
+
# Act - When
|
|
5453
|
+
m.add_colorbar(colors=["#ff0000", "#00ff00"], vmin=0.0, vmax=10.0, legend_name="MyLegend")
|
|
5454
|
+
html = m._repr_html_()
|
|
5455
|
+
|
|
5456
|
+
# Assert - Then
|
|
5457
|
+
assert "MyLegend" in html, "Legend caption should be rendered in the HTML"
|
|
5458
|
+
|
|
5459
|
+
def test_named_palette(self) -> None:
|
|
5460
|
+
"""
|
|
5461
|
+
Scenario: A colorbar built from a named palette.
|
|
5462
|
+
|
|
5463
|
+
Given: An empty map
|
|
5464
|
+
When: add_colorbar is called with colors="blues"
|
|
5465
|
+
Then: One colormap is registered
|
|
5466
|
+
"""
|
|
5467
|
+
m = Map()
|
|
5468
|
+
m.add_colorbar(colors="blues", vmin=0.0, vmax=1.0, legend_name="x")
|
|
5469
|
+
assert len(m._colormaps) == 1
|
|
5470
|
+
|
|
5471
|
+
def test_unknown_palette_raises_value_error(self) -> None:
|
|
5472
|
+
"""
|
|
5473
|
+
Scenario: A colorbar with an unknown palette name.
|
|
5474
|
+
|
|
5475
|
+
Given: An empty map
|
|
5476
|
+
When: add_colorbar is called with an unknown palette
|
|
5477
|
+
Then: A ValueError is raised with a helpful message
|
|
5478
|
+
"""
|
|
5479
|
+
m = Map()
|
|
5480
|
+
with pytest.raises(ValueError, match="Unknown palette"):
|
|
5481
|
+
m.add_colorbar(colors="nonexistent", vmin=0.0, vmax=1.0, legend_name="x")
|
|
5482
|
+
|
|
5483
|
+
def test_colormap_endpoints_differ(self) -> None:
|
|
5484
|
+
"""
|
|
5485
|
+
Scenario: The colorbar maps the value range across distinct colours.
|
|
5486
|
+
|
|
5487
|
+
Given: A colorbar over a non-degenerate range
|
|
5488
|
+
When: The colormap is evaluated at vmin and vmax
|
|
5489
|
+
Then: The endpoint colours differ
|
|
5490
|
+
"""
|
|
5491
|
+
m = Map()
|
|
5492
|
+
colormap = m.add_colorbar(colors=["#ff0000", "#0000ff"], vmin=0.0, vmax=100.0, legend_name="x")
|
|
5493
|
+
assert colormap(0.0) != colormap(100.0), "vmin and vmax should resolve to different colours"
|
|
5494
|
+
|
|
5495
|
+
def test_legend_is_html_gradient_not_branca_svg(self) -> None:
|
|
5496
|
+
"""
|
|
5497
|
+
Scenario: The colorbar is a readable HTML legend, not branca's SVG colorbar.
|
|
5498
|
+
|
|
5499
|
+
Given: A map with a multi-colour colorbar
|
|
5500
|
+
When: The map is rendered
|
|
5501
|
+
Then: An HTML gradient legend is pinned bottom-centre and no branca SVG/topright
|
|
5502
|
+
control is emitted (so it cannot overlap the top-centre title)
|
|
5503
|
+
"""
|
|
5504
|
+
m = Map(title="B1")
|
|
5505
|
+
m.add_colorbar(colors=["#d73027", "#fee08b", "#1a9850"], vmin=0.0, vmax=100.0, legend_name="Cap")
|
|
5506
|
+
html = m.get_standalone_html()
|
|
5507
|
+
|
|
5508
|
+
assert "linear-gradient(to right" in html, "Legend should be a CSS gradient bar"
|
|
5509
|
+
assert "bottom:14px;right:14px" in html, "Legend should sit bottom-right, clear of the title"
|
|
5510
|
+
assert "color_map_" not in html, "branca's SVG colorbar must not be emitted"
|
|
5511
|
+
assert ".legend = L.control({position: 'topright'})" not in html, "no top-right colorbar control"
|
|
5512
|
+
|
|
5513
|
+
def test_legend_caption_preserves_inline_html(self) -> None:
|
|
5514
|
+
"""
|
|
5515
|
+
Scenario: A caption with inline markup renders as HTML, not literal text.
|
|
5516
|
+
|
|
5517
|
+
Given: A colorbar whose legend_name contains a ``<sub>`` tag
|
|
5518
|
+
When: The map is rendered
|
|
5519
|
+
Then: The ``<sub>`` markup is preserved in the legend (so it renders as a subscript)
|
|
5520
|
+
"""
|
|
5521
|
+
m = Map()
|
|
5522
|
+
m.add_colorbar(colors=["#ff0000", "#00ff00"], vmin=0.0, vmax=10.0, legend_name="R<sub>c;cal</sub>")
|
|
5523
|
+
html = m.get_standalone_html()
|
|
5524
|
+
|
|
5525
|
+
assert "R<sub>c;cal</sub>" in html, "inline HTML in the caption must be preserved, not escaped"
|
|
5526
|
+
|
|
5527
|
+
def test_legend_ticks_format_integers_and_decimals(self) -> None:
|
|
5528
|
+
"""
|
|
5529
|
+
Scenario: Tick labels are thousands-separated integers or two-decimal floats.
|
|
5530
|
+
|
|
5531
|
+
Given: A colorbar whose range yields both integer and fractional ticks
|
|
5532
|
+
When: The map is rendered
|
|
5533
|
+
Then: Whole values show as separated integers and fractional values as 2-decimals
|
|
5534
|
+
"""
|
|
5535
|
+
m = Map()
|
|
5536
|
+
m.add_colorbar(colors="blues", vmin=1000.0, vmax=1001.0, legend_name="x")
|
|
5537
|
+
html = m.get_standalone_html()
|
|
5538
|
+
|
|
5539
|
+
assert "1,000" in html, "whole tick values render thousands-separated"
|
|
5540
|
+
assert "1,000.25" in html, "fractional tick values render with two decimals"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapyta-0.9.0 → mapyta-0.10.0.dev1}/docs/_overrides/assets/images/mapyta-logo-light-mode.svg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|