summaryrefslogtreecommitdiff
path: root/src/python/test/test_time_delay.py
diff options
context:
space:
mode:
authormtakenouchi <m.takenouchi@jp.fujitsu.com>2020-02-25 13:24:48 +0900
committermtakenouchi <m.takenouchi@jp.fujitsu.com>2020-02-25 13:24:48 +0900
commit66c96498b994fea1fcaa6877121023410f4209f9 (patch)
tree1a5d1590bce9203d1c25c0a7cc35eeb49345016e /src/python/test/test_time_delay.py
parent88964b4ff10798d6d9c3d0a342c004ee6b8b1496 (diff)
Update test_time_delay.py
Diffstat (limited to 'src/python/test/test_time_delay.py')
-rwxr-xr-xsrc/python/test/test_time_delay.py51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/python/test/test_time_delay.py b/src/python/test/test_time_delay.py
index 5464a185..1ead9bca 100755
--- a/src/python/test/test_time_delay.py
+++ b/src/python/test/test_time_delay.py
@@ -1,36 +1,43 @@
from gudhi.point_cloud.timedelay import TimeDelayEmbedding
import numpy as np
+
def test_normal():
# Sample array
ts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Normal case.
prep = TimeDelayEmbedding()
- attractor = prep(ts)
- assert (attractor[0] == np.array([1, 2, 3])).all()
- assert (attractor[1] == np.array([2, 3, 4])).all()
- assert (attractor[2] == np.array([3, 4, 5])).all()
- assert (attractor[3] == np.array([4, 5, 6])).all()
- assert (attractor[4] == np.array([5, 6, 7])).all()
- assert (attractor[5] == np.array([6, 7, 8])).all()
- assert (attractor[6] == np.array([7, 8, 9])).all()
- assert (attractor[7] == np.array([8, 9, 10])).all()
+ pointclouds = prep(ts)
+ assert (pointclouds[0] == np.array([1, 2, 3])).all()
+ assert (pointclouds[1] == np.array([2, 3, 4])).all()
+ assert (pointclouds[2] == np.array([3, 4, 5])).all()
+ assert (pointclouds[3] == np.array([4, 5, 6])).all()
+ assert (pointclouds[4] == np.array([5, 6, 7])).all()
+ assert (pointclouds[5] == np.array([6, 7, 8])).all()
+ assert (pointclouds[6] == np.array([7, 8, 9])).all()
+ assert (pointclouds[7] == np.array([8, 9, 10])).all()
# Delay = 3
prep = TimeDelayEmbedding(delay=3)
- attractor = prep(ts)
- assert (attractor[0] == np.array([1, 4, 7])).all()
- assert (attractor[1] == np.array([2, 5, 8])).all()
- assert (attractor[2] == np.array([3, 6, 9])).all()
- assert (attractor[3] == np.array([4, 7, 10])).all()
+ pointclouds = prep(ts)
+ assert (pointclouds[0] == np.array([1, 4, 7])).all()
+ assert (pointclouds[1] == np.array([2, 5, 8])).all()
+ assert (pointclouds[2] == np.array([3, 6, 9])).all()
+ assert (pointclouds[3] == np.array([4, 7, 10])).all()
# Skip = 3
prep = TimeDelayEmbedding(skip=3)
- attractor = prep(ts)
- assert (attractor[0] == np.array([1, 2, 3])).all()
- assert (attractor[1] == np.array([4, 5, 6])).all()
- assert (attractor[2] == np.array([7, 8, 9])).all()
+ pointclouds = prep(ts)
+ assert (pointclouds[0] == np.array([1, 2, 3])).all()
+ assert (pointclouds[1] == np.array([4, 5, 6])).all()
+ assert (pointclouds[2] == np.array([7, 8, 9])).all()
# Delay = 2 / Skip = 2
prep = TimeDelayEmbedding(delay=2, skip=2)
- attractor = prep(ts)
- assert (attractor[0] == np.array([1, 3, 5])).all()
- assert (attractor[1] == np.array([3, 5, 7])).all()
- assert (attractor[2] == np.array([5, 7, 9])).all()
+ pointclouds = prep(ts)
+ assert (pointclouds[0] == np.array([1, 3, 5])).all()
+ assert (pointclouds[1] == np.array([3, 5, 7])).all()
+ assert (pointclouds[2] == np.array([5, 7, 9])).all()
+
+ # Vector series
+ ts = np.arange(0, 10).reshape(-1, 2)
+ prep = TimeDelayEmbedding(dim=4)
+ prep.fit([ts])
+ assert (prep.transform([ts])[0] == [[0, 1, 2, 3], [2, 3, 4, 5], [4, 5, 6, 7], [6, 7, 8, 9]]).all()