diff --git a/mkdocstrings_parser/parser.py b/mkdocstrings_parser/parser.py
index fb91c7b..975a938 100644
--- a/mkdocstrings_parser/parser.py
+++ b/mkdocstrings_parser/parser.py
@@ -10,7 +10,6 @@
# Suppress griffe warnings
logging.getLogger("griffe").setLevel(logging.ERROR)
-
class MkDocstringsParser:
def __init__(self):
pass
@@ -136,6 +135,18 @@ def generate_documentation(self, module_path: str, options: Dict[str, Any]) -> s
markdown_docs = render_object_docs(obj, config) # type: ignore
markdown_docs = markdown_docs.replace(f"### `{to_replace}.", "### `")
+ # Fix double backslashes in inline math equations
+ markdown_docs = re.sub(
+ r"\$([^$]+)\$",
+ lambda m: "$" + m.group(1).replace("\\\\", "\\") + "$",
+ markdown_docs
+ )
+ # Fix underscores in inline math equations
+ markdown_docs = re.sub(
+ r"\$([^$]+)\$",
+ lambda m: "$" + m.group(1).replace("\_", "_") + "$",
+ markdown_docs
+ )
return markdown_docs
diff --git a/pyproject.toml b/pyproject.toml
index b5b8bdf..1b711cd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,9 +7,9 @@ name = "mkdocstrings-parser"
version = "0.0.1"
description = "A simple parser for mkdocstrings signature blocks"
readme = "README.md"
-requires-python = ">=3.8"
+requires-python = ">=3.9"
dependencies = [
- "griffe2md<1.3",
+ "griffe2md",
"pip-licenses>=4.5.1",
"pyyaml",
"rich",
@@ -19,16 +19,18 @@ dependencies = [
dev = [
"pytest",
"pytest-cov",
+ "lightgbm<4.6"
]
nixtlaverse = [
- "coreforecast",
- "utilsforecast",
- "datasetsforecast",
- "mlforecast[dask]",
- "hierarchicalforecast",
- "neuralforecast",
- "statsforecast",
- "nixtla"
+ "coreforecast@git+https://github.com/Nixtla/coreforecast.git",
+ "utilsforecast@git+https://github.com/Nixtla/utilsforecast.git",
+ "datasetsforecast@git+https://github.com/Nixtla/datasetsforecast.git",
+ "mlforecast[dask]@git+https://github.com/Nixtla/mlforecast.git",
+ "mlforecast@git+https://github.com/Nixtla/mlforecast.git",
+ "hierarchicalforecast@git+https://github.com/Nixtla/hierarchicalforecast.git@fix/docs",
+ "neuralforecast@git+https://github.com/Nixtla/neuralforecast.git",
+ "statsforecast@git+https://github.com/Nixtla/statsforecast.git",
+ "nixtla@git+https://github.com/Nixtla/nixtla.git"
]
optional = ["pandas"]
diff --git a/tests/test_datasetsforecast.py b/tests/test_datasetsforecast.py
index 367febc..f6387f2 100644
--- a/tests/test_datasetsforecast.py
+++ b/tests/test_datasetsforecast.py
@@ -51,13 +51,7 @@ def test_yearly_dataclass(setup_parser):
@pytest.mark.datasets
def test_download_file(setup_parser):
- fn = """::: datasetsforecast.utils.download_file
- handler: python
- options:
- docstring_style: numpy
- heading_level: 3
- show_root_heading: true
- show_source: true"""
+ fn = "::: datasetsforecast.utils.download_file"
rendered = setup_parser.process_markdown(fn)
assert rendered == """### `download_file`
@@ -72,7 +66,7 @@ def test_download_file(setup_parser):
Name | Type | Description | Default
---- | ---- | ----------- | -------
-`directory` | [str](#str) | Custom directory where data will be downloaded. | *required*
+`directory` | ([str](#str), [Path](#pathlib.Path)) | Custom directory where data will be downloaded. | *required*
`source_url` | [str](#str) | URL where data is hosted. | *required*
`decompress` | [bool](#bool) | Wheter decompress downloaded file. Default False. | False
"""
\ No newline at end of file
diff --git a/tests/test_hierarchicalforecast.py b/tests/test_hierarchicalforecast.py
index 58c9ef8..b752959 100644
--- a/tests/test_hierarchicalforecast.py
+++ b/tests/test_hierarchicalforecast.py
@@ -167,7 +167,7 @@ def test_bottomup(setup_parser):
the first time by Orcutt in 1968.
The corresponding hierarchical "projection" matrix is defined as:
$$
-\\\\mathbf{P}_{\\\\text{BU}} = \\[\\\\mathbf{0}_{\\\\mathrm{[b],[a]}};|;\\\\mathbf{I}\\_{\\\\mathrm{[b][b]}}\\]
+\\mathbf{P}_{\\text{BU}} = \[\\mathbf{0}_{\\mathrm{[b],[a]}};|;\\mathbf{I}\_{\\mathrm{[b][b]}}\]
$$
@@ -235,4 +235,108 @@ def test_bottomup(setup_parser):
Name | Type | Description
---- | ---- | -----------
`dict` | | y_tilde: Reconciliated y_hat using the Bottom Up approach.
-"""
\ No newline at end of file
+"""
+
+def test_topdown(setup_parser):
+ fn = """::: hierarchicalforecast.methods.TopDown
+ handler: python
+ options:
+ docstring_style: google
+ members:
+ - fit
+ - predict
+ - fit_predict
+ - sample
+ inherited_members: false
+ heading_level: 3
+ show_root_heading: true
+ show_source: true"""
+ output = setup_parser.process_markdown(fn)
+ assert output == """### `TopDown`
+
+```python
+TopDown(method)
+```
+
+Bases: [HReconciler](#hierarchicalforecast.methods.HReconciler)
+
+Top Down Reconciliation Class.
+
+The Top Down hierarchical reconciliation method, distributes the total aggregate predictions and decomposes
+it down the hierarchy using proportions $\mathbf{p}_{\mathrm{[b]}}$ that can be actual historical values
+or estimated.
+
+```math
+\mathbf{P}=[\mathbf{p}_{\mathrm{[b]}}\;|\;\mathbf{0}_{\mathrm{[b][a,b\;-1]}}]
+```
+
+**Parameters:**
+
+Name | Type | Description | Default
+---- | ---- | ----------- | -------
+`method` | [str](#str) | One of `forecast_proportions`, `average_proportions` and `proportion_averages`. | *required*
+
+References:
+
+- [CW. Gross (1990). "Disaggregation methods to expedite product line forecasting". Journal of Forecasting, 9 , 233-254. doi:10.1002/for.3980090304](https://onlinelibrary.wiley.com/doi/abs/10.1002/for.3980090304).
+- [G. Fliedner (1999). "An investigation of aggregate variable time series forecast strategies with specific subaggregate time series statistical correlation". Computers and Operations Research, 26 , 1133-1149. doi:10.1016/S0305-0548(99)00017-9]().
+
+#### `TopDown.fit`
+
+```python
+fit(S, y_hat, y_insample, y_hat_insample=None, sigmah=None, intervals_method=None, num_samples=None, seed=None, tags=None, idx_bottom=None)
+```
+
+TopDown Fit Method.
+
+**Parameters:**
+
+Name | Type | Description | Default
+---- | ---- | ----------- | -------
+`S` | [ndarray](#numpy.ndarray) | Summing matrix of size (`base`, `bottom`). | *required*
+`y_hat` | [ndarray](#numpy.ndarray) | Forecast values of size (`base`, `horizon`). | *required*
+`y_insample` | [ndarray](#numpy.ndarray) | Insample values of size (`base`, `insample_size`). Optional for `forecast_proportions` method. | *required*
+`y_hat_insample` | [ndarray](#numpy.ndarray) | Insample forecast values of size (`base`, `insample_size`). Optional for `forecast_proportions` method. | None
+`sigmah` | [ndarray](#numpy.ndarray) | Estimated standard deviation of the conditional marginal distribution. | None
+`interval_method` | [str](#str) | Sampler for prediction intervals, one of `normality`, `bootstrap`, `permbu`. | *required*
+`num_samples` | [int](#int) | Number of samples for probabilistic coherent distribution. | None
+`seed` | [int](#int) | Seed for reproducibility. | None
+`tags` | [dict](#dict)\[[str](#str), [ndarray](#numpy.ndarray)\] | Each key is a level and each value its `S` indices. | None
+`idx_bottom` | [ndarray](#numpy.ndarray) | Indices corresponding to the bottom level of `S`, size (`bottom`). | None
+
+**Returns:**
+
+Name | Type | Description
+---- | ---- | -----------
+`TopDown` | [object](#object) | fitted reconciler.
+
+#### `TopDown.fit_predict`
+
+```python
+fit_predict(S, y_hat, tags, idx_bottom=None, y_insample=None, y_hat_insample=None, sigmah=None, level=None, intervals_method=None, num_samples=None, seed=None)
+```
+
+Top Down Reconciliation Method.
+
+**Parameters:**
+
+Name | Type | Description | Default
+---- | ---- | ----------- | -------
+`S` | [ndarray](#numpy.ndarray) | Summing matrix of size (`base`, `bottom`). | *required*
+`y_hat` | [ndarray](#numpy.ndarray) | Forecast values of size (`base`, `horizon`). | *required*
+`tags` | [dict](#dict)\[[str](#str), [ndarray](#numpy.ndarray)\] | Each key is a level and each value its `S` indices. | *required*
+`idx_bottom` | [ndarray](#numpy.ndarray) | Indices corresponding to the bottom level of `S`, size (`bottom`). Default is None. | None
+`y_insample` | [ndarray](#numpy.ndarray) | Insample values of size (`base`, `insample_size`). Optional for `forecast_proportions` method. Default is None. | None
+`y_hat_insample` | [ndarray](#numpy.ndarray) | Insample forecast values of size (`base`, `insample_size`). Optional for `forecast_proportions` method. Default is None. | None
+`sigmah` | [ndarray](#numpy.ndarray) | Estimated standard deviation of the conditional marginal distribution. Default is None. | None
+`level` | [list](#list)\[[int](#int)\] | float list 0-100, confidence levels for prediction intervals. Default is None. | None
+`intervals_method` | [str](#str) | Sampler for prediction intervals, one of `normality`, `bootstrap`, `permbu`. Default is None. | None
+`num_samples` | [int](#int) | Number of samples for probabilistic coherent distribution. Default is None. | None
+`seed` | [int](#int) | Seed for reproducibility. | None
+
+**Returns:**
+
+Name | Type | Description
+---- | ---- | -----------
+`y_tilde` | [ndarray](#numpy.ndarray) | Reconciliated y_hat using the Top Down approach.
+"""
diff --git a/tests/test_utilsforecast.py b/tests/test_utilsforecast.py
index 5460604..b831bfb 100644
--- a/tests/test_utilsforecast.py
+++ b/tests/test_utilsforecast.py
@@ -12,7 +12,7 @@ def test_utilsforecast_rmae(setup_parser):
assert output == """### `rmae`
```python
-rmae(df, models, baseline, id_col='unique_id', target_col='y')
+rmae(df, models, baseline, id_col='unique_id', target_col='y', cutoff_col='cutoff')
```
Relative Mean Absolute Error (RMAE)
@@ -30,10 +30,11 @@ def test_utilsforecast_rmae(setup_parser):
`baseline` | [str](#str) | Column that identifies the baseline model predictions. | *required*
`id_col` | [str](#str) | Column that identifies each serie. Defaults to 'unique_id'. | 'unique_id'
`target_col` | [str](#str) | Column that contains the target. Defaults to 'y'. | 'y'
+`cutoff_col` | [str](#str) | Column that identifies the cutoff point for each forecast cross-validation fold. Defaults to 'cutoff'. | 'cutoff'
**Returns:**
Type | Description
---- | -----------
-[DFType](#utilsforecast.compat.DFType) | pandas or polars DataFrame: dataframe with one row per id and one column per model.
+[IntoDataFrameT](#narwhals.stable.v2.typing.IntoDataFrameT) | pandas or polars DataFrame: dataframe with one row per id and one column per model.
"""