From 850c0947e4220b6ffd38b5871e918c2f20d6909f Mon Sep 17 00:00:00 2001 From: Alexandre Blanc <alexandre.blanc@pasteur.fr> Date: Wed, 25 Sep 2024 18:03:01 +0200 Subject: [PATCH] ADD int int temporal slicing to trx --- src/pytrxmat/trx.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pytrxmat/trx.py b/src/pytrxmat/trx.py index 8c2e01c..597f884 100644 --- a/src/pytrxmat/trx.py +++ b/src/pytrxmat/trx.py @@ -107,6 +107,7 @@ class TRX: * tuple(float, float) : return all times t_sel such that t[0] <= t_sel < t[1]. * tuple(float, int) : return up to t[1] points after the intial time t[0]. * tuple(int, float) : return up to t[0] points before the finalal time t[1]. + * tuple(int, int) : slice the time axis along t[0]:t[1]. There is no guarantee that the shapes are the same across larvae due to missing data. If no points verify the condition, returns an array whith second dimension equal to 0. @@ -159,8 +160,10 @@ class TRX: arrays = [a[:, s:s+t2] if s is not None else np.empty((a.shape[0],0)) for a, s in zip(arrays, start_points)] elif isinstance(t1, int) and isinstance(t2, float): raise NotImplementedError() + elif isinstance(t1, int) and isinstance(t2, int): + arrays = [a[:, t1:t2] for a in arrays] else: - raise ValueError("'t' can only be of type Tuple(float, float), Tuple(float, int), or Tuple(int, float)") + raise ValueError("'t' can only be of type Tuple(float, float), Tuple(float, int), Tuple(int, int), or Tuple(int, float)") if 'return_columns' in kwargs and kwargs['return_columns']: return arrays, columns -- GitLab