Making sure that all trajectories are numpy arrays

There was a small bug on gradient, in which not all trajectories where numpy arrays. This PR fixes this issue