def _discount(self, x): a = np.asarray(x) return lfilter([1], [1, -self.discount_factor], a[::-1], axis=0)[::-1]