The core Problem: I have paths saved as a triple nested lists and I fail to index them properly.
Here is a minimal example
l1 = []
l11 = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]
l12 = [[5], [5, 6], [5, 6, 7], [5, 6, 7, 8]]
l1.append(l11)
l1.append(l12)
# Goal:
l_target = [[[1], [1, 2], [1, 2, 3]], [[5], [5, 6], [5, 6, 7]]]
print(l1[:][:4] == l_target)
Explaining the list in question: The first dimension is the number of paths. Each path is a list that represent the values at the different timesteps. Each timestep is a list, where every timestep has a different dimension, which is the reason I have a tripple nested list and not a matrix.
Since this is very confusing here is an example:
For this example my val paths are saved in h1 (usually multiple hundred, I reduced it to 2 for this example). I have expanded the first path and you can see that at time k it consists of all values up to time k.
The problem is that I want a single line code that remove all timesteps after k for all paths.
To me it seemed very simple as "[:][:k]" should do it, however it doesn't change the list at all (see h2 == h1). As stuff like [:, :k] doesn't work either I am quite confused.