Skip to content

Commit

Permalink
Merge pull request #187 from jakobrunge/developer
Browse files Browse the repository at this point in the history
removed ValueError for constants in arrays
  • Loading branch information
jakobrunge authored Mar 16, 2022
2 parents 29c5579 + 72072c4 commit fcbd87c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run(self):
# Run the setup
setup(
name="tigramite",
version="5.0.0.6",
version="5.0.0.7",
packages=["tigramite", "tigramite.independence_tests", "tigramite.toymodels"],
license="GNU General Public License v3.0",
description="Tigramite causal discovery for time series",
Expand Down
11 changes: 7 additions & 4 deletions tigramite/independence_tests/cmiknn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from .independence_tests_base import CondIndTest
from numba import jit

import warnings

class CMIknn(CondIndTest):
r"""Conditional mutual information test based on nearest-neighbor estimator.
Expand Down Expand Up @@ -169,9 +169,10 @@ def _get_nearest_neighbors(self, array, xyz, knn):
# array /= array.std(axis=1).reshape(dim, 1)
# FIXME: If the time series is constant, return nan rather than
# raising Exception
# if np.isnan(array).sum() != 0:
# raise ValueError("nans after standardizing, "
# "possibly constant array!")
if np.any(std == 0.):
warnings.warn("Possibly constant array!")
# raise ValueError("nans after standardizing, "
# "possibly constant array!")
elif self.transform == 'uniform':
array = self._trafo2uniform(array)
elif self.transform == 'ranks':
Expand Down Expand Up @@ -387,6 +388,8 @@ def get_conditional_entropy(self, array, xyz):
# array /= array.std(axis=1).reshape(dim, 1)
# FIXME: If the time series is constant, return nan rather than
# raising Exception
if np.any(std == 0.):
warnings.warn("Possibly constant array!")
# if np.isnan(array).sum() != 0:
# raise ValueError("nans after standardizing, "
# "possibly constant array!")
Expand Down
2 changes: 2 additions & 0 deletions tigramite/independence_tests/gpdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def _get_single_residuals(self, array, target_var,
for i in range(dim):
if std[i] != 0.:
array[i] /= std[i]
if np.any(std == 0.):
warnings.warn("Possibly constant array!")
# array /= array.std(axis=1).reshape(dim, 1)
# if np.isnan(array).sum() != 0:
# raise ValueError("nans after standardizing, "
Expand Down
2 changes: 2 additions & 0 deletions tigramite/independence_tests/gpdc_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def _get_single_residuals(self, array, target_var,
for i in range(dim):
if std[i] != 0.:
array[i] /= std[i]
if np.any(std == 0.):
warnings.warn("Possibly constant array!")
# array /= array.std(axis=1).reshape(dim, 1)
# if np.isnan(array).any():
# raise ValueError("Nans after standardizing, "
Expand Down
3 changes: 3 additions & 0 deletions tigramite/independence_tests/parcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from scipy import stats
import numpy as np
import sys
import warnings

from .independence_tests_base import CondIndTest

Expand Down Expand Up @@ -95,6 +96,8 @@ def _get_single_residuals(self, array, target_var,
for i in range(dim):
if std[i] != 0.:
array[i] /= std[i]
if np.any(std == 0.):
warnings.warn("Possibly constant array!")
# array /= array.std(axis=1).reshape(dim, 1)
# if np.isnan(array).sum() != 0:
# raise ValueError("nans after standardizing, "
Expand Down

0 comments on commit fcbd87c

Please sign in to comment.