tesorotools-python 0.0.26__tar.gz → 0.0.27__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.
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/PKG-INFO +1 -1
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/pyproject.toml +1 -1
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/stacked.py +48 -16
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/.gitignore +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/barh.md +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/barh_plot.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/line_plot.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/table.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/type_curve.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/README.md +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Black.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Bold.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Extrabold.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Extralight.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Light.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Medium.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Regular.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/CabinetGrotesk-Thin.otf +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/README.md +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/plots.yaml +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/tesoro.mplstyle +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/convert.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/README.md +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/debug.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/lseg.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/database/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/database/local.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/database/push.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/node.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/resolution.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/main.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/offsets/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/offsets/offsets.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/offsets/outliers.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/diagnose.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/engine.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/rules.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/providers/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/providers/base.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/providers/bde.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/py.typed +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/content.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/images.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/section.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/subtitle.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/table.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/text.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/title.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/report.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/__init__.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/config.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/format.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/globals.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/matplotlib.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/series.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/shortcuts.py +0 -0
- {tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/utils/template.py +0 -0
|
@@ -139,6 +139,13 @@ class StackedBarPlot:
|
|
|
139
139
|
|
|
140
140
|
Positive and negative values are stacked separately so
|
|
141
141
|
that bars extend in both directions from the baseline.
|
|
142
|
+
|
|
143
|
+
The ``plot`` method delegates to overridable hooks so
|
|
144
|
+
subclasses can customise individual steps without
|
|
145
|
+
reimplementing the full render pipeline:
|
|
146
|
+
|
|
147
|
+
* ``_prepare_data`` — slice, scale, resample
|
|
148
|
+
* ``_format_xticks`` — tick positions, labels, rotation
|
|
142
149
|
"""
|
|
143
150
|
|
|
144
151
|
def __init__(
|
|
@@ -156,6 +163,8 @@ class StackedBarPlot:
|
|
|
156
163
|
figsize: tuple[float, float] | None = None,
|
|
157
164
|
overlay_series: dict[str, str] | None = None,
|
|
158
165
|
plot_size: tuple[float, float] | None = None,
|
|
166
|
+
bar_width: float = 0.7,
|
|
167
|
+
x_rotation: float = 0,
|
|
159
168
|
) -> None:
|
|
160
169
|
if out_path.suffix != ".png":
|
|
161
170
|
raise ValueError(f"out_path must be .png: {out_path}")
|
|
@@ -171,6 +180,8 @@ class StackedBarPlot:
|
|
|
171
180
|
self.plot_size = plot_size
|
|
172
181
|
self.figsize = figsize
|
|
173
182
|
self.overlay_series = overlay_series or {}
|
|
183
|
+
self.bar_width = bar_width
|
|
184
|
+
self.x_rotation = x_rotation
|
|
174
185
|
|
|
175
186
|
@classmethod
|
|
176
187
|
def from_yaml(cls, loader: TemplateLoader, node: MappingNode) -> Self:
|
|
@@ -182,7 +193,13 @@ class StackedBarPlot:
|
|
|
182
193
|
cfg["data"] = pd.read_feather(cfg.pop("data_path"))
|
|
183
194
|
return cls(**cfg)
|
|
184
195
|
|
|
185
|
-
|
|
196
|
+
# -- Overridable hooks -----------------------------------
|
|
197
|
+
|
|
198
|
+
def _prepare_data(self) -> pd.DataFrame:
|
|
199
|
+
"""Slice, scale, and return plot-ready DataFrame.
|
|
200
|
+
|
|
201
|
+
Override to resample, change the index type, etc.
|
|
202
|
+
"""
|
|
186
203
|
start = (
|
|
187
204
|
pd.Timestamp(self.start_date)
|
|
188
205
|
if self.start_date
|
|
@@ -193,10 +210,35 @@ class StackedBarPlot:
|
|
|
193
210
|
if self.end_date
|
|
194
211
|
else self.data.index.max()
|
|
195
212
|
)
|
|
196
|
-
|
|
197
213
|
all_cols = list(self.series.keys()) + list(self.overlay_series.keys())
|
|
198
214
|
plot_data = self.data.loc[start:end, all_cols].dropna()
|
|
199
|
-
|
|
215
|
+
return plot_data * self.scale
|
|
216
|
+
|
|
217
|
+
def _format_xticks(
|
|
218
|
+
self,
|
|
219
|
+
ax: Axes,
|
|
220
|
+
plot_data: pd.DataFrame,
|
|
221
|
+
x: np.ndarray[tuple[int], np.dtype[np.intp]],
|
|
222
|
+
) -> None:
|
|
223
|
+
"""Set tick positions, labels, and rotation.
|
|
224
|
+
|
|
225
|
+
Override for custom labels (e.g. string index).
|
|
226
|
+
"""
|
|
227
|
+
dates = plot_data.index
|
|
228
|
+
step = max(1, len(dates) // 12)
|
|
229
|
+
tick_pos = list(range(0, len(dates), step))
|
|
230
|
+
tick_labels = [dates[i].strftime("%Y") for i in tick_pos]
|
|
231
|
+
ax.set_xticks( # type: ignore[reportUnknownMemberType]
|
|
232
|
+
tick_pos
|
|
233
|
+
)
|
|
234
|
+
ax.set_xticklabels( # type: ignore[reportUnknownMemberType]
|
|
235
|
+
tick_labels, rotation=self.x_rotation
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# -- Main render -----------------------------------------
|
|
239
|
+
|
|
240
|
+
def plot(self) -> Axes:
|
|
241
|
+
plot_data = self._prepare_data()
|
|
200
242
|
|
|
201
243
|
fig_kw = dict(FIG_CONFIG)
|
|
202
244
|
if self.figsize is not None:
|
|
@@ -210,7 +252,6 @@ class StackedBarPlot:
|
|
|
210
252
|
labels = list(self.series.values())
|
|
211
253
|
|
|
212
254
|
x = np.arange(len(plot_data))
|
|
213
|
-
bar_width = 0.7
|
|
214
255
|
|
|
215
256
|
pos_bottom: np.ndarray[tuple[int], np.dtype[np.float64]] = np.zeros(
|
|
216
257
|
len(plot_data)
|
|
@@ -235,7 +276,7 @@ class StackedBarPlot:
|
|
|
235
276
|
x,
|
|
236
277
|
pos,
|
|
237
278
|
bottom=pos_bottom,
|
|
238
|
-
width=bar_width,
|
|
279
|
+
width=self.bar_width,
|
|
239
280
|
label=label,
|
|
240
281
|
)
|
|
241
282
|
.patches[0]
|
|
@@ -245,7 +286,7 @@ class StackedBarPlot:
|
|
|
245
286
|
x,
|
|
246
287
|
neg,
|
|
247
288
|
bottom=neg_bottom,
|
|
248
|
-
width=bar_width,
|
|
289
|
+
width=self.bar_width,
|
|
249
290
|
color=color,
|
|
250
291
|
)
|
|
251
292
|
pos_bottom = pos_bottom + pos
|
|
@@ -262,16 +303,7 @@ class StackedBarPlot:
|
|
|
262
303
|
zorder=10,
|
|
263
304
|
)
|
|
264
305
|
|
|
265
|
-
|
|
266
|
-
step = max(1, len(dates) // 12)
|
|
267
|
-
tick_pos = list(range(0, len(dates), step))
|
|
268
|
-
tick_labels = [dates[i].strftime("%Y") for i in tick_pos]
|
|
269
|
-
ax.set_xticks( # type: ignore[reportUnknownMemberType]
|
|
270
|
-
tick_pos
|
|
271
|
-
)
|
|
272
|
-
ax.set_xticklabels( # type: ignore[reportUnknownMemberType]
|
|
273
|
-
tick_labels
|
|
274
|
-
)
|
|
306
|
+
self._format_xticks(ax, plot_data, x)
|
|
275
307
|
|
|
276
308
|
style_spines(
|
|
277
309
|
ax,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/barh_plot.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/line_plot.py
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/artists/type_curve.py
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
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/fonts/README.md
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/assets/tesoro.mplstyle
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/README.md
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/debug.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/data_sources/lseg.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/database/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/node.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/dependencies/resolution.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/pipeline/diagnose.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/providers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/content.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/images.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/section.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/subtitle.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/table.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/text.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.26 → tesorotools_python-0.0.27}/src/tesorotools/render/content/title.py
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
|