tirex-mirror 2025.11.7__tar.gz → 2025.11.12__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.
Files changed (35) hide show
  1. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/PKG-INFO +3 -1
  2. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/pyproject.toml +2 -1
  3. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/util.py +117 -2
  4. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex_mirror.egg-info/PKG-INFO +3 -1
  5. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex_mirror.egg-info/requires.txt +3 -0
  6. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/LICENSE +0 -0
  7. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/LICENSE_MIRROR.txt +0 -0
  8. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/MANIFEST.in +0 -0
  9. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/NOTICE.txt +0 -0
  10. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/README.md +0 -0
  11. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/setup.cfg +0 -0
  12. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/__init__.py +0 -0
  13. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/api_adapter/__init__.py +0 -0
  14. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/api_adapter/forecast.py +0 -0
  15. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/api_adapter/gluon.py +0 -0
  16. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/api_adapter/hf_data.py +0 -0
  17. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/api_adapter/standard_adapter.py +0 -0
  18. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/base.py +0 -0
  19. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/__init__.py +0 -0
  20. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/patcher.py +0 -0
  21. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/slstm/block.py +0 -0
  22. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/slstm/cell.py +0 -0
  23. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/slstm/layer.py +0 -0
  24. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex/models/tirex.py +0 -0
  25. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex_mirror.egg-info/SOURCES.txt +0 -0
  26. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex_mirror.egg-info/dependency_links.txt +0 -0
  27. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/src/tirex_mirror.egg-info/top_level.txt +0 -0
  28. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_chronos_zs.py +0 -0
  29. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_compile.py +0 -0
  30. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_forecast.py +0 -0
  31. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_forecast_adapter.py +0 -0
  32. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_patcher.py +0 -0
  33. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_slstm_torch_vs_cuda.py +0 -0
  34. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_standard_adapter.py +0 -0
  35. {tirex_mirror-2025.11.7 → tirex_mirror-2025.11.12}/tests/test_util_freq.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tirex-mirror
3
- Version: 2025.11.7
3
+ Version: 2025.11.12
4
4
  Summary: Unofficial mirror of NX-AI/tirex for packaging
5
5
  Author-email: Arpad Rozsas <rozsasarpi@gmail.com>
6
6
  License: NXAI COMMUNITY LICENSE AGREEMENT
@@ -75,6 +75,8 @@ Requires-Dist: ipykernel; extra == "notebooks"
75
75
  Requires-Dist: matplotlib; extra == "notebooks"
76
76
  Requires-Dist: pandas; extra == "notebooks"
77
77
  Requires-Dist: python-dotenv; extra == "notebooks"
78
+ Provides-Extra: plotting
79
+ Requires-Dist: matplotlib; extra == "plotting"
78
80
  Provides-Extra: gluonts
79
81
  Requires-Dist: gluonts; extra == "gluonts"
80
82
  Requires-Dist: pandas; extra == "gluonts"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tirex-mirror"
3
- version = "2025.11.07"
3
+ version = "2025.11.12"
4
4
  description = "Unofficial mirror of NX-AI/tirex for packaging"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -25,6 +25,7 @@ Issues = "https://github.com/rozsasarpi/tirex-mirror/issues"
25
25
  [project.optional-dependencies]
26
26
  cuda = [ "xlstm", "ninja",]
27
27
  notebooks = [ "ipykernel", "matplotlib", "pandas", "python-dotenv",]
28
+ plotting = [ "matplotlib",]
28
29
  gluonts = [ "gluonts", "pandas",]
29
30
  hfdataset = [ "datasets",]
30
31
  test = [ "fev>=0.6.0", "pytest",]
@@ -1,15 +1,22 @@
1
1
  # Copyright (c) NXAI GmbH.
2
2
  # This software may be used and distributed according to the terms of the NXAI Community License Agreement.
3
3
 
4
- from collections.abc import Callable
4
+ from collections.abc import Callable, Sequence
5
5
  from dataclasses import fields
6
6
  from functools import partial
7
7
  from math import ceil
8
- from typing import Literal, Optional
8
+ from typing import Literal
9
9
 
10
10
  import numpy as np
11
11
  import torch
12
12
 
13
+ COLOR_CONTEXT = "#4a90d0"
14
+ COLOR_FORECAST = "#d94e4e"
15
+ COLOR_GROUND_TRUTH = "#4a90d0"
16
+ COLOR_CUTOFF_LINE = "#000000"
17
+ COLOR_QUANTILES = "#d94e4e"
18
+ ALPHA_QUANTILES = 0.1
19
+
13
20
 
14
21
  def frequency_resample(
15
22
  ts: torch.Tensor,
@@ -627,3 +634,111 @@ def select_quantile_subset(quantiles: torch.Tensor, quantile_levels: list[float]
627
634
  quantile_levels_idx = [trained_quantiles.index(q) for q in quantile_levels]
628
635
  quantiles_idx = torch.tensor(quantile_levels_idx, dtype=torch.long, device=quantiles.device)
629
636
  return torch.index_select(quantiles, dim=-1, index=quantiles_idx).squeeze(-1)
637
+
638
+
639
+ def plot_forecast(
640
+ context: torch.Tensor | np.ndarray,
641
+ forecasts: torch.Tensor | np.ndarray | None = None,
642
+ ground_truth: torch.Tensor | np.ndarray | None = None,
643
+ ax=None,
644
+ x: Sequence | None = None,
645
+ quantiles: tuple[int, int] = (0, 8),
646
+ ):
647
+ """
648
+ Plots the historical context, optional ground-truth future, and forecast.
649
+
650
+ Parameters
651
+ ----------
652
+ context : torch.Tensor or np.ndarray
653
+ The historical time series data to be plotted.
654
+ forecasts : torch.Tensor or np.ndarray, optional
655
+ The forecasts data including quantiles, of shape [Q, N],
656
+ where Q=9 quantiles are required, and N is the number of forecast timesteps.
657
+ ground_truth : torch.Tensor or np.ndarray, optional
658
+ The actual future data to compare the forecast against.
659
+ ax : matplotlib.Axes, optional
660
+ The matplotlib axes object to plot on.
661
+ x : Sequence, optional
662
+ X-axis values (e.g., timestamps or indices) for the data. The sequence must be slicable.
663
+ quantiles : tuple[int], optional
664
+ A tuple indicating the indices of the quantiles to use to plot as shaded areas
665
+ around the median forecast. Set to None to deactivate. Default is (0, 8).
666
+
667
+ Returns
668
+ -------
669
+ matplotlib.Axes
670
+ The Axes object with the plotted forecast.
671
+ """
672
+ try:
673
+ from matplotlib import pyplot as plt
674
+ except ImportError as e:
675
+ raise ImportError(
676
+ "'plot_forecast' requires matplotlib to be installed. "
677
+ "Please install TiRex package with plotting support via "
678
+ "\"pip install 'tirex-ts[plotting]'\"."
679
+ ) from e
680
+
681
+ if quantiles is not None and len(quantiles) != 2:
682
+ raise ValueError(
683
+ "quantiles must either be a collection of two values for min- and max quantile, respectively, or None."
684
+ )
685
+
686
+ if ax is None:
687
+ # default to current axis
688
+ ax = plt.gca()
689
+
690
+ # determine all lenghts for clarity
691
+ context_size = len(context)
692
+ forecast_size = len(forecasts) if forecasts is not None else 0
693
+ ground_truth_size = len(ground_truth) if ground_truth is not None else 0
694
+ full_size = context_size + max(forecast_size, ground_truth_size)
695
+
696
+ if x is None:
697
+ x = range(full_size)
698
+ elif len(x) < full_size:
699
+ raise ValueError(
700
+ "Not enough 'x' values provided to have one for every timestep in context, forecast, and ground truth window."
701
+ )
702
+
703
+ # plot context
704
+ ax.plot(x[:context_size], context, label="Ground Truth Context", color=COLOR_CONTEXT)
705
+
706
+ # plot ground truth if supplied
707
+ if ground_truth is not None:
708
+ ax.plot(
709
+ x[context_size : context_size + ground_truth_size],
710
+ ground_truth,
711
+ label="Ground Truth Future",
712
+ color=COLOR_GROUND_TRUTH,
713
+ linestyle="--",
714
+ )
715
+
716
+ # plot forecasts if supplied
717
+ # forecasts are a 2D array with quantiles as rows, and data for each timestep as columns
718
+ if forecasts is not None:
719
+ median_forecast = forecasts[:, 4]
720
+ forecast_x = x[context_size : context_size + forecast_size]
721
+ ax.plot(forecast_x, median_forecast, label="Forecast (Median)", color=COLOR_FORECAST)
722
+
723
+ if quantiles is not None:
724
+ min_quantile, max_quantile = quantiles
725
+ lower_bound = forecasts[:, min_quantile]
726
+ upper_bound = forecasts[:, max_quantile]
727
+
728
+ ax.fill_between(
729
+ forecast_x,
730
+ lower_bound,
731
+ upper_bound,
732
+ color=COLOR_QUANTILES,
733
+ alpha=ALPHA_QUANTILES,
734
+ label=f"Forecast {(min_quantile + 1) * 10}% - {(max_quantile + 1) * 10}% Quantiles",
735
+ )
736
+
737
+ if ground_truth is not None or forecasts is not None:
738
+ ax.axvline(x[context_size], color=COLOR_CUTOFF_LINE, linestyle=":")
739
+
740
+ ax.set_xlim(left=x[0])
741
+ ax.legend()
742
+ ax.grid()
743
+
744
+ return ax
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tirex-mirror
3
- Version: 2025.11.7
3
+ Version: 2025.11.12
4
4
  Summary: Unofficial mirror of NX-AI/tirex for packaging
5
5
  Author-email: Arpad Rozsas <rozsasarpi@gmail.com>
6
6
  License: NXAI COMMUNITY LICENSE AGREEMENT
@@ -75,6 +75,8 @@ Requires-Dist: ipykernel; extra == "notebooks"
75
75
  Requires-Dist: matplotlib; extra == "notebooks"
76
76
  Requires-Dist: pandas; extra == "notebooks"
77
77
  Requires-Dist: python-dotenv; extra == "notebooks"
78
+ Provides-Extra: plotting
79
+ Requires-Dist: matplotlib; extra == "plotting"
78
80
  Provides-Extra: gluonts
79
81
  Requires-Dist: gluonts; extra == "gluonts"
80
82
  Requires-Dist: pandas; extra == "gluonts"
@@ -32,6 +32,9 @@ matplotlib
32
32
  pandas
33
33
  python-dotenv
34
34
 
35
+ [plotting]
36
+ matplotlib
37
+
35
38
  [test]
36
39
  fev>=0.6.0
37
40
  pytest