-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,364 additions
and
1,724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Cython==0.20.1 | ||
numpy==1.8.0 | ||
py==1.4.20 | ||
pytest==2.5.2 | ||
wheel==0.23.0 | ||
twine==1.3.0 | ||
Cython>=0.20.2 | ||
numpy>=1.8.0, <2.0.0 | ||
py>=1.4.20 | ||
pytest>=2.5.2 | ||
wheel>=0.23.0 | ||
twine>=1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import unittest | ||
import numpy as np | ||
from pyemd import emd | ||
|
||
|
||
class TestEmd(unittest.TestCase): | ||
def test_case_1(): | ||
first_signature = np.array([0.0, 1.0]) | ||
second_signature = np.array([5.0, 3.0]) | ||
distance_matrix = np.array([[0.0, 0.5], | ||
[0.5, 0.0]]) | ||
assert 3.5 == emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_case_1(self): | ||
first_signature = np.array([0.0, 1.0]) | ||
second_signature = np.array([5.0, 3.0]) | ||
distance_matrix = np.array([[0.0, 0.5], | ||
[0.5, 0.0]]) | ||
assert 3.5 == emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_case_2(self): | ||
first_signature = np.array([1.0, 1.0]) | ||
second_signature = np.array([1.0, 1.0]) | ||
distance_matrix = np.array([[0.0, 1.0], | ||
[1.0, 0.0]]) | ||
assert 0.0 == emd(first_signature, second_signature, distance_matrix) | ||
def test_case_2(): | ||
first_signature = np.array([1.0, 1.0]) | ||
second_signature = np.array([1.0, 1.0]) | ||
distance_matrix = np.array([[0.0, 1.0], | ||
[1.0, 0.0]]) | ||
assert 0.0 == emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_case_3(self): | ||
first_signature = np.array([6.0, 1.0]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[0.0, 0.0], | ||
[0.0, 0.0]]) | ||
assert 0.0 == emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_error_different_signature_lengths(self): | ||
first_signature = np.array([6.0, 1.0, 9.0]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[0.0, 1.0], | ||
[1.0, 0.0]]) | ||
with self.assertRaises(ValueError): | ||
emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_error_wrong_distance_matrix_shape(self): | ||
first_signature = np.array([6.0, 1.0]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[0.0, 1.0, 0.4], | ||
[1.0, 0.0]]) | ||
with self.assertRaises(ValueError): | ||
emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_error_wrong_signature_ndim(self): | ||
first_signature = np.array([[6.0, 1.0]]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[0.0, 1.0], | ||
[1.0, 0.0]]) | ||
with self.assertRaises(ValueError): | ||
emd(first_signature, second_signature, distance_matrix) | ||
|
||
def test_error_wrong_distance_matrix_ndim(self): | ||
first_signature = np.array([6.0, 1.0]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[[0.0, 1.0], | ||
[1.0, 0.0]]]) | ||
with self.assertRaises(ValueError): | ||
emd(first_signature, second_signature, distance_matrix) | ||
def test_case_3(): | ||
first_signature = np.array([6.0, 1.0]) | ||
second_signature = np.array([1.0, 7.0]) | ||
distance_matrix = np.array([[0.0, 0.0], | ||
[0.0, 0.0]]) | ||
assert 0.0 == emd(first_signature, second_signature, distance_matrix) |