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

cmisymb now issues warning if non-int array is passed instead of erro… #219

Merged
merged 1 commit into from
May 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
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.