Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enfoce deepcopy for costar to avoid inplace modifications #164

Merged
merged 1 commit into from
May 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ruptures/costs/costautoregressive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
from numpy.lib.stride_tricks import as_strided
from numpy.linalg import lstsq
from copy import deepcopy

from ruptures.base import BaseCost
from ruptures.costs import NotEnoughPoints
Expand Down Expand Up @@ -34,10 +35,9 @@ def fit(self, signal):
Returns:
self: the current object
"""
self.signal = deepcopy(signal)
if signal.ndim == 1:
self.signal = signal.reshape(-1, 1)
else:
self.signal = signal
self.signal = self.signal.reshape(-1, 1)

# lagged covariates
n_samples, _ = self.signal.shape
Expand Down