Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisCarpentier42 committed Dec 5, 2024
1 parent f0f2326 commit d88849c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/semantic_segmentation/test_LogisticRegressionSegmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,40 @@ def test_initialization_additional_args(self):
with pytest.raises(TypeError):
LogisticRegressionSegmentor(something_invalid=0)

def test_fit(self, pattern_based_embedding):
def test_fit(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
clf = LogisticRegressionSegmentor()
assert clf.fit(pattern_based_embedding) == clf

def test_predict_proba(self, pattern_based_embedding):
def test_predict_proba(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
clf = LogisticRegressionSegmentor()
clf.fit(pattern_based_embedding)
pred = clf.predict_proba(pattern_based_embedding)
assert pred.shape[0] == pattern_based_embedding.shape[1]

def test_fit_predict_proba(self, pattern_based_embedding):
def test_fit_predict_proba(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
pred = LogisticRegressionSegmentor().fit_predict_proba(pattern_based_embedding)
assert pred.shape[0] == pattern_based_embedding.shape[1]

def test_fit_predict_proba_one_n_segment(self, pattern_based_embedding):
def test_fit_predict_proba_one_n_segment(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
pred = LogisticRegressionSegmentor(n_segments=3).fit_predict_proba(pattern_based_embedding)
assert pred.shape == (pattern_based_embedding.shape[1], 3)

def test_fit_predict_proba_multiple_jobs(self, pattern_based_embedding):
def test_fit_predict_proba_multiple_jobs(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
pred = LogisticRegressionSegmentor(n_jobs=4).fit_predict_proba(pattern_based_embedding)
assert pred.shape[0] == pattern_based_embedding.shape[1]

def test_predict_proba_not_fitted(self, pattern_based_embedding):
def test_predict_proba_not_fitted(self):
univariate_time_series = np.sin(np.arange(0, 50, 0.05)) + np.random.normal(0, 0.25, 1000)
pattern_based_embedding = PatternBasedEmbedder().fit_transform(univariate_time_series)
with pytest.raises(NotFittedError):
LogisticRegressionSegmentor().predict_proba(pattern_based_embedding)

0 comments on commit d88849c

Please sign in to comment.