diff --git a/setup.py b/setup.py index 5877c4ef..bcdf598b 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tigramite/independence_tests/cmiknn.py b/tigramite/independence_tests/cmiknn.py index e04f1c49..92b480da 100644 --- a/tigramite/independence_tests/cmiknn.py +++ b/tigramite/independence_tests/cmiknn.py @@ -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. @@ -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': @@ -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!") diff --git a/tigramite/independence_tests/gpdc.py b/tigramite/independence_tests/gpdc.py index fc7812e6..554aedce 100644 --- a/tigramite/independence_tests/gpdc.py +++ b/tigramite/independence_tests/gpdc.py @@ -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, " diff --git a/tigramite/independence_tests/gpdc_torch.py b/tigramite/independence_tests/gpdc_torch.py index 3efacb8c..26bd8714 100644 --- a/tigramite/independence_tests/gpdc_torch.py +++ b/tigramite/independence_tests/gpdc_torch.py @@ -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, " diff --git a/tigramite/independence_tests/parcorr.py b/tigramite/independence_tests/parcorr.py index 8a55a337..bdcccdf9 100644 --- a/tigramite/independence_tests/parcorr.py +++ b/tigramite/independence_tests/parcorr.py @@ -8,6 +8,7 @@ from scipy import stats import numpy as np import sys +import warnings from .independence_tests_base import CondIndTest @@ -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, "