From 004a8e3bb94e88849723f726965dd1ab69615fbb Mon Sep 17 00:00:00 2001 From: teobucci Date: Thu, 22 Feb 2024 15:58:02 +0100 Subject: [PATCH] Add specification the shape to avoid "-0" which is not the final element --- src/tefs/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tefs/core.py b/src/tefs/core.py index c972a00..838ee71 100644 --- a/src/tefs/core.py +++ b/src/tefs/core.py @@ -50,7 +50,7 @@ def compute_transfer_entropy( max_lag = max(max(lag_features), max(lag_target), max(lag_conditioning)) # Filling member1 - member1 = np.hstack([X[max_lag - lag : -lag, :] for lag in lag_features]) + member1 = np.hstack([X[max_lag - lag : X.shape[0]-lag, :] for lag in lag_features]) # Filling member2 member2 = np.hstack(Y[max_lag:, :]) @@ -58,9 +58,9 @@ def compute_transfer_entropy( # Filling member3 member3 = np.hstack([ # Filling the part relative the past of the target - *[Y[max_lag - lag : -lag, :] for lag in lag_target], + *[Y[max_lag - lag : Y.shape[0]-lag, :] for lag in lag_target], # Filling the part relative the past of the conditioning features - *[Z[max_lag - lag : -lag, :] for lag in lag_conditioning], + *[Z[max_lag - lag : Z.shape[0]-lag, :] for lag in lag_conditioning], ]) return estimate_cmi(member1, member2, member3, k)