-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
164 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,6 @@ cython_debug/ | |
|
||
# vscode | ||
.vscode/ | ||
|
||
# dont att poetry lock to package | ||
poetry.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from jax import numpy as jnp | ||
from jax import random | ||
|
||
from examples.reconciliation import GPForecaster | ||
from reconcile import ProbabilisticReconciliation | ||
from reconcile.data import sample_hierarchical_timeseries | ||
from reconcile.grouping import Grouping | ||
|
||
|
||
@pytest.fixture() | ||
def grouping(): | ||
_, groups = sample_hierarchical_timeseries() | ||
grouping = Grouping(groups) | ||
return grouping | ||
|
||
|
||
@pytest.fixture() | ||
def reconciliator(): | ||
(b, x), groups = sample_hierarchical_timeseries() | ||
grouping = Grouping(groups) | ||
all_timeseries = grouping.all_timeseries(b) | ||
all_features = jnp.tile(x, [1, all_timeseries.shape[1], 1]) | ||
|
||
forecaster = GPForecaster() | ||
forecaster.fit( | ||
random.PRNGKey(1), | ||
all_timeseries[:, :90, :], | ||
all_features[:, :90, :], | ||
100, | ||
) | ||
|
||
recon = ProbabilisticReconciliation(grouping, forecaster) | ||
return (all_timeseries, all_features), recon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import chex | ||
|
||
|
||
def test_grouping_size(grouping): | ||
assert grouping.n_groups == 1 | ||
|
||
|
||
def test_grouping_colnames(grouping): | ||
for e, f in zip( | ||
grouping.all_timeseries_column_names(), | ||
["Total", "A", "B", "A:10", "A:20", "B:10", "B:20", "B:30"], | ||
): | ||
assert e == f | ||
|
||
|
||
def test_grouping_summing_matrix(grouping): | ||
chex.assert_axis_dimension(grouping.summing_matrix().toarray(), 0, 8) | ||
chex.assert_axis_dimension(grouping.summing_matrix().toarray(), 1, 5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import chex | ||
from jax import random | ||
|
||
|
||
def test_fit_reconciliation(reconciliator): | ||
(_, all_features), recon = reconciliator | ||
fit_recon = recon.fit_reconciled_posterior_predictive( | ||
random.PRNGKey(1), all_features, n_samples=100 | ||
) | ||
chex.assert_shape(fit_recon, (100, 5, 100)) | ||
|
||
|
||
def test_sample_reconciliation(reconciliator): | ||
(_, all_features), recon = reconciliator | ||
fit_recon = recon.sample_reconciled_posterior_predictive( | ||
random.PRNGKey(1), all_features, n_warmup=50, n_iter=100 | ||
) | ||
chex.assert_shape(fit_recon, (50, 4, 5, 100)) |