Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed ValueError for constants in arrays #187

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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