summaryrefslogtreecommitdiff
path: root/src/python/test
diff options
context:
space:
mode:
authorHind-M <hind.montassif@gmail.com>2021-08-11 14:35:25 +0200
committerHind-M <hind.montassif@gmail.com>2021-08-11 14:35:25 +0200
commit575beed582f9288d83a403f4f578731f172f7f5f (patch)
tree3cd25aba0751dcdd0aec279b71543e39191e336a /src/python/test
parentb9160fb8410bbb999913b0b4e91f1aa1ff58d2cd (diff)
Add test for sphere and torus
Fix numerical approximations inconsistencies with dim fraction exponent when generating points as grid on torus Add notes in doc regarding the torus versions use cases
Diffstat (limited to 'src/python/test')
-rwxr-xr-xsrc/python/test/test_datasets_generators.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/python/test/test_datasets_generators.py b/src/python/test/test_datasets_generators.py
new file mode 100755
index 00000000..656c30ee
--- /dev/null
+++ b/src/python/test/test_datasets_generators.py
@@ -0,0 +1,40 @@
+""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ Author(s): Hind Montassif
+
+ Copyright (C) 2021 Inria
+
+ Modification(s):
+ - YYYY/MM Author: Description of the modification
+"""
+
+from gudhi.datasets.generators import points
+from gudhi.datasets.generators import _points
+
+import pytest
+
+def test_sphere():
+ assert _points.sphere(n_samples = 10, ambient_dim = 2, radius = 1., sample = 'random').shape == (10, 2)
+
+ with pytest.raises(ValueError):
+ _points.sphere(n_samples = 10, ambient_dim = 2, radius = 1., sample = 'other')
+
+def test_torus():
+ assert _points.torus(n_samples = 64, dim = 3, sample = 'random').shape == (64, 6)
+ assert _points.torus(n_samples = 64, dim = 3, sample = 'grid').shape == (64, 6)
+
+ assert _points.torus(n_samples = 10, dim = 4, sample = 'random').shape == (10, 8)
+ assert _points.torus(n_samples = 10, dim = 4, sample = 'grid').shape == (1, 8)
+
+ with pytest.raises(ValueError):
+ _points.torus(n_samples = 10, dim = 4, sample = 'other')
+
+def test_torus_full_python():
+ assert points.torus(n_samples = 64, dim = 3, sample = 'random').shape == (64, 6)
+ assert points.torus(n_samples = 64, dim = 3, sample = 'grid').shape == (64, 6)
+
+ assert points.torus(n_samples = 10, dim = 4, sample = 'random').shape == (10, 8)
+ assert points.torus(n_samples = 10, dim = 4, sample = 'grid').shape == (1, 8)
+
+ with pytest.raises(ValueError):
+ points.torus(n_samples = 10, dim = 4, sample = 'other')