Skip to content

Commit

Permalink
Merge pull request #219 from jakobrunge/developer
Browse files Browse the repository at this point in the history
cmisymb now issues warning if non-int array is passed instead of erro…
  • Loading branch information
jakobrunge authored May 16, 2022
2 parents 092b7cd + 8a38102 commit f8f4ebd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 114 deletions.
14 changes: 9 additions & 5 deletions tigramite/independence_tests/cmisymb.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _bincount_hist(self, symb_array, weights=None):
Parameters
----------
symb_array : integer array
Data array of shape (dim, T).
Data array of shape (dim, T). If a float is passed, it will be converted to int.
weights : float array, optional (default: None)
Optional weights array of shape (dim, T).
Expand All @@ -106,17 +106,21 @@ def _bincount_hist(self, symb_array, weights=None):
dimensions with Z-dimensions coming first.
"""

if 'int' not in str(symb_array.dtype):
# raise ValueError("Input data must of integer type, where each "
# "number indexes a symbol.")
warnings.warn("Input data should be of integer type, where each "
"number indexes a symbol. If you provide a float,"
" then the array will still be converted to int.")
symb_array = symb_array.astype('int')

if self.n_symbs is None:
n_symbs = int(symb_array.max() + 1)
else:
n_symbs = self.n_symbs
if n_symbs < int(symb_array.max() + 1):
raise ValueError("n_symbs must be >= symb_array.max() + 1 = {}".format(symb_array.max() + 1))

if 'int' not in str(symb_array.dtype):
raise ValueError("Input data must of integer type, where each "
"number indexes a symbol.")

dim, T = symb_array.shape

flathist = np.zeros((n_symbs ** dim), dtype='int16')
Expand Down
152 changes: 43 additions & 109 deletions tutorials/tigramite_tutorial_sliding_window_analysis.ipynb

Large diffs are not rendered by default.

0 comments on commit f8f4ebd

Please sign in to comment.