tesorotools-python 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl
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.
- tesorotools/artists/_common.py +27 -11
- tesorotools/artists/box_plot.py +1 -1
- tesorotools/note/__init__.py +28 -3
- tesorotools/note/builder.py +663 -127
- tesorotools/note/charts.py +134 -0
- tesorotools/note/cli.py +158 -18
- tesorotools/note/inline.py +279 -50
- tesorotools/note/issues.py +48 -0
- tesorotools/note/lint.py +1089 -144
- tesorotools/note/markdown.py +1186 -214
- tesorotools/note/pdf.py +123 -0
- tesorotools/note/skeleton.md +44 -10
- tesorotools/note/skill/SKILL.md +296 -72
- tesorotools/note/skill/reglas.md +43 -21
- {tesorotools_python-0.1.4.dist-info → tesorotools_python-0.1.6.dist-info}/METADATA +1 -1
- {tesorotools_python-0.1.4.dist-info → tesorotools_python-0.1.6.dist-info}/RECORD +18 -15
- {tesorotools_python-0.1.4.dist-info → tesorotools_python-0.1.6.dist-info}/WHEEL +0 -0
- {tesorotools_python-0.1.4.dist-info → tesorotools_python-0.1.6.dist-info}/entry_points.txt +0 -0
tesorotools/artists/_common.py
CHANGED
|
@@ -24,6 +24,7 @@ overrides only need to update ``plots.yaml``.
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
import math
|
|
27
|
+
import warnings
|
|
27
28
|
from collections.abc import Sequence
|
|
28
29
|
from pathlib import Path
|
|
29
30
|
from typing import Any, Literal, Protocol, Self, cast, runtime_checkable
|
|
@@ -624,7 +625,7 @@ def compact_legend_font_pt() -> float:
|
|
|
624
625
|
)
|
|
625
626
|
|
|
626
627
|
|
|
627
|
-
def compact_legend_kwargs() -> dict[str, Any]:
|
|
628
|
+
def compact_legend_kwargs(ax: Axes | None = None) -> dict[str, Any]:
|
|
628
629
|
"""Legend styling for compact charts, from the ``compact`` config.
|
|
629
630
|
|
|
630
631
|
Returns ``fontsize`` / ``handlelength`` / ``handletextpad`` /
|
|
@@ -633,9 +634,17 @@ def compact_legend_kwargs() -> dict[str, Any]:
|
|
|
633
634
|
the metrics used to *draw* the legend in :func:`legend_above` -- the
|
|
634
635
|
invariant that prevents an over-counted ``ncol``. The smaller font
|
|
635
636
|
and shorter handles let several wide labels share one legend row.
|
|
637
|
+
|
|
638
|
+
With *ax*, the legend is never larger than its tick labels: a chart
|
|
639
|
+
drawn with a small ``font_pt`` (the 7 pt of the notes) keeps the
|
|
640
|
+
legend at that size instead of ``legend_font_pt``.
|
|
636
641
|
"""
|
|
642
|
+
fontsize = compact_legend_font_pt()
|
|
643
|
+
ticks = (ax.get_yticklabels() or ax.get_xticklabels()) if ax else []
|
|
644
|
+
if ticks:
|
|
645
|
+
fontsize = min(fontsize, float(ticks[0].get_fontsize()))
|
|
637
646
|
return {
|
|
638
|
-
"fontsize":
|
|
647
|
+
"fontsize": fontsize,
|
|
639
648
|
"handlelength": float(COMPACT_CONFIG.get("legend_handlelength", 1.2)),
|
|
640
649
|
"handletextpad": float(COMPACT_CONFIG.get("legend_handletextpad", 0.4)),
|
|
641
650
|
"columnspacing": float(COMPACT_CONFIG.get("legend_columnspacing", 0.8)),
|
|
@@ -690,14 +699,21 @@ def date_span_ticks(
|
|
|
690
699
|
lo: float = float(cast(Any, date2num(data_min)))
|
|
691
700
|
hi: float = float(cast(Any, date2num(data_max)))
|
|
692
701
|
locator = AutoDateLocator(minticks=2, maxticks=maxticks)
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
702
|
+
# With few ticks over a long span the locator finds no interval in its
|
|
703
|
+
# table, warns and falls back to a sensible default: the fallback is
|
|
704
|
+
# the wanted result, the warning only noise for whoever draws a chart.
|
|
705
|
+
with warnings.catch_warnings():
|
|
706
|
+
warnings.filterwarnings(
|
|
707
|
+
"ignore", "AutoDateLocator was unable", UserWarning
|
|
708
|
+
)
|
|
709
|
+
candidates: list[float] = cast(
|
|
710
|
+
"list[float]", locator.tick_values(data_min, data_max)
|
|
711
|
+
)
|
|
712
|
+
if not pin_start:
|
|
713
|
+
return [t for t in candidates if lo <= t <= hi] or [lo, hi]
|
|
714
|
+
chosen: Any = locator.get_locator( # type: ignore[reportUnknownMemberType]
|
|
715
|
+
data_min, data_max
|
|
716
|
+
)
|
|
701
717
|
if isinstance(chosen, YearLocator):
|
|
702
718
|
step = int(cast(Any, chosen.base).step)
|
|
703
719
|
if step > 1:
|
|
@@ -1251,7 +1267,7 @@ def place_legend(
|
|
|
1251
1267
|
side = resolve_legend_position(position, compact=compact)
|
|
1252
1268
|
fig_w_px: float = fig.get_size_inches()[0] * fig.dpi
|
|
1253
1269
|
if compact:
|
|
1254
|
-
legend_kw = compact_legend_kwargs()
|
|
1270
|
+
legend_kw = compact_legend_kwargs(ax)
|
|
1255
1271
|
if ncol is None:
|
|
1256
1272
|
ncol = auto_ncol(
|
|
1257
1273
|
ax, labels, available_width_px=fig_w_px, **legend_kw
|
tesorotools/artists/box_plot.py
CHANGED
|
@@ -499,7 +499,7 @@ class BoxPlot(FigureLifecycle):
|
|
|
499
499
|
self.legend.position, compact=self.compact
|
|
500
500
|
)
|
|
501
501
|
if self.compact:
|
|
502
|
-
kw = compact_legend_kwargs()
|
|
502
|
+
kw = compact_legend_kwargs(ax)
|
|
503
503
|
ncol = self.legend.ncol or auto_ncol(
|
|
504
504
|
ax, labels, available_width_px=fig_w_px, **kw
|
|
505
505
|
)
|
tesorotools/note/__init__.py
CHANGED
|
@@ -15,26 +15,51 @@ from tesorotools.note.builder import (
|
|
|
15
15
|
Chart,
|
|
16
16
|
Note,
|
|
17
17
|
Table,
|
|
18
|
-
chart_size,
|
|
19
18
|
format_number,
|
|
19
|
+
normalize_unit,
|
|
20
20
|
spanish_date,
|
|
21
21
|
)
|
|
22
|
-
from tesorotools.note.
|
|
23
|
-
|
|
22
|
+
from tesorotools.note.charts import (
|
|
23
|
+
NOTE_COLORS,
|
|
24
|
+
axis_decimals,
|
|
25
|
+
axis_format,
|
|
26
|
+
chart_size,
|
|
27
|
+
note_palette,
|
|
28
|
+
)
|
|
29
|
+
from tesorotools.note.cli import skill_text
|
|
30
|
+
from tesorotools.note.issues import Issue, NoteError
|
|
31
|
+
from tesorotools.note.lint import check
|
|
32
|
+
from tesorotools.note.markdown import (
|
|
33
|
+
ChartRenderer,
|
|
34
|
+
NoteSource,
|
|
35
|
+
assemble,
|
|
36
|
+
build,
|
|
37
|
+
parse,
|
|
38
|
+
read,
|
|
39
|
+
)
|
|
24
40
|
from tesorotools.note.template import open_template
|
|
25
41
|
|
|
26
42
|
__all__ = [
|
|
43
|
+
"NOTE_COLORS",
|
|
27
44
|
"Chart",
|
|
45
|
+
"ChartRenderer",
|
|
28
46
|
"Issue",
|
|
29
47
|
"Note",
|
|
48
|
+
"NoteError",
|
|
30
49
|
"NoteSource",
|
|
31
50
|
"Table",
|
|
51
|
+
"assemble",
|
|
52
|
+
"axis_decimals",
|
|
53
|
+
"axis_format",
|
|
32
54
|
"build",
|
|
33
55
|
"chart_size",
|
|
34
56
|
"check",
|
|
35
57
|
"format_number",
|
|
58
|
+
"normalize_unit",
|
|
59
|
+
"note_palette",
|
|
36
60
|
"open_template",
|
|
37
61
|
"parse",
|
|
38
62
|
"read",
|
|
63
|
+
"skill_text",
|
|
39
64
|
"spanish_date",
|
|
40
65
|
]
|