From f0c12fbdce04d09bf13b141d549e5e385c64caad Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 1 Jun 2021 18:39:31 +0200 Subject: First version allowing to fetch remote datasets --- src/python/CMakeLists.txt | 2 + src/python/gudhi/datasets/remote.py | 85 +++++++++++++++++++++++++++++++++ src/python/test/test_remote_datasets.py | 22 +++++++++ 3 files changed, 109 insertions(+) create mode 100644 src/python/gudhi/datasets/remote.py create mode 100644 src/python/test/test_remote_datasets.py (limited to 'src') diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 98f2b85f..6f117588 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -542,6 +542,8 @@ if(PYTHONINTERP_FOUND) add_gudhi_py_test(test_dtm_rips_complex) endif() + # Fetch remote datasets + add_gudhi_py_test(test_remote_datasets) # Set missing or not modules set(GUDHI_MODULES ${GUDHI_MODULES} "python" CACHE INTERNAL "GUDHI_MODULES") diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py new file mode 100644 index 00000000..27076785 --- /dev/null +++ b/src/python/gudhi/datasets/remote.py @@ -0,0 +1,85 @@ +# 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 + +import hashlib + +from os.path import join, exists +from os import makedirs + +from urllib.request import urlretrieve + + +def _checksum_sha256(file_path): + """ + Compute the file checksum using sha256 + + Parameters + ---------- + file_path: string + Full path of the created file. + + Returns + ------- + The hex digest of file_path + """ + sha256_hash = hashlib.sha256() + chunk_size = 4096 + with open(file_path,"rb") as f: + # Read and update hash string value in blocks of 4K + while True: + buffer = f.read(chunk_size) + if not buffer: + break + sha256_hash.update(buffer) + return sha256_hash.hexdigest() + +def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, file_checksum = None): + """ + Fetch the wanted dataset from the given url and save it in file_path + + Parameters + ---------- + url : string + The url to fetch the dataset from + filename : string + The filename to download + dirname : string + The directory to save the file to. + checksum_flag : boolean + To set if the user wants the file checksum. Default is 'False'. + Note that if checksum_flag is set to 'True', the file_checksum must be provided. + file_checksum : string + The file checksum using sha256 to check against the one computed on the downloaded file. + To be considered, checksum_flag must be set to 'True'. + Default is 'None'. + + Returns + ------- + file_path: string + Full path of the created file. + """ + if not exists(dirname): + makedirs(dirname) + + file_path = join(dirname, filename) + + urlretrieve(url, file_path) + + if (checksum_flag): + if file_checksum is None: + raise ValueError("The file checksum must be provided - different from None - for the check to be performed.") + + checksum = _checksum_sha256(file_path) + if file_checksum != checksum: + raise IOError("{} has a SHA256 checksum : {}, " + "different from expected : {}." + "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, + file_checksum)) + + return file_path diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py new file mode 100644 index 00000000..c4e752a7 --- /dev/null +++ b/src/python/test/test_remote_datasets.py @@ -0,0 +1,22 @@ +# 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 import remote + +def test_fetch_remote_datasets(): + # Test files download from given urls + assert 'remote_datasets/spiral_2d.csv' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv") + assert 'remote_datasets/sphere3D_pts_on_grid.off' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") + + # Test files download with checksums provided + assert 'remote_datasets/spiral_2d.csv' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, + file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + assert 'remote_datasets/sphere3D_pts_on_grid.off' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", + checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') -- cgit v1.2.3 From c2f0cf79af04ea3586a70c0a121a200353e989ac Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Jun 2021 11:30:09 +0200 Subject: Add wrapping function to fecth spiral_2d.csv directly --- src/python/gudhi/datasets/remote.py | 24 +++++++++++++++++++++--- src/python/test/test_remote_datasets.py | 3 +++ 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 27076785..4a300b15 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -46,11 +46,11 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil Parameters ---------- url : string - The url to fetch the dataset from + The url to fetch the dataset from. filename : string - The filename to download + The name to give to downloaded file. dirname : string - The directory to save the file to. + The directory to save the file to. Default is "remote_datasets". checksum_flag : boolean To set if the user wants the file checksum. Default is 'False'. Note that if checksum_flag is set to 'True', the file_checksum must be provided. @@ -83,3 +83,21 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil file_checksum)) return file_path + +def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): + """ + Fetch spiral_2d.csv remotely + + Parameters + ---------- + filename : string + The name to give to downloaded file. Default is "spiral_2d.csv" + dirname : string + The directory to save the file to. Default is "remote_datasets". + + Returns + ------- + file_path: string + Full path of the created file. + """ + return fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", filename, dirname, True, '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index c4e752a7..dc854e25 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -20,3 +20,6 @@ def test_fetch_remote_datasets(): file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') assert 'remote_datasets/sphere3D_pts_on_grid.off' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') + + # Test spiral_2d.csv wrapping function + assert 'remote_datasets/spiral_2d.csv' == remote.fetch_spiral_2d() -- cgit v1.2.3 From baa2e67036dae8ec63321a4d9ff4e913780a8757 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Jun 2021 16:00:40 +0200 Subject: Modify test to consider both slash and backslash in the returned file path --- src/python/test/test_remote_datasets.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index dc854e25..a822ebaa 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -9,17 +9,36 @@ from gudhi.datasets import remote +import re def test_fetch_remote_datasets(): # Test files download from given urls - assert 'remote_datasets/spiral_2d.csv' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv") - assert 'remote_datasets/sphere3D_pts_on_grid.off' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") + path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv") + names_dw = re.split(r' |/|\\', path_file_dw) + assert 'remote_datasets' == names_dw[0] + assert 'spiral_2d.csv' == names_dw[1] + + path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") + names_dw = re.split(r' |/|\\', path_file_dw) + assert 'remote_datasets' == names_dw[0] + assert 'sphere3D_pts_on_grid.off' == names_dw[1] + # Test files download with checksums provided - assert 'remote_datasets/spiral_2d.csv' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, + path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') - assert 'remote_datasets/sphere3D_pts_on_grid.off' == remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", + names_dw = re.split(r' |/|\\', path_file_dw) + assert 'remote_datasets' == names_dw[0] + assert 'spiral_2d.csv' == names_dw[1] + + path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') + names_dw = re.split(r' |/|\\', path_file_dw) + assert 'remote_datasets' == names_dw[0] + assert 'sphere3D_pts_on_grid.off' == names_dw[1] # Test spiral_2d.csv wrapping function - assert 'remote_datasets/spiral_2d.csv' == remote.fetch_spiral_2d() + path_file_dw = remote.fetch_spiral_2d() + names_dw = re.split(r' |/|\\', path_file_dw) + assert 'remote_datasets' == names_dw[0] + assert 'spiral_2d.csv' == names_dw[1] -- cgit v1.2.3 From 3ee453718eebc7274b19caef4b79d8ec2754d583 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Thu, 3 Jun 2021 16:40:59 +0200 Subject: Modify urls to point to GUDHI/gudhi-data repo --- src/python/gudhi/datasets/remote.py | 3 ++- src/python/test/test_remote_datasets.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 4a300b15..525a7b66 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -100,4 +100,5 @@ def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): file_path: string Full path of the created file. """ - return fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", filename, dirname, True, '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, True, + '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index a822ebaa..63ad7885 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -13,25 +13,25 @@ import re def test_fetch_remote_datasets(): # Test files download from given urls - path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv") + path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] assert 'spiral_2d.csv' == names_dw[1] - path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") + path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] assert 'sphere3D_pts_on_grid.off' == names_dw[1] # Test files download with checksums provided - path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, + path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] assert 'spiral_2d.csv' == names_dw[1] - path_file_dw = remote.fetch("https://raw.githubusercontent.com/Hind-M/gudhi-data/main/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", + path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] -- cgit v1.2.3 From bbe2e25a204be50eb422db71b4cf314b92797d4e Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 4 Jun 2021 12:21:11 +0200 Subject: Remove checksum_flag parameter and use value of 'file_checksum is not None' instead --- src/python/gudhi/datasets/remote.py | 13 +++---------- src/python/test/test_remote_datasets.py | 7 ++++--- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 525a7b66..fdd20f74 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -39,7 +39,7 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, file_checksum = None): +def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): """ Fetch the wanted dataset from the given url and save it in file_path @@ -51,12 +51,8 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil The name to give to downloaded file. dirname : string The directory to save the file to. Default is "remote_datasets". - checksum_flag : boolean - To set if the user wants the file checksum. Default is 'False'. - Note that if checksum_flag is set to 'True', the file_checksum must be provided. file_checksum : string The file checksum using sha256 to check against the one computed on the downloaded file. - To be considered, checksum_flag must be set to 'True'. Default is 'None'. Returns @@ -71,10 +67,7 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil urlretrieve(url, file_path) - if (checksum_flag): - if file_checksum is None: - raise ValueError("The file checksum must be provided - different from None - for the check to be performed.") - + if file_checksum is not None: checksum = _checksum_sha256(file_path) if file_checksum != checksum: raise IOError("{} has a SHA256 checksum : {}, " @@ -100,5 +93,5 @@ def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): file_path: string Full path of the created file. """ - return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, True, + return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 63ad7885..6c9217c8 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -25,14 +25,15 @@ def test_fetch_remote_datasets(): # Test files download with checksums provided - path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True, - file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", + file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] assert 'spiral_2d.csv' == names_dw[1] path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", - checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') + file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') + names_dw = re.split(r' |/|\\', path_file_dw) assert 'remote_datasets' == names_dw[0] assert 'sphere3D_pts_on_grid.off' == names_dw[1] -- cgit v1.2.3 From f7b4d9f3ed0b0c386204077ea53a22e2dba527fc Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 4 Jun 2021 15:06:57 +0200 Subject: Check if the wanted file already exists locally before downloading --- src/python/gudhi/datasets/remote.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index fdd20f74..b266467d 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -60,20 +60,24 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): file_path: string Full path of the created file. """ - if not exists(dirname): - makedirs(dirname) file_path = join(dirname, filename) - urlretrieve(url, file_path) - - if file_checksum is not None: - checksum = _checksum_sha256(file_path) - if file_checksum != checksum: - raise IOError("{} has a SHA256 checksum : {}, " - "different from expected : {}." - "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, - file_checksum)) + # Check that an existing file does not already exist at file_path + if not exists(file_path): + # Create directory if not existing + if not exists(dirname): + makedirs(dirname) + + urlretrieve(url, file_path) + + if file_checksum is not None: + checksum = _checksum_sha256(file_path) + if file_checksum != checksum: + raise IOError("{} has a SHA256 checksum : {}, " + "different from expected : {}." + "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, + file_checksum)) return file_path -- cgit v1.2.3 From 16867ca9321e50531307253e957b91c4df7e564c Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 4 Jun 2021 16:39:16 +0200 Subject: Verify checksum even for already existing files locally --- src/python/gudhi/datasets/remote.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index b266467d..aef4b277 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -63,7 +63,7 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): file_path = join(dirname, filename) - # Check that an existing file does not already exist at file_path + # Check for an already existing file at file_path if not exists(file_path): # Create directory if not existing if not exists(dirname): @@ -71,13 +71,12 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): urlretrieve(url, file_path) - if file_checksum is not None: - checksum = _checksum_sha256(file_path) - if file_checksum != checksum: - raise IOError("{} has a SHA256 checksum : {}, " - "different from expected : {}." - "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, - file_checksum)) + if file_checksum is not None: + checksum = _checksum_sha256(file_path) + if file_checksum != checksum: + raise IOError("{} has a SHA256 checksum : {}, " + "different from expected : {}." + "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, file_checksum)) return file_path -- cgit v1.2.3 From 82524c5b0a6ab02b020574b2200a8721f3ed424c Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 7 Jun 2021 15:03:14 +0200 Subject: Add test with wrong checksum Add functions to avoid redundant code --- src/python/test/test_remote_datasets.py | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 6c9217c8..e252980d 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -10,36 +10,37 @@ from gudhi.datasets import remote import re +import os.path +import pytest -def test_fetch_remote_datasets(): - # Test files download from given urls - path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") - names_dw = re.split(r' |/|\\', path_file_dw) - assert 'remote_datasets' == names_dw[0] - assert 'spiral_2d.csv' == names_dw[1] +def check_dir_file_names(path_file_dw, filename, dirname): + assert os.path.isfile(path_file_dw) - path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") names_dw = re.split(r' |/|\\', path_file_dw) - assert 'remote_datasets' == names_dw[0] - assert 'sphere3D_pts_on_grid.off' == names_dw[1] + assert dirname == names_dw[0] + assert filename == names_dw[1] +def check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): + path_file_dw = remote.fetch(url, filename, dirname, file_checksum) + check_dir_file_names(path_file_dw, filename, dirname) + +def test_fetch_remote_datasets(): + # Test fetch with a wrong checksum + with pytest.raises(OSError): + check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = 'XXXXXXXXXX') - # Test files download with checksums provided - path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", + # Test files download from given urls with checksums provided + check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') - names_dw = re.split(r' |/|\\', path_file_dw) - assert 'remote_datasets' == names_dw[0] - assert 'spiral_2d.csv' == names_dw[1] - path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", + check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') - names_dw = re.split(r' |/|\\', path_file_dw) - assert 'remote_datasets' == names_dw[0] - assert 'sphere3D_pts_on_grid.off' == names_dw[1] + # Test files download from given urls without checksums + check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") + + check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") # Test spiral_2d.csv wrapping function path_file_dw = remote.fetch_spiral_2d() - names_dw = re.split(r' |/|\\', path_file_dw) - assert 'remote_datasets' == names_dw[0] - assert 'spiral_2d.csv' == names_dw[1] + check_dir_file_names(path_file_dw, 'spiral_2d.csv', 'remote_datasets') -- cgit v1.2.3 From 8749199e00c0ed1c32b8e0198a65797de3ad192a Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 27 Sep 2021 15:19:25 +0200 Subject: Add option in cmake to enable or not the inclusion of datasets fetching test (disabled by default) --- src/cmake/modules/GUDHI_modules.cmake | 11 ++++++----- src/python/CMakeLists.txt | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index ccaf1ac5..9cc1a8f5 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -17,11 +17,12 @@ function(add_gudhi_module file_path) endfunction(add_gudhi_module) -option(WITH_GUDHI_BENCHMARK "Activate/desactivate benchmark compilation" OFF) -option(WITH_GUDHI_EXAMPLE "Activate/desactivate examples compilation and installation" OFF) -option(WITH_GUDHI_PYTHON "Activate/desactivate python module compilation and installation" ON) -option(WITH_GUDHI_TEST "Activate/desactivate examples compilation and installation" ON) -option(WITH_GUDHI_UTILITIES "Activate/desactivate utilities compilation and installation" ON) +option(WITH_GUDHI_BENCHMARK "Activate/deactivate benchmark compilation" OFF) +option(WITH_GUDHI_EXAMPLE "Activate/deactivate examples compilation and installation" OFF) +option(WITH_NETWORK "Activate/deactivate datasets fetching test which uses the Internet" OFF) +option(WITH_GUDHI_PYTHON "Activate/deactivate python module compilation and installation" ON) +option(WITH_GUDHI_TEST "Activate/deactivate examples compilation and installation" ON) +option(WITH_GUDHI_UTILITIES "Activate/deactivate utilities compilation and installation" ON) if (WITH_GUDHI_BENCHMARK) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};benchmark") diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 6f117588..6c8dfe32 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -543,7 +543,9 @@ if(PYTHONINTERP_FOUND) endif() # Fetch remote datasets - add_gudhi_py_test(test_remote_datasets) + if(WITH_NETWORK) + add_gudhi_py_test(test_remote_datasets) + endif() # Set missing or not modules set(GUDHI_MODULES ${GUDHI_MODULES} "python" CACHE INTERNAL "GUDHI_MODULES") -- cgit v1.2.3 From 613db2444a9a12a64b097b944d0180e4fdbff71f Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 27 Sep 2021 17:32:55 +0200 Subject: Document option WITH_NETWORK in installation manual and tests_strategy Enable WITH_NETWORK option in some of the CI platforms (for a minimal testing) --- .appveyor.yml | 5 ++++- .circleci/config.yml | 18 ++++++++++++++++++ .github/for_maintainers/tests_strategy.md | 4 +++- src/common/doc/installation.h | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/.appveyor.yml b/.appveyor.yml index 9ff8f157..b44e08e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -29,6 +29,9 @@ environment: - target: Python CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON + - target: PythonTestsWithNetwork + CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON + cache: - c:\Tools\vcpkg\installed @@ -56,7 +59,7 @@ build_script: - mkdir build - cd build - cmake -G "Visual Studio 15 2017 Win64" %CMAKE_FLAGS% %CMAKE_GMP_FLAGS% %CMAKE_MPFR_FLAGS% %CMAKE_VCPKG_FLAGS% .. - - if [%target%]==[Python] ( + - if [[%target%]==[Python] || [%target%]==[PythonTestsWithNetwork]] ( cd src/python & type setup.py & MSBuild Cython.sln /m /p:Configuration=Release /p:Platform=x64 & diff --git a/.circleci/config.yml b/.circleci/config.yml index f6a875dd..85e42f8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,6 +77,23 @@ jobs: path: /tmp/htmlcov destination: htmlcov + python_tests_with_network: + docker: + - image: gudhi/ci_for_gudhi:latest + steps: + - checkout + - run: + name: Build and test python module with network + command: | + git submodule init + git submodule update + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON .. + cd src/python + python3 setup.py build_ext --inplace + ctest --output-on-failure + doxygen: docker: - image: gudhi/ci_for_gudhi:latest @@ -245,4 +262,5 @@ workflows: - tests - utils - python + - python_tests_with_network - doxygen diff --git a/.github/for_maintainers/tests_strategy.md b/.github/for_maintainers/tests_strategy.md index 9c181740..8fd7ac0d 100644 --- a/.github/for_maintainers/tests_strategy.md +++ b/.github/for_maintainers/tests_strategy.md @@ -8,13 +8,14 @@ The aim is to help maintainers to anticipate third parties modifications, update ### Linux -As all the third parties are already installed (thanks to docker), the compilations has been seperated by categories to be parallelized: +As all the third parties are already installed (thanks to docker), the compilations has been separated by categories to be parallelized: * examples (C++) * tests (C++) * utils (C++) * doxygen (C++ documentation that is available in the artefacts) * python (including documentation and code coverage that are available in the artefacts) +* python_tests_with_network (includes previous python with WITH_NETWORK option enabled which adds datasets fetching test) (cf. `.circleci/config.yml`) @@ -45,6 +46,7 @@ The compilations has been seperated by categories to be parallelized, but I don' * tests (C++) * utils (C++) * python +* python tests with network Doxygen (C++) is not tested. (cf. `.appveyor.yml`) diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 610aa17e..72d4b1e5 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -40,6 +40,8 @@ make \endverbatim * `make test` is using Ctest (CMake test driver * program). If some of the tests are failing, please send us the result of the following command: * \verbatim ctest --output-on-failure \endverbatim + * Testing fetching datasets feature requires the use of the internet and is disabled by default. If you want to include this test, set WITH_NETWORK to ON when building in the previous step (note that this test is included in the python module): + * \verbatim cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON --DWITH_GUDHI_PYTHON=ON .. \endverbatim * * \subsection documentationgeneration Documentation * To generate the documentation, Doxygen is required. -- cgit v1.2.3 From c9d6439fb9a6e65d7aa9f18bce675de65e901a0d Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 25 Oct 2021 11:43:09 +0200 Subject: Rename WITH_NETWORK option to WITH_GUDHI_REMOTE_TEST --- .appveyor.yml | 2 +- .circleci/config.yml | 2 +- .github/for_maintainers/tests_strategy.md | 2 +- src/cmake/modules/GUDHI_modules.cmake | 2 +- src/common/doc/installation.h | 4 ++-- src/python/CMakeLists.txt | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/.appveyor.yml b/.appveyor.yml index 521ec42d..ee6067e0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -30,7 +30,7 @@ environment: CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON - target: PythonTestsWithNetwork - CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON + CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_REMOTE_TEST=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON cache: diff --git a/.circleci/config.yml b/.circleci/config.yml index 85e42f8a..262e124b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,7 +89,7 @@ jobs: git submodule update mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON .. + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_REMOTE_TEST=ON .. cd src/python python3 setup.py build_ext --inplace ctest --output-on-failure diff --git a/.github/for_maintainers/tests_strategy.md b/.github/for_maintainers/tests_strategy.md index 8fd7ac0d..610e1749 100644 --- a/.github/for_maintainers/tests_strategy.md +++ b/.github/for_maintainers/tests_strategy.md @@ -15,7 +15,7 @@ As all the third parties are already installed (thanks to docker), the compilati * utils (C++) * doxygen (C++ documentation that is available in the artefacts) * python (including documentation and code coverage that are available in the artefacts) -* python_tests_with_network (includes previous python with WITH_NETWORK option enabled which adds datasets fetching test) +* python_tests_with_network (includes previous python with WITH_GUDHI_REMOTE_TEST option enabled which adds datasets fetching test) (cf. `.circleci/config.yml`) diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index 9cc1a8f5..7cdce307 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -19,7 +19,7 @@ endfunction(add_gudhi_module) option(WITH_GUDHI_BENCHMARK "Activate/deactivate benchmark compilation" OFF) option(WITH_GUDHI_EXAMPLE "Activate/deactivate examples compilation and installation" OFF) -option(WITH_NETWORK "Activate/deactivate datasets fetching test which uses the Internet" OFF) +option(WITH_GUDHI_REMOTE_TEST "Activate/deactivate datasets fetching test which uses the Internet" OFF) option(WITH_GUDHI_PYTHON "Activate/deactivate python module compilation and installation" ON) option(WITH_GUDHI_TEST "Activate/deactivate examples compilation and installation" ON) option(WITH_GUDHI_UTILITIES "Activate/deactivate utilities compilation and installation" ON) diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 72d4b1e5..b0fbdf20 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -40,8 +40,8 @@ make \endverbatim * `make test` is using Ctest (CMake test driver * program). If some of the tests are failing, please send us the result of the following command: * \verbatim ctest --output-on-failure \endverbatim - * Testing fetching datasets feature requires the use of the internet and is disabled by default. If you want to include this test, set WITH_NETWORK to ON when building in the previous step (note that this test is included in the python module): - * \verbatim cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_TEST=ON -DWITH_NETWORK=ON --DWITH_GUDHI_PYTHON=ON .. \endverbatim + * Testing fetching datasets feature requires the use of the internet and is disabled by default. If you want to include this test, set WITH_GUDHI_REMOTE_TEST to ON when building in the previous step (note that this test is included in the python module): + * \verbatim cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_REMOTE_TEST=ON --DWITH_GUDHI_PYTHON=ON .. \endverbatim * * \subsection documentationgeneration Documentation * To generate the documentation, Doxygen is required. diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 6c8dfe32..ddb5c9c2 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -543,7 +543,7 @@ if(PYTHONINTERP_FOUND) endif() # Fetch remote datasets - if(WITH_NETWORK) + if(WITH_GUDHI_REMOTE_TEST) add_gudhi_py_test(test_remote_datasets) endif() -- cgit v1.2.3 From 5db7ab2b55262a88c0ceecbb9c7ea004d9ed087e Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 25 Oct 2021 15:34:03 +0200 Subject: Enable WITH_GUDHI_REMOTE_TEST option for python target in CI platforms --- .appveyor.yml | 11 ++++------- .circleci/config.yml | 20 +------------------- .github/for_maintainers/tests_strategy.md | 12 +++++------- azure-pipelines.yml | 2 +- src/cmake/modules/GUDHI_modules.cmake | 6 +++--- 5 files changed, 14 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/.appveyor.yml b/.appveyor.yml index ee6067e0..e90f1b83 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -27,10 +27,7 @@ environment: CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=OFF - target: Python - CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON - - - target: PythonTestsWithNetwork - CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_REMOTE_TEST=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON + CMAKE_FLAGS: -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON cache: @@ -59,12 +56,12 @@ build_script: - mkdir build - cd build - cmake -G "Visual Studio 15 2017 Win64" %CMAKE_FLAGS% %CMAKE_GMP_FLAGS% %CMAKE_MPFR_FLAGS% %CMAKE_VCPKG_FLAGS% .. - - if or ([%target%]==[Python]) ([%target%]==[PythonTestsWithNetwork]) { + - if [%target%]==[Python] ( cd src/python & type setup.py & MSBuild Cython.sln /m /p:Configuration=Release /p:Platform=x64 & ctest -j 1 --output-on-failure -C Release - } else { + ) else ( MSBuild GUDHIdev.sln /m /p:Configuration=Release /p:Platform=x64 & ctest -j 1 --output-on-failure -C Release -E diff_files - } + ) diff --git a/.circleci/config.yml b/.circleci/config.yml index 262e124b..90737006 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,7 +61,7 @@ jobs: cmake -DUSER_VERSION_DIR=version .. make user_version cd version - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 . + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_REMOTE_TEST=ON . cd python python3 setup.py build_ext --inplace make sphinx @@ -77,23 +77,6 @@ jobs: path: /tmp/htmlcov destination: htmlcov - python_tests_with_network: - docker: - - image: gudhi/ci_for_gudhi:latest - steps: - - checkout - - run: - name: Build and test python module with network - command: | - git submodule init - git submodule update - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_REMOTE_TEST=ON .. - cd src/python - python3 setup.py build_ext --inplace - ctest --output-on-failure - doxygen: docker: - image: gudhi/ci_for_gudhi:latest @@ -262,5 +245,4 @@ workflows: - tests - utils - python - - python_tests_with_network - doxygen diff --git a/.github/for_maintainers/tests_strategy.md b/.github/for_maintainers/tests_strategy.md index 610e1749..2bba3f42 100644 --- a/.github/for_maintainers/tests_strategy.md +++ b/.github/for_maintainers/tests_strategy.md @@ -14,8 +14,7 @@ As all the third parties are already installed (thanks to docker), the compilati * tests (C++) * utils (C++) * doxygen (C++ documentation that is available in the artefacts) -* python (including documentation and code coverage that are available in the artefacts) -* python_tests_with_network (includes previous python with WITH_GUDHI_REMOTE_TEST option enabled which adds datasets fetching test) +* python (including documentation and code coverage that are available in the artefacts; here the WITH_GUDHI_REMOTE_TEST option is enabled which adds datasets fetching test) (cf. `.circleci/config.yml`) @@ -40,13 +39,12 @@ docker push gudhi/ci_for_gudhi_wo_cgal:latest ### Windows -The compilations has been seperated by categories to be parallelized, but I don't know why builds are not run in parallel: +The compilations has been separated by categories to be parallelized, but I don't know why builds are not run in parallel: * examples (C++) * tests (C++) * utils (C++) -* python -* python tests with network +* python (here the WITH_GUDHI_REMOTE_TEST option is enabled which adds datasets fetching test) Doxygen (C++) is not tested. (cf. `.appveyor.yml`) @@ -56,12 +54,12 @@ In case of installation issue, check in [vcpkg issues](https://github.com/micros ### OSx -The compilations has been seperated by categories to be parallelized: +The compilations has been separated by categories to be parallelized: * examples (C++) * tests (C++) * utils (C++) -* python +* python (here the WITH_GUDHI_REMOTE_TEST option is enabled which adds datasets fetching test) * Doxygen (C++) (cf. `azure-pipelines.yml`) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6c194f2a..6e102b83 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: source activate gudhi_build_env mkdir build cd build - cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 .. + cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_REMOTE_TEST=ON .. make -j 4 make doxygen ctest -j 4 --output-on-failure # -E sphinx remove sphinx build as it fails diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index 7cdce307..cbed6351 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -18,11 +18,11 @@ function(add_gudhi_module file_path) endfunction(add_gudhi_module) option(WITH_GUDHI_BENCHMARK "Activate/deactivate benchmark compilation" OFF) -option(WITH_GUDHI_EXAMPLE "Activate/deactivate examples compilation and installation" OFF) +option(WITH_GUDHI_EXAMPLE "Activate/deactivate examples compilation" OFF) option(WITH_GUDHI_REMOTE_TEST "Activate/deactivate datasets fetching test which uses the Internet" OFF) option(WITH_GUDHI_PYTHON "Activate/deactivate python module compilation and installation" ON) -option(WITH_GUDHI_TEST "Activate/deactivate examples compilation and installation" ON) -option(WITH_GUDHI_UTILITIES "Activate/deactivate utilities compilation and installation" ON) +option(WITH_GUDHI_TEST "Activate/deactivate tests compilation" ON) +option(WITH_GUDHI_UTILITIES "Activate/deactivate utilities compilation" ON) if (WITH_GUDHI_BENCHMARK) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};benchmark") -- cgit v1.2.3 From aa600c433e1f756bec4323e29e86786b937d9443 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 15 Nov 2021 11:12:27 +0100 Subject: Print files licenses when available Wrap bunny fetching Add corresponding tests --- src/python/gudhi/datasets/remote.py | 38 ++++++++++++++++++++++- src/python/test/test_remote_datasets.py | 55 ++++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index aef4b277..7e8f9ce7 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -39,7 +39,7 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): +def fetch(url, filename, dirname = "remote_datasets", file_checksum = None, accept_license = False): """ Fetch the wanted dataset from the given url and save it in file_path @@ -54,6 +54,9 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): file_checksum : string The file checksum using sha256 to check against the one computed on the downloaded file. Default is 'None'. + accept_license : boolean + Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. + Default is False Returns ------- @@ -69,6 +72,7 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): if not exists(dirname): makedirs(dirname) + # Get the file urlretrieve(url, file_path) if file_checksum is not None: @@ -78,6 +82,13 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): "different from expected : {}." "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, file_checksum)) + # Print license terms unless accept_license is set to True + if not accept_license: + license_file = join(dirname, "LICENSE") + if exists(license_file) and (file_path != license_file): + with open(license_file, 'r') as f: + print(f.read()) + return file_path def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): @@ -98,3 +109,28 @@ def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): """ return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + +def fetch_bunny(filename = "bunny.off", dirname = "remote_datasets/bunny", accept_license = False): + """ + Fetch bunny.off remotely and its LICENSE file + + Parameters + ---------- + filename : string + The name to give to downloaded file. Default is "bunny.off" + dirname : string + The directory to save the file to. Default is "remote_datasets/bunny". + accept_license : boolean + Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. + Default is False + + Returns + ------- + files_paths: list of strings + Full paths of the created file and its LICENSE. + """ + + return [fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/LICENSE", "LICENSE", dirname, + 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956'), + fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/bunny.off", filename, dirname, + '11852d5e73e2d4bd7b86a2c5cc8a5884d0fbb72539493e8cec100ea922b19f5b', accept_license)] diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index e252980d..e777abc6 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -11,36 +11,69 @@ from gudhi.datasets import remote import re import os.path +import io +import sys import pytest -def check_dir_file_names(path_file_dw, filename, dirname): +def _check_dir_file_names(path_file_dw, filename, dirname): assert os.path.isfile(path_file_dw) names_dw = re.split(r' |/|\\', path_file_dw) - assert dirname == names_dw[0] - assert filename == names_dw[1] + # Case where inner directories are created in "remote_datasets/"; e.g: "remote_datasets/bunny" + if len(names_dw) >= 3: + for i in range(len(names_dw)-1): + assert re.split(r' |/|\\', dirname)[i] == names_dw[i] + assert filename == names_dw[i+1] + else: + assert dirname == names_dw[0] + assert filename == names_dw[1] -def check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): +def _check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): path_file_dw = remote.fetch(url, filename, dirname, file_checksum) - check_dir_file_names(path_file_dw, filename, dirname) + _check_dir_file_names(path_file_dw, filename, dirname) + +def _get_bunny_license_print(accept_license = False): + capturedOutput = io.StringIO() + # Redirect stdout + sys.stdout = capturedOutput + remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/bunny.off", "bunny.off", "remote_datasets/bunny", + '11852d5e73e2d4bd7b86a2c5cc8a5884d0fbb72539493e8cec100ea922b19f5b', accept_license) + # Reset redirect + sys.stdout = sys.__stdout__ + return capturedOutput def test_fetch_remote_datasets(): # Test fetch with a wrong checksum with pytest.raises(OSError): - check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = 'XXXXXXXXXX') + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = 'XXXXXXXXXX') # Test files download from given urls with checksums provided - check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') - check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') # Test files download from given urls without checksums - check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") - check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") # Test spiral_2d.csv wrapping function path_file_dw = remote.fetch_spiral_2d() - check_dir_file_names(path_file_dw, 'spiral_2d.csv', 'remote_datasets') + _check_dir_file_names(path_file_dw, 'spiral_2d.csv', 'remote_datasets') + + # Test printing existing LICENSE file when fetching bunny.off with accept_license = False (default) + # Fetch LICENSE file + remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/LICENSE", "LICENSE", "remote_datasets/bunny", + 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956') + with open("remote_datasets/bunny/LICENSE") as f: + assert f.read() == _get_bunny_license_print().getvalue().rstrip("\n") + + # Test not printing bunny.off LICENSE when accept_license = True + assert "" == _get_bunny_license_print(accept_license = True).getvalue() + + # Test fetch_bunny wrapping function + path_file_dw = remote.fetch_bunny() + _check_dir_file_names(path_file_dw[0], 'LICENSE', 'remote_datasets/bunny') + _check_dir_file_names(path_file_dw[1], 'bunny.off', 'remote_datasets/bunny') -- cgit v1.2.3 From d941ebc854880a06707999f677137a9d6ff7473f Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 26 Jan 2022 15:21:20 +0100 Subject: Add datasets remote fetching module to doc --- src/python/doc/datasets.inc | 14 ++++ src/python/doc/datasets.rst | 118 +++++++++++++++++++++++++++++++++ src/python/doc/datasets_generators.inc | 14 ---- src/python/doc/datasets_generators.rst | 105 ----------------------------- src/python/doc/index.rst | 6 +- 5 files changed, 135 insertions(+), 122 deletions(-) create mode 100644 src/python/doc/datasets.inc create mode 100644 src/python/doc/datasets.rst delete mode 100644 src/python/doc/datasets_generators.inc delete mode 100644 src/python/doc/datasets_generators.rst (limited to 'src') diff --git a/src/python/doc/datasets.inc b/src/python/doc/datasets.inc new file mode 100644 index 00000000..95a87678 --- /dev/null +++ b/src/python/doc/datasets.inc @@ -0,0 +1,14 @@ +.. table:: + :widths: 30 40 30 + + +-----------------------------------+--------------------------------------------+--------------------------------------------------------------------------------------+ + | .. figure:: | Datasets either generated or fetched. | :Authors: Hind Montassif | + | img/sphere_3d.png | | | + | | | :Since: GUDHI 3.5.0 | + | | | | + | | | :License: MIT (`LGPL v3 `_) | + | | | | + | | | :Requires: `CGAL `_ | + +-----------------------------------+--------------------------------------------+--------------------------------------------------------------------------------------+ + | * :doc:`datasets` | + +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/python/doc/datasets.rst b/src/python/doc/datasets.rst new file mode 100644 index 00000000..4fa8a628 --- /dev/null +++ b/src/python/doc/datasets.rst @@ -0,0 +1,118 @@ + +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + +================ +Datasets manual +================ + +Datasets generators +=================== + +We provide the generation of different customizable datasets to use as inputs for Gudhi complexes and data structures. + +Points generators +------------------ + +The module **points** enables the generation of random points on a sphere, random points on a torus and as a grid. + +Points on sphere +^^^^^^^^^^^^^^^^ + +The function **sphere** enables the generation of random i.i.d. points uniformly on a (d-1)-sphere in :math:`R^d`. +The user should provide the number of points to be generated on the sphere :code:`n_samples` and the ambient dimension :code:`ambient_dim`. +The :code:`radius` of sphere is optional and is equal to **1** by default. +Only random points generation is currently available. + +The generated points are given as an array of shape :math:`(n\_samples, ambient\_dim)`. + +Example +""""""" + +.. code-block:: python + + from gudhi.datasets.generators import points + from gudhi import AlphaComplex + + # Generate 50 points on a sphere in R^2 + gen_points = points.sphere(n_samples = 50, ambient_dim = 2, radius = 1, sample = "random") + + # Create an alpha complex from the generated points + alpha_complex = AlphaComplex(points = gen_points) + +.. autofunction:: gudhi.datasets.generators.points.sphere + +Points on a flat torus +^^^^^^^^^^^^^^^^^^^^^^ + +You can also generate points on a torus. + +Two functions are available and give the same output: the first one depends on **CGAL** and the second does not and consists of full python code. + +On another hand, two sample types are provided: you can either generate i.i.d. points on a d-torus in :math:`R^{2d}` *randomly* or on a *grid*. + +First function: **ctorus** +""""""""""""""""""""""""""" + +The user should provide the number of points to be generated on the torus :code:`n_samples`, and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`. +The :code:`sample` argument is optional and is set to **'random'** by default. +In this case, the returned generated points would be an array of shape :math:`(n\_samples, 2*dim)`. +Otherwise, if set to **'grid'**, the points are generated on a grid and would be given as an array of shape: + +.. math:: + + ( ⌊n\_samples^{1 \over {dim}}⌋^{dim}, 2*dim ) + +**Note 1:** The output array first shape is rounded down to the closest perfect :math:`dim^{th}` power. + +**Note 2:** This version is recommended when the user wishes to use **'grid'** as sample type, or **'random'** with a relatively small number of samples (~ less than 150). + +Example +""""""" +.. code-block:: python + + from gudhi.datasets.generators import points + + # Generate 50 points randomly on a torus in R^6 + gen_points = points.ctorus(n_samples = 50, dim = 3) + + # Generate 27 points on a torus as a grid in R^6 + gen_points = points.ctorus(n_samples = 50, dim = 3, sample = 'grid') + +.. autofunction:: gudhi.datasets.generators.points.ctorus + +Second function: **torus** +""""""""""""""""""""""""""" + +The user should provide the number of points to be generated on the torus :code:`n_samples` and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`. +The :code:`sample` argument is optional and is set to **'random'** by default. +The other allowed value of sample type is **'grid'**. + +**Note:** This version is recommended when the user wishes to use **'random'** as sample type with a great number of samples and a low dimension. + +Example +""""""" +.. code-block:: python + + from gudhi.datasets.generators import points + + # Generate 50 points randomly on a torus in R^6 + gen_points = points.torus(n_samples = 50, dim = 3) + + # Generate 27 points on a torus as a grid in R^6 + gen_points = points.torus(n_samples = 50, dim = 3, sample = 'grid') + + +.. autofunction:: gudhi.datasets.generators.points.torus + + +Fetching datasets +================= + +We provide some ready-to-use datasets that are not available by default when getting GUDHI, and need to be fetched explicitly. + +.. automodule:: gudhi.datasets.remote + :members: + :special-members: + :show-inheritance: diff --git a/src/python/doc/datasets_generators.inc b/src/python/doc/datasets_generators.inc deleted file mode 100644 index 8d169275..00000000 --- a/src/python/doc/datasets_generators.inc +++ /dev/null @@ -1,14 +0,0 @@ -.. table:: - :widths: 30 40 30 - - +-----------------------------------+--------------------------------------------+--------------------------------------------------------------------------------------+ - | .. figure:: | Datasets generators (points). | :Authors: Hind Montassif | - | img/sphere_3d.png | | | - | | | :Since: GUDHI 3.5.0 | - | | | | - | | | :License: MIT (`LGPL v3 `_) | - | | | | - | | | :Requires: `CGAL `_ | - +-----------------------------------+--------------------------------------------+--------------------------------------------------------------------------------------+ - | * :doc:`datasets_generators` | - +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/python/doc/datasets_generators.rst b/src/python/doc/datasets_generators.rst deleted file mode 100644 index 260c3882..00000000 --- a/src/python/doc/datasets_generators.rst +++ /dev/null @@ -1,105 +0,0 @@ - -:orphan: - -.. To get rid of WARNING: document isn't included in any toctree - -=========================== -Datasets generators manual -=========================== - -We provide the generation of different customizable datasets to use as inputs for Gudhi complexes and data structures. - - -Points generators ------------------- - -The module **points** enables the generation of random points on a sphere, random points on a torus and as a grid. - -Points on sphere -^^^^^^^^^^^^^^^^ - -The function **sphere** enables the generation of random i.i.d. points uniformly on a (d-1)-sphere in :math:`R^d`. -The user should provide the number of points to be generated on the sphere :code:`n_samples` and the ambient dimension :code:`ambient_dim`. -The :code:`radius` of sphere is optional and is equal to **1** by default. -Only random points generation is currently available. - -The generated points are given as an array of shape :math:`(n\_samples, ambient\_dim)`. - -Example -""""""" - -.. code-block:: python - - from gudhi.datasets.generators import points - from gudhi import AlphaComplex - - # Generate 50 points on a sphere in R^2 - gen_points = points.sphere(n_samples = 50, ambient_dim = 2, radius = 1, sample = "random") - - # Create an alpha complex from the generated points - alpha_complex = AlphaComplex(points = gen_points) - -.. autofunction:: gudhi.datasets.generators.points.sphere - -Points on a flat torus -^^^^^^^^^^^^^^^^^^^^^^ - -You can also generate points on a torus. - -Two functions are available and give the same output: the first one depends on **CGAL** and the second does not and consists of full python code. - -On another hand, two sample types are provided: you can either generate i.i.d. points on a d-torus in :math:`R^{2d}` *randomly* or on a *grid*. - -First function: **ctorus** -""""""""""""""""""""""""""" - -The user should provide the number of points to be generated on the torus :code:`n_samples`, and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`. -The :code:`sample` argument is optional and is set to **'random'** by default. -In this case, the returned generated points would be an array of shape :math:`(n\_samples, 2*dim)`. -Otherwise, if set to **'grid'**, the points are generated on a grid and would be given as an array of shape: - -.. math:: - - ( ⌊n\_samples^{1 \over {dim}}⌋^{dim}, 2*dim ) - -**Note 1:** The output array first shape is rounded down to the closest perfect :math:`dim^{th}` power. - -**Note 2:** This version is recommended when the user wishes to use **'grid'** as sample type, or **'random'** with a relatively small number of samples (~ less than 150). - -Example -""""""" -.. code-block:: python - - from gudhi.datasets.generators import points - - # Generate 50 points randomly on a torus in R^6 - gen_points = points.ctorus(n_samples = 50, dim = 3) - - # Generate 27 points on a torus as a grid in R^6 - gen_points = points.ctorus(n_samples = 50, dim = 3, sample = 'grid') - -.. autofunction:: gudhi.datasets.generators.points.ctorus - -Second function: **torus** -""""""""""""""""""""""""""" - -The user should provide the number of points to be generated on the torus :code:`n_samples` and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`. -The :code:`sample` argument is optional and is set to **'random'** by default. -The other allowed value of sample type is **'grid'**. - -**Note:** This version is recommended when the user wishes to use **'random'** as sample type with a great number of samples and a low dimension. - -Example -""""""" -.. code-block:: python - - from gudhi.datasets.generators import points - - # Generate 50 points randomly on a torus in R^6 - gen_points = points.torus(n_samples = 50, dim = 3) - - # Generate 27 points on a torus as a grid in R^6 - gen_points = points.torus(n_samples = 50, dim = 3, sample = 'grid') - - -.. autofunction:: gudhi.datasets.generators.points.torus diff --git a/src/python/doc/index.rst b/src/python/doc/index.rst index 2d7921ae..35f4ba46 100644 --- a/src/python/doc/index.rst +++ b/src/python/doc/index.rst @@ -92,7 +92,7 @@ Clustering .. include:: clustering.inc -Datasets generators -******************* +Datasets +******** -.. include:: datasets_generators.inc +.. include:: datasets.inc -- cgit v1.2.3 From 8d1e7aeb3416194d00f45587d1ecea85ba218028 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 28 Jan 2022 16:21:33 +0100 Subject: Return arrays of points instead of files paths when fetching bunny.npy and spiral_2d.csv --- src/python/gudhi/datasets/remote.py | 83 +++++++++++++++++++++------------ src/python/test/test_remote_datasets.py | 33 +++++++------ 2 files changed, 72 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 7e8f9ce7..ef797417 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -7,17 +7,17 @@ # Modification(s): # - YYYY/MM Author: Description of the modification -import hashlib - from os.path import join, exists from os import makedirs from urllib.request import urlretrieve +import hashlib +import numpy as np def _checksum_sha256(file_path): """ - Compute the file checksum using sha256 + Compute the file checksum using sha256. Parameters ---------- @@ -26,7 +26,7 @@ def _checksum_sha256(file_path): Returns ------- - The hex digest of file_path + The hex digest of file_path. """ sha256_hash = hashlib.sha256() chunk_size = 4096 @@ -39,9 +39,9 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def fetch(url, filename, dirname = "remote_datasets", file_checksum = None, accept_license = False): +def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = None, accept_license = False): """ - Fetch the wanted dataset from the given url and save it in file_path + Fetch the wanted dataset from the given url and save it in file_path. Parameters ---------- @@ -56,7 +56,7 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None, acce Default is 'None'. accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. - Default is False + Default is False. Returns ------- @@ -66,14 +66,8 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None, acce file_path = join(dirname, filename) - # Check for an already existing file at file_path - if not exists(file_path): - # Create directory if not existing - if not exists(dirname): - makedirs(dirname) - - # Get the file - urlretrieve(url, file_path) + # Get the file + urlretrieve(url, file_path) if file_checksum is not None: checksum = _checksum_sha256(file_path) @@ -93,44 +87,71 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None, acce def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): """ - Fetch spiral_2d.csv remotely + Fetch "spiral_2d.csv" remotely. Parameters ---------- filename : string - The name to give to downloaded file. Default is "spiral_2d.csv" + The name to give to downloaded file. Default is "spiral_2d.csv". dirname : string The directory to save the file to. Default is "remote_datasets". Returns ------- - file_path: string - Full path of the created file. + points: array + Array of points stored in "spiral_2d.csv". """ - return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, - '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv" + file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38' -def fetch_bunny(filename = "bunny.off", dirname = "remote_datasets/bunny", accept_license = False): + archive_path = join(dirname, filename) + + if not exists(archive_path): + # Create directory if not existing + if not exists(dirname): + makedirs(dirname) + + file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) + + return np.loadtxt(file_path_pkl) + else: + return np.loadtxt(archive_path) + +def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accept_license = False): """ - Fetch bunny.off remotely and its LICENSE file + Fetch "bunny.npy" remotely and its LICENSE file. Parameters ---------- filename : string - The name to give to downloaded file. Default is "bunny.off" + The name to give to downloaded file. Default is "bunny.npy". dirname : string The directory to save the file to. Default is "remote_datasets/bunny". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. - Default is False + Default is False. Returns ------- - files_paths: list of strings - Full paths of the created file and its LICENSE. + points: array + Array of points stored in "bunny.npy". """ - return [fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/LICENSE", "LICENSE", dirname, - 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956'), - fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/bunny.off", filename, dirname, - '11852d5e73e2d4bd7b86a2c5cc8a5884d0fbb72539493e8cec100ea922b19f5b', accept_license)] + file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy" + file_checksum = '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b' + license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" + license_checksum = 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956' + + archive_path = join(dirname, filename) + + if not exists(archive_path): + # Create directory if not existing + if not exists(dirname): + makedirs(dirname) + + license_path = _fetch_remote(license_url, "LICENSE", dirname, license_checksum) + file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum, accept_license) + + return np.load(file_path_pkl, mmap_mode='r') + else: + return np.load(archive_path, mmap_mode='r') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index e777abc6..56a273b4 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -10,13 +10,14 @@ from gudhi.datasets import remote import re -import os.path +from os.path import isfile, exists +from os import makedirs import io import sys import pytest def _check_dir_file_names(path_file_dw, filename, dirname): - assert os.path.isfile(path_file_dw) + assert isfile(path_file_dw) names_dw = re.split(r' |/|\\', path_file_dw) # Case where inner directories are created in "remote_datasets/"; e.g: "remote_datasets/bunny" @@ -29,15 +30,20 @@ def _check_dir_file_names(path_file_dw, filename, dirname): assert filename == names_dw[1] def _check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): - path_file_dw = remote.fetch(url, filename, dirname, file_checksum) + if not exists(dirname): + makedirs(dirname) + path_file_dw = remote._fetch_remote(url, filename, dirname, file_checksum) _check_dir_file_names(path_file_dw, filename, dirname) def _get_bunny_license_print(accept_license = False): capturedOutput = io.StringIO() # Redirect stdout sys.stdout = capturedOutput - remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/bunny.off", "bunny.off", "remote_datasets/bunny", - '11852d5e73e2d4bd7b86a2c5cc8a5884d0fbb72539493e8cec100ea922b19f5b', accept_license) + + if not exists("remote_datasets/bunny"): + makedirs("remote_datasets/bunny") + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "remote_datasets/bunny", + '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) # Reset redirect sys.stdout = sys.__stdout__ return capturedOutput @@ -60,20 +66,21 @@ def test_fetch_remote_datasets(): _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") # Test spiral_2d.csv wrapping function - path_file_dw = remote.fetch_spiral_2d() - _check_dir_file_names(path_file_dw, 'spiral_2d.csv', 'remote_datasets') + spiral_2d_arr = remote.fetch_spiral_2d() + assert spiral_2d_arr.shape == (114562, 2) - # Test printing existing LICENSE file when fetching bunny.off with accept_license = False (default) + # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) # Fetch LICENSE file - remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points//bunny/LICENSE", "LICENSE", "remote_datasets/bunny", + if not exists("remote_datasets/bunny"): + makedirs("remote_datasets/bunny") + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956') with open("remote_datasets/bunny/LICENSE") as f: assert f.read() == _get_bunny_license_print().getvalue().rstrip("\n") - # Test not printing bunny.off LICENSE when accept_license = True + # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() # Test fetch_bunny wrapping function - path_file_dw = remote.fetch_bunny() - _check_dir_file_names(path_file_dw[0], 'LICENSE', 'remote_datasets/bunny') - _check_dir_file_names(path_file_dw[1], 'bunny.off', 'remote_datasets/bunny') + bunny_arr = remote.fetch_bunny() + assert bunny_arr.shape == (35947, 3) -- cgit v1.2.3 From ad7a50fb87ed4237b9a02165eac39ae355dd5440 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 1 Feb 2022 10:32:03 +0100 Subject: Fetch spiral_2d.npy file instead of csv Add some modifications related to those done on files in gudhi-data --- src/python/gudhi/datasets/remote.py | 20 ++++++++++---------- src/python/test/test_remote_datasets.py | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index ef797417..3498a645 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -85,24 +85,24 @@ def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = No return file_path -def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): +def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = "remote_datasets/spiral_2d"): """ - Fetch "spiral_2d.csv" remotely. + Fetch "spiral_2d.npy" remotely. Parameters ---------- filename : string - The name to give to downloaded file. Default is "spiral_2d.csv". + The name to give to downloaded file. Default is "spiral_2d.npy". dirname : string - The directory to save the file to. Default is "remote_datasets". + The directory to save the file to. Default is "remote_datasets/spiral_2d". Returns ------- points: array - Array of points stored in "spiral_2d.csv". + Array of points stored in "spiral_2d.npy". """ - file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv" - file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38' + file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy" + file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf' archive_path = join(dirname, filename) @@ -113,9 +113,9 @@ def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"): file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) - return np.loadtxt(file_path_pkl) + return np.load(file_path_pkl, mmap_mode='r') else: - return np.loadtxt(archive_path) + return np.load(archive_path, mmap_mode='r') def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accept_license = False): """ @@ -140,7 +140,7 @@ def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accep file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy" file_checksum = '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b' license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" - license_checksum = 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956' + license_checksum = 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a' archive_path = join(dirname, filename) diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 56a273b4..2057c63b 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -51,21 +51,21 @@ def _get_bunny_license_print(accept_license = False): def test_fetch_remote_datasets(): # Test fetch with a wrong checksum with pytest.raises(OSError): - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", file_checksum = 'XXXXXXXXXX') + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy", file_checksum = 'XXXXXXXXXX') # Test files download from given urls with checksums provided - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", - file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38') + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy", + file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf') _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') # Test files download from given urls without checksums - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv") + _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy") _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") - # Test spiral_2d.csv wrapping function + # Test fetch_spiral_2d wrapping function spiral_2d_arr = remote.fetch_spiral_2d() assert spiral_2d_arr.shape == (114562, 2) @@ -74,9 +74,9 @@ def test_fetch_remote_datasets(): if not exists("remote_datasets/bunny"): makedirs("remote_datasets/bunny") remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", - 'aeb1bad319b7d74fa0b8076358182f9c6b1284c67cc07dc67cbc9bc73025d956') + 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') with open("remote_datasets/bunny/LICENSE") as f: - assert f.read() == _get_bunny_license_print().getvalue().rstrip("\n") + assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() -- cgit v1.2.3 From 741f4f182479d1e5e78e9eb9180adce0a72e99b6 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Feb 2022 10:38:15 +0100 Subject: Modify remote fetching test to increase its coverage --- src/python/test/test_remote_datasets.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 2057c63b..dac9ee80 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -40,8 +40,6 @@ def _get_bunny_license_print(accept_license = False): # Redirect stdout sys.stdout = capturedOutput - if not exists("remote_datasets/bunny"): - makedirs("remote_datasets/bunny") remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "remote_datasets/bunny", '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) # Reset redirect @@ -65,22 +63,17 @@ def test_fetch_remote_datasets(): _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") - # Test fetch_spiral_2d wrapping function - spiral_2d_arr = remote.fetch_spiral_2d() - assert spiral_2d_arr.shape == (114562, 2) + # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) + for i in range(2): + spiral_2d_arr = remote.fetch_spiral_2d() + assert spiral_2d_arr.shape == (114562, 2) + + bunny_arr = remote.fetch_bunny() + assert bunny_arr.shape == (35947, 3) # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) - # Fetch LICENSE file - if not exists("remote_datasets/bunny"): - makedirs("remote_datasets/bunny") - remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", - 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') with open("remote_datasets/bunny/LICENSE") as f: assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() - - # Test fetch_bunny wrapping function - bunny_arr = remote.fetch_bunny() - assert bunny_arr.shape == (35947, 3) -- cgit v1.2.3 From 19689c712a1f5945e664f9c74c14b6994e7afaaf Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Feb 2022 16:14:17 +0100 Subject: Try to fix failing test in windows --- src/python/test/test_remote_datasets.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index dac9ee80..643485f9 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -40,6 +40,9 @@ def _get_bunny_license_print(accept_license = False): # Redirect stdout sys.stdout = capturedOutput + if not exists("remote_datasets/bunny"): + makedirs("remote_datasets/bunny") + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "remote_datasets/bunny", '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) # Reset redirect @@ -72,6 +75,11 @@ def test_fetch_remote_datasets(): assert bunny_arr.shape == (35947, 3) # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) + # Fetch LICENSE file + if not exists("remote_datasets/bunny"): + makedirs("remote_datasets/bunny") + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", + 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') with open("remote_datasets/bunny/LICENSE") as f: assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") -- cgit v1.2.3 From a2d55f9bbf0f45e3ae4c147f734ce04f5bc87ab8 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Feb 2022 21:32:55 +0100 Subject: Another attempt to fix windows failing test: move fetch_bunny to the end --- src/python/test/test_remote_datasets.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 643485f9..5e607d73 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -66,14 +66,6 @@ def test_fetch_remote_datasets(): _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") - # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) - for i in range(2): - spiral_2d_arr = remote.fetch_spiral_2d() - assert spiral_2d_arr.shape == (114562, 2) - - bunny_arr = remote.fetch_bunny() - assert bunny_arr.shape == (35947, 3) - # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) # Fetch LICENSE file if not exists("remote_datasets/bunny"): @@ -85,3 +77,11 @@ def test_fetch_remote_datasets(): # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() + + # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) + for i in range(2): + spiral_2d_arr = remote.fetch_spiral_2d() + assert spiral_2d_arr.shape == (114562, 2) + + bunny_arr = remote.fetch_bunny() + assert bunny_arr.shape == (35947, 3) -- cgit v1.2.3 From 6109fd920ba477f89e83fea3df9803232c169463 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Thu, 3 Feb 2022 10:24:38 +0100 Subject: Remove archive folder before testing wrapping functions --- src/python/test/test_remote_datasets.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 5e607d73..93a8a982 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -78,6 +78,9 @@ def test_fetch_remote_datasets(): # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() + # Remove "remote_datasets" directory and all its content + import shutil + shutil.rmtree("remote_datasets") # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) for i in range(2): spiral_2d_arr = remote.fetch_spiral_2d() -- cgit v1.2.3 From a13282e4da9910a5d2bdadf97040095ae5b7880a Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 4 Feb 2022 15:39:51 +0100 Subject: Store fetched datasets in user directory by default --- src/python/gudhi/datasets/remote.py | 68 ++++++++++++++++++++++++++------- src/python/test/test_remote_datasets.py | 31 +++++++++++---- 2 files changed, 79 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 3498a645..3d6c01b0 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -7,14 +7,52 @@ # Modification(s): # - YYYY/MM Author: Description of the modification -from os.path import join, exists +from os.path import join, exists, expanduser from os import makedirs from urllib.request import urlretrieve import hashlib +import shutil import numpy as np +def get_data_home(data_home = None): + """ + Return the path of the remote datasets directory. + This folder is used to store remotely fetched datasets. + By default the datasets directory is set to a folder named 'remote_datasets' in the user home folder. + Alternatively, it can be set by giving an explicit folder path. The '~' symbol is expanded to the user home folder. + If the folder does not already exist, it is automatically created. + + Parameters + ---------- + data_home : string + The path to remote datasets directory. Default is `None`, meaning that the data home directory will be set to "~/remote_datasets". + + Returns + ------- + data_home: string + The path to remote datasets directory. + """ + if data_home is None: + data_home = join("~", "remote_datasets") + data_home = expanduser(data_home) + makedirs(data_home, exist_ok=True) + return data_home + + +def clear_data_home(data_home = None): + """ + Delete all the content of the data home cache. + + Parameters + ---------- + data_home : string, default is None. + The path to remote datasets directory. If `None`, the default directory to be removed is set to "~/remote_datasets". + """ + data_home = get_data_home(data_home) + shutil.rmtree(data_home) + def _checksum_sha256(file_path): """ Compute the file checksum using sha256. @@ -85,7 +123,7 @@ def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = No return file_path -def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = "remote_datasets/spiral_2d"): +def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): """ Fetch "spiral_2d.npy" remotely. @@ -94,7 +132,7 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = "remote_datasets/spira filename : string The name to give to downloaded file. Default is "spiral_2d.npy". dirname : string - The directory to save the file to. Default is "remote_datasets/spiral_2d". + The directory to save the file to. Default is None, meaning that the data home will be set to "~/remote_datasets/spiral_2d". Returns ------- @@ -104,20 +142,22 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = "remote_datasets/spira file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy" file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf' + if dirname is None: + dirname = join(get_data_home(dirname), "spiral_2d") + makedirs(dirname, exist_ok=True) + else: + dirname = get_data_home(dirname) + archive_path = join(dirname, filename) if not exists(archive_path): - # Create directory if not existing - if not exists(dirname): - makedirs(dirname) - file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) return np.load(file_path_pkl, mmap_mode='r') else: return np.load(archive_path, mmap_mode='r') -def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accept_license = False): +def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): """ Fetch "bunny.npy" remotely and its LICENSE file. @@ -126,7 +166,7 @@ def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accep filename : string The name to give to downloaded file. Default is "bunny.npy". dirname : string - The directory to save the file to. Default is "remote_datasets/bunny". + The directory to save the file to. Default is None, meaning that the data home will be set to "~/remote_datasets/bunny". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. @@ -142,13 +182,15 @@ def fetch_bunny(filename = "bunny.npy", dirname = "remote_datasets/bunny", accep license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" license_checksum = 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a' + if dirname is None: + dirname = join(get_data_home(dirname), "bunny") + makedirs(dirname, exist_ok=True) + else: + dirname = get_data_home(dirname) + archive_path = join(dirname, filename) if not exists(archive_path): - # Create directory if not existing - if not exists(dirname): - makedirs(dirname) - license_path = _fetch_remote(license_url, "LICENSE", dirname, license_checksum) file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum, accept_license) diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 93a8a982..27eb51b0 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -10,7 +10,7 @@ from gudhi.datasets import remote import re -from os.path import isfile, exists +from os.path import isfile, isdir, expanduser from os import makedirs import io import sys @@ -30,8 +30,7 @@ def _check_dir_file_names(path_file_dw, filename, dirname): assert filename == names_dw[1] def _check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): - if not exists(dirname): - makedirs(dirname) + makedirs(dirname, exist_ok=True) path_file_dw = remote._fetch_remote(url, filename, dirname, file_checksum) _check_dir_file_names(path_file_dw, filename, dirname) @@ -40,8 +39,7 @@ def _get_bunny_license_print(accept_license = False): # Redirect stdout sys.stdout = capturedOutput - if not exists("remote_datasets/bunny"): - makedirs("remote_datasets/bunny") + makedirs("remote_datasets/bunny", exist_ok=True) remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "remote_datasets/bunny", '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) @@ -68,8 +66,7 @@ def test_fetch_remote_datasets(): # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) # Fetch LICENSE file - if not exists("remote_datasets/bunny"): - makedirs("remote_datasets/bunny") + makedirs("remote_datasets/bunny", exist_ok=True) remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') with open("remote_datasets/bunny/LICENSE") as f: @@ -88,3 +85,23 @@ def test_fetch_remote_datasets(): bunny_arr = remote.fetch_bunny() assert bunny_arr.shape == (35947, 3) + + # Check that default dir was created + assert isdir(expanduser("~/remote_datasets")) == True + + # Test clear_data_home + clear_data_home() + assert isdir(expanduser("~/remote_datasets")) == False + + # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default + spiral_2d_arr = remote.fetch_spiral_2d(dirname = "~/test") + assert spiral_2d_arr.shape == (114562, 2) + + bunny_arr = remote.fetch_bunny(dirname = "~/test") + assert bunny_arr.shape == (35947, 3) + + assert isdir(expanduser("~/test")) == True + + # Test clear_data_home with data directory different from default + clear_data_home("~/test") + assert isdir(expanduser("~/test")) == False -- cgit v1.2.3 From b0071de9ee7b6b4feb2eb9f19ceb759de21c997f Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 4 Feb 2022 16:09:54 +0100 Subject: Add forgotten module name before func call --- src/python/test/test_remote_datasets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 27eb51b0..9532b4ec 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -90,7 +90,7 @@ def test_fetch_remote_datasets(): assert isdir(expanduser("~/remote_datasets")) == True # Test clear_data_home - clear_data_home() + remote.clear_data_home() assert isdir(expanduser("~/remote_datasets")) == False # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default @@ -103,5 +103,5 @@ def test_fetch_remote_datasets(): assert isdir(expanduser("~/test")) == True # Test clear_data_home with data directory different from default - clear_data_home("~/test") + remote.clear_data_home("~/test") assert isdir(expanduser("~/test")) == False -- cgit v1.2.3 From b5d7d6c2857d305ba2828065310c11edefb37c4e Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 7 Feb 2022 13:03:45 +0100 Subject: Test get_data_home and clear_data_home on a separate folder --- src/python/test/test_remote_datasets.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 9532b4ec..c160f270 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -87,21 +87,20 @@ def test_fetch_remote_datasets(): assert bunny_arr.shape == (35947, 3) # Check that default dir was created - assert isdir(expanduser("~/remote_datasets")) == True - - # Test clear_data_home - remote.clear_data_home() - assert isdir(expanduser("~/remote_datasets")) == False + assert isdir(expanduser("~/remote_datasets")) # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default - spiral_2d_arr = remote.fetch_spiral_2d(dirname = "~/test") + spiral_2d_arr = remote.fetch_spiral_2d(dirname = "~/another_fetch_folder") assert spiral_2d_arr.shape == (114562, 2) - bunny_arr = remote.fetch_bunny(dirname = "~/test") + bunny_arr = remote.fetch_bunny(dirname = "~/another_fetch_folder") assert bunny_arr.shape == (35947, 3) - assert isdir(expanduser("~/test")) == True + assert isdir(expanduser("~/another_fetch_folder")) + + # Test get_data_home and clear_data_home on new empty folder + empty_data_home = remote.get_data_home(data_home="empty_folder") + assert isdir(empty_data_home) - # Test clear_data_home with data directory different from default - remote.clear_data_home("~/test") - assert isdir(expanduser("~/test")) == False + remote.clear_data_home(data_home=empty_data_home) + assert not isdir(empty_data_home) -- cgit v1.2.3 From e9b020adf11d48ce7a88932a5fe12cef011e72c9 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 7 Feb 2022 13:18:57 +0100 Subject: Separate tests into different functions and remove all test folders at the end --- src/python/test/test_remote_datasets.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index c160f270..2e595423 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -7,15 +7,17 @@ # Modification(s): # - YYYY/MM Author: Description of the modification - from gudhi.datasets import remote + import re -from os.path import isfile, isdir, expanduser -from os import makedirs +import shutil import io import sys import pytest +from os.path import isfile, isdir, expanduser +from os import makedirs + def _check_dir_file_names(path_file_dw, filename, dirname): assert isfile(path_file_dw) @@ -76,8 +78,9 @@ def test_fetch_remote_datasets(): assert "" == _get_bunny_license_print(accept_license = True).getvalue() # Remove "remote_datasets" directory and all its content - import shutil shutil.rmtree("remote_datasets") + +def test_fetch_remote_datasets_wrapped(): # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) for i in range(2): spiral_2d_arr = remote.fetch_spiral_2d() @@ -98,6 +101,14 @@ def test_fetch_remote_datasets(): assert isdir(expanduser("~/another_fetch_folder")) + # Remove test folders + shutil.rmtree(expanduser("~/remote_datasets")) + shutil.rmtree(expanduser("~/another_fetch_folder")) + + assert not isdir(expanduser("~/remote_datasets")) + assert not isdir(expanduser("~/another_fetch_folder")) + +def test_data_home(): # Test get_data_home and clear_data_home on new empty folder empty_data_home = remote.get_data_home(data_home="empty_folder") assert isdir(empty_data_home) -- cgit v1.2.3 From e964ec32247ce02fb12939cfcddaeabc04639869 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 7 Feb 2022 16:52:55 +0100 Subject: Del used variables before removing folders --- src/python/test/test_remote_datasets.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 2e595423..cb53cb85 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -102,6 +102,8 @@ def test_fetch_remote_datasets_wrapped(): assert isdir(expanduser("~/another_fetch_folder")) # Remove test folders + del spiral_2d_arr + del bunny_arr shutil.rmtree(expanduser("~/remote_datasets")) shutil.rmtree(expanduser("~/another_fetch_folder")) -- cgit v1.2.3 From 5c0c731fdd2bc41c2a4833be1612dca5a082c337 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Mar 2022 10:26:52 +0100 Subject: Modifications following PR review --- src/python/gudhi/datasets/remote.py | 60 ++++++++++++++++++--------------- src/python/test/test_remote_datasets.py | 38 ++++++++++----------- 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 3d6c01b0..618fa80e 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -20,14 +20,14 @@ def get_data_home(data_home = None): """ Return the path of the remote datasets directory. This folder is used to store remotely fetched datasets. - By default the datasets directory is set to a folder named 'remote_datasets' in the user home folder. + By default the datasets directory is set to a folder named 'gudhi_data' in the user home folder. Alternatively, it can be set by giving an explicit folder path. The '~' symbol is expanded to the user home folder. If the folder does not already exist, it is automatically created. Parameters ---------- data_home : string - The path to remote datasets directory. Default is `None`, meaning that the data home directory will be set to "~/remote_datasets". + The path to remote datasets directory. Default is `None`, meaning that the data home directory will be set to "~/gudhi_data". Returns ------- @@ -35,7 +35,7 @@ def get_data_home(data_home = None): The path to remote datasets directory. """ if data_home is None: - data_home = join("~", "remote_datasets") + data_home = join("~", "gudhi_data") data_home = expanduser(data_home) makedirs(data_home, exist_ok=True) return data_home @@ -43,12 +43,12 @@ def get_data_home(data_home = None): def clear_data_home(data_home = None): """ - Delete all the content of the data home cache. + Delete the data home cache directory and all its content. Parameters ---------- data_home : string, default is None. - The path to remote datasets directory. If `None`, the default directory to be removed is set to "~/remote_datasets". + The path to remote datasets directory. If `None`, the default directory to be removed is set to "~/gudhi_data". """ data_home = get_data_home(data_home) shutil.rmtree(data_home) @@ -77,7 +77,7 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = None, accept_license = False): +def _fetch_remote(url, filename, dirname = "gudhi_data", file_checksum = None, accept_license = False): """ Fetch the wanted dataset from the given url and save it in file_path. @@ -88,10 +88,10 @@ def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = No filename : string The name to give to downloaded file. dirname : string - The directory to save the file to. Default is "remote_datasets". + The directory to save the file to. Default is "gudhi_data". file_checksum : string The file checksum using sha256 to check against the one computed on the downloaded file. - Default is 'None'. + Default is 'None', which means the checksum is not checked. accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. @@ -100,6 +100,11 @@ def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = No ------- file_path: string Full path of the created file. + + Raises + ------ + IOError + If the computed SHA256 checksum of file does not match the one given by the user. """ file_path = join(dirname, filename) @@ -123,32 +128,37 @@ def _fetch_remote(url, filename, dirname = "remote_datasets", file_checksum = No return file_path +def _get_archive_and_dir(dirname, filename, label): + if dirname is None: + dirname = join(get_data_home(dirname), label) + makedirs(dirname, exist_ok=True) + else: + dirname = get_data_home(dirname) + + archive_path = join(dirname, filename) + + return archive_path, dirname + def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): """ - Fetch "spiral_2d.npy" remotely. + Fetch spiral_2d dataset remotely. Parameters ---------- filename : string The name to give to downloaded file. Default is "spiral_2d.npy". dirname : string - The directory to save the file to. Default is None, meaning that the data home will be set to "~/remote_datasets/spiral_2d". + The directory to save the file to. Default is None, meaning that the data home will be set to "~/gudhi_data/spiral_2d". Returns ------- points: array - Array of points stored in "spiral_2d.npy". + Array of points. """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy" file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf' - if dirname is None: - dirname = join(get_data_home(dirname), "spiral_2d") - makedirs(dirname, exist_ok=True) - else: - dirname = get_data_home(dirname) - - archive_path = join(dirname, filename) + archive_path, dirname = _get_archive_and_dir(dirname, filename, "spiral_2d") if not exists(archive_path): file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) @@ -159,14 +169,14 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): """ - Fetch "bunny.npy" remotely and its LICENSE file. + Fetch Stanford bunny dataset remotely and its LICENSE file. Parameters ---------- filename : string The name to give to downloaded file. Default is "bunny.npy". dirname : string - The directory to save the file to. Default is None, meaning that the data home will be set to "~/remote_datasets/bunny". + The directory to save the file to. Default is None, meaning that the data home will be set to "~/gudhi_data/bunny". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. @@ -174,7 +184,7 @@ def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): Returns ------- points: array - Array of points stored in "bunny.npy". + Array of points. """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy" @@ -182,13 +192,7 @@ def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" license_checksum = 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a' - if dirname is None: - dirname = join(get_data_home(dirname), "bunny") - makedirs(dirname, exist_ok=True) - else: - dirname = get_data_home(dirname) - - archive_path = join(dirname, filename) + archive_path, dirname = _get_archive_and_dir(dirname, filename, "bunny") if not exists(archive_path): license_path = _fetch_remote(license_url, "LICENSE", dirname, license_checksum) diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index cb53cb85..c44ac22b 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -22,7 +22,7 @@ def _check_dir_file_names(path_file_dw, filename, dirname): assert isfile(path_file_dw) names_dw = re.split(r' |/|\\', path_file_dw) - # Case where inner directories are created in "remote_datasets/"; e.g: "remote_datasets/bunny" + # Case where inner directories are created in "test_gudhi_data/"; e.g: "test_gudhi_data/bunny" if len(names_dw) >= 3: for i in range(len(names_dw)-1): assert re.split(r' |/|\\', dirname)[i] == names_dw[i] @@ -31,7 +31,7 @@ def _check_dir_file_names(path_file_dw, filename, dirname): assert dirname == names_dw[0] assert filename == names_dw[1] -def _check_fetch_output(url, filename, dirname = "remote_datasets", file_checksum = None): +def _check_fetch_output(url, filename, dirname = "test_gudhi_data", file_checksum = None): makedirs(dirname, exist_ok=True) path_file_dw = remote._fetch_remote(url, filename, dirname, file_checksum) _check_dir_file_names(path_file_dw, filename, dirname) @@ -41,9 +41,9 @@ def _get_bunny_license_print(accept_license = False): # Redirect stdout sys.stdout = capturedOutput - makedirs("remote_datasets/bunny", exist_ok=True) + makedirs("test_gudhi_data/bunny", exist_ok=True) - remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "remote_datasets/bunny", + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "test_gudhi_data/bunny", '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) # Reset redirect sys.stdout = sys.__stdout__ @@ -68,19 +68,21 @@ def test_fetch_remote_datasets(): # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) # Fetch LICENSE file - makedirs("remote_datasets/bunny", exist_ok=True) - remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "remote_datasets/bunny", + makedirs("test_gudhi_data/bunny", exist_ok=True) + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "test_gudhi_data/bunny", 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') - with open("remote_datasets/bunny/LICENSE") as f: + with open("test_gudhi_data/bunny/LICENSE") as f: assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() - # Remove "remote_datasets" directory and all its content - shutil.rmtree("remote_datasets") + # Remove "test_gudhi_data" directory and all its content + shutil.rmtree("test_gudhi_data") def test_fetch_remote_datasets_wrapped(): + # Check if gudhi_data default dir exists already + to_be_removed = not isdir(expanduser("~/gudhi_data")) # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) for i in range(2): spiral_2d_arr = remote.fetch_spiral_2d() @@ -90,29 +92,27 @@ def test_fetch_remote_datasets_wrapped(): assert bunny_arr.shape == (35947, 3) # Check that default dir was created - assert isdir(expanduser("~/remote_datasets")) + assert isdir(expanduser("~/gudhi_data")) # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default - spiral_2d_arr = remote.fetch_spiral_2d(dirname = "~/another_fetch_folder") + spiral_2d_arr = remote.fetch_spiral_2d(dirname = "./another_fetch_folder_for_test") assert spiral_2d_arr.shape == (114562, 2) - bunny_arr = remote.fetch_bunny(dirname = "~/another_fetch_folder") + bunny_arr = remote.fetch_bunny(dirname = "./another_fetch_folder_for_test") assert bunny_arr.shape == (35947, 3) - assert isdir(expanduser("~/another_fetch_folder")) + assert isdir(expanduser("./another_fetch_folder_for_test")) # Remove test folders del spiral_2d_arr del bunny_arr - shutil.rmtree(expanduser("~/remote_datasets")) - shutil.rmtree(expanduser("~/another_fetch_folder")) - - assert not isdir(expanduser("~/remote_datasets")) - assert not isdir(expanduser("~/another_fetch_folder")) + if to_be_removed: + shutil.rmtree(expanduser("~/gudhi_data")) + shutil.rmtree(expanduser("./another_fetch_folder_for_test")) def test_data_home(): # Test get_data_home and clear_data_home on new empty folder - empty_data_home = remote.get_data_home(data_home="empty_folder") + empty_data_home = remote.get_data_home(data_home="empty_folder_for_test") assert isdir(empty_data_home) remote.clear_data_home(data_home=empty_data_home) -- cgit v1.2.3 From 58e2f677081b4e9f21c47d6286b329218aa825d6 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 2 Mar 2022 17:58:39 +0100 Subject: Remove file when given checksum does not match Add more details to doc Remove default dirname value in _fetch_remote Add points/ subfolder in fetching functions --- src/python/gudhi/datasets/remote.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 618fa80e..8b3baef4 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -8,7 +8,7 @@ # - YYYY/MM Author: Description of the modification from os.path import join, exists, expanduser -from os import makedirs +from os import makedirs, remove from urllib.request import urlretrieve import hashlib @@ -77,7 +77,7 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def _fetch_remote(url, filename, dirname = "gudhi_data", file_checksum = None, accept_license = False): +def _fetch_remote(url, filename, dirname, file_checksum = None, accept_license = False): """ Fetch the wanted dataset from the given url and save it in file_path. @@ -88,7 +88,7 @@ def _fetch_remote(url, filename, dirname = "gudhi_data", file_checksum = None, a filename : string The name to give to downloaded file. dirname : string - The directory to save the file to. Default is "gudhi_data". + The directory to save the file to. file_checksum : string The file checksum using sha256 to check against the one computed on the downloaded file. Default is 'None', which means the checksum is not checked. @@ -115,6 +115,8 @@ def _fetch_remote(url, filename, dirname = "gudhi_data", file_checksum = None, a if file_checksum is not None: checksum = _checksum_sha256(file_path) if file_checksum != checksum: + # Remove file and raise error + remove(file_path) raise IOError("{} has a SHA256 checksum : {}, " "different from expected : {}." "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, file_checksum)) @@ -148,17 +150,17 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): filename : string The name to give to downloaded file. Default is "spiral_2d.npy". dirname : string - The directory to save the file to. Default is None, meaning that the data home will be set to "~/gudhi_data/spiral_2d". + The directory to save the file to. Default is None, meaning that the downloaded file will be put in "~/gudhi_data/points/spiral_2d". Returns ------- - points: array - Array of points. + points: numpy array + Array of shape (114562, 2). """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy" file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf' - archive_path, dirname = _get_archive_and_dir(dirname, filename, "spiral_2d") + archive_path, dirname = _get_archive_and_dir(dirname, filename, "points/spiral_2d") if not exists(archive_path): file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) @@ -170,21 +172,22 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): """ Fetch Stanford bunny dataset remotely and its LICENSE file. + This dataset contains 35947 vertices. Parameters ---------- filename : string The name to give to downloaded file. Default is "bunny.npy". dirname : string - The directory to save the file to. Default is None, meaning that the data home will be set to "~/gudhi_data/bunny". + The directory to save the file to. Default is None, meaning that the downloaded files will be put in "~/gudhi_data/points/bunny". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. Returns ------- - points: array - Array of points. + points: numpy array + Array of shape (35947, 3). """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy" @@ -192,7 +195,7 @@ def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" license_checksum = 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a' - archive_path, dirname = _get_archive_and_dir(dirname, filename, "bunny") + archive_path, dirname = _get_archive_and_dir(dirname, filename, "points/bunny") if not exists(archive_path): license_path = _fetch_remote(license_url, "LICENSE", dirname, license_checksum) -- cgit v1.2.3 From 0047eaacaffef2b3da6207123da3ef3d919c0b27 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 9 Mar 2022 15:56:23 +0100 Subject: Add bunny image to the datasets doc --- src/python/doc/datasets.rst | 6 ++++++ src/python/doc/img/bunny.png | Bin 0 -> 48040 bytes 2 files changed, 6 insertions(+) create mode 100644 src/python/doc/img/bunny.png (limited to 'src') diff --git a/src/python/doc/datasets.rst b/src/python/doc/datasets.rst index 4fa8a628..62b7dca0 100644 --- a/src/python/doc/datasets.rst +++ b/src/python/doc/datasets.rst @@ -112,6 +112,12 @@ Fetching datasets We provide some ready-to-use datasets that are not available by default when getting GUDHI, and need to be fetched explicitly. +.. figure:: ./img/bunny.png + :figclass: align-center + + 3D Stanford bunny with 35947 vertices. + + .. automodule:: gudhi.datasets.remote :members: :special-members: diff --git a/src/python/doc/img/bunny.png b/src/python/doc/img/bunny.png new file mode 100644 index 00000000..769aa530 Binary files /dev/null and b/src/python/doc/img/bunny.png differ -- cgit v1.2.3 From 17dc48527dcc8ee7e5eab95f9fdde3e236f4ad47 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Mon, 21 Mar 2022 17:47:59 +0100 Subject: extended_persistence uses directly get_persistent_pairs --- src/python/gudhi/simplex_tree.pxd | 4 +-- src/python/gudhi/simplex_tree.pyx | 3 +- .../include/Persistent_cohomology_interface.h | 40 ++++++++++++++++++++++ src/python/include/Simplex_tree_interface.h | 30 ---------------- src/python/test/test_simplex_tree.py | 4 +++ 5 files changed, 47 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/simplex_tree.pxd b/src/python/gudhi/simplex_tree.pxd index 5c98fb4a..a8ed6d50 100644 --- a/src/python/gudhi/simplex_tree.pxd +++ b/src/python/gudhi/simplex_tree.pxd @@ -63,7 +63,6 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": bool prune_above_filtration(double filtration) nogil bool make_filtration_non_decreasing() nogil void compute_extended_filtration() nogil - vector[vector[pair[int, pair[double, double]]]] compute_extended_persistence_subdiagrams(vector[pair[int, pair[double, double]]] dgm, double min_persistence) nogil Simplex_tree_interface_full_featured* collapse_edges(int nb_collapse_iteration) nogil except + void reset_filtration(double filtration, int dimension) nogil bint operator==(Simplex_tree_interface_full_featured) nogil @@ -78,7 +77,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": pair[Simplex_tree_boundary_iterator, Simplex_tree_boundary_iterator] get_boundary_iterators(vector[int] simplex) nogil except + cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": - cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface>": + cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface>": Simplex_tree_persistence_interface(Simplex_tree_interface_full_featured * st, bool persistence_dim_max) nogil void compute_persistence(int homology_coeff_field, double min_persistence) nogil except + vector[pair[int, pair[double, double]]] get_persistence() nogil @@ -89,3 +88,4 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": vector[pair[vector[int], vector[int]]] persistence_pairs() nogil pair[vector[vector[int]], vector[vector[int]]] lower_star_generators() nogil pair[vector[vector[int]], vector[vector[int]]] flag_generators() nogil + vector[vector[pair[int, pair[double, double]]]] compute_extended_persistence_subdiagrams(double min_persistence) nogil diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index b8fabf78..1bbf1539 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -471,8 +471,7 @@ cdef class SimplexTree: del self.pcohptr self.pcohptr = new Simplex_tree_persistence_interface(self.get_ptr(), False) self.pcohptr.compute_persistence(homology_coeff_field, -1.) - persistence_result = self.pcohptr.get_persistence() - return self.get_ptr().compute_extended_persistence_subdiagrams(persistence_result, min_persistence) + return self.pcohptr.compute_extended_persistence_subdiagrams(min_persistence) def persistence(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False): diff --git a/src/python/include/Persistent_cohomology_interface.h b/src/python/include/Persistent_cohomology_interface.h index e5a3dfba..945378a0 100644 --- a/src/python/include/Persistent_cohomology_interface.h +++ b/src/python/include/Persistent_cohomology_interface.h @@ -12,6 +12,8 @@ #define INCLUDE_PERSISTENT_COHOMOLOGY_INTERFACE_H_ #include +#include // for Extended_simplex_type + #include #include @@ -223,6 +225,44 @@ persistent_cohomology::Persistent_cohomology; + using Persistence_subdiagrams = std::vector>>; + + Persistence_subdiagrams compute_extended_persistence_subdiagrams(Filtration_value min_persistence){ + Persistence_subdiagrams pers_subs(4); + auto const& persistent_pairs = Base::get_persistent_pairs(); + for (auto pair : persistent_pairs) { + std::pair px = stptr_->decode_extended_filtration(stptr_->filtration(get<0>(pair)), + stptr_->efd); + std::pair py = stptr_->decode_extended_filtration(stptr_->filtration(get<1>(pair)), + stptr_->efd); + std::pair pd_point = std::make_pair(stptr_->dimension(get<0>(pair)), + std::make_pair(px.first, py.first)); + if(std::abs(px.first - py.first) > min_persistence){ + //Ordinary + if (px.second == Extended_simplex_type::UP && py.second == Extended_simplex_type::UP){ + pers_subs[0].push_back(pd_point); + } + // Relative + else if (px.second == Extended_simplex_type::DOWN && py.second == Extended_simplex_type::DOWN){ + pers_subs[1].push_back(pd_point); + } + else{ + // Extended+ + if (px.first < py.first){ + pers_subs[2].push_back(pd_point); + } + //Extended- + else{ + pers_subs[3].push_back(pd_point); + } + } + } + } + return pers_subs; + } + private: // A copy FilteredComplex* stptr_; diff --git a/src/python/include/Simplex_tree_interface.h b/src/python/include/Simplex_tree_interface.h index 629f6083..dc9d01d7 100644 --- a/src/python/include/Simplex_tree_interface.h +++ b/src/python/include/Simplex_tree_interface.h @@ -133,36 +133,6 @@ class Simplex_tree_interface : public Simplex_tree { return; } - std::vector>>> compute_extended_persistence_subdiagrams(const std::vector>>& dgm, Filtration_value min_persistence){ - std::vector>>> new_dgm(4); - for (unsigned int i = 0; i < dgm.size(); i++){ - std::pair px = this->decode_extended_filtration(dgm[i].second.first, this->efd); - std::pair py = this->decode_extended_filtration(dgm[i].second.second, this->efd); - std::pair> pd_point = std::make_pair(dgm[i].first, std::make_pair(px.first, py.first)); - if(std::abs(px.first - py.first) > min_persistence){ - //Ordinary - if (px.second == Extended_simplex_type::UP && py.second == Extended_simplex_type::UP){ - new_dgm[0].push_back(pd_point); - } - // Relative - else if (px.second == Extended_simplex_type::DOWN && py.second == Extended_simplex_type::DOWN){ - new_dgm[1].push_back(pd_point); - } - else{ - // Extended+ - if (px.first < py.first){ - new_dgm[2].push_back(pd_point); - } - //Extended- - else{ - new_dgm[3].push_back(pd_point); - } - } - } - } - return new_dgm; - } - Simplex_tree_interface* collapse_edges(int nb_collapse_iteration) { #ifdef GUDHI_USE_EIGEN3 using Filtered_edge = std::tuple; diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index a8180ce8..23458eb2 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -320,6 +320,10 @@ def test_extend_filtration(): ] dgms = st.extended_persistence(min_persistence=-1.) + assert len(dgms) == 4 + # Sort by (death-birth) descending - we are only interested in those with the longest life span + for idx in range(4): + dgms[idx] = sorted(dgms[idx], key=lambda x:(-abs(x[1][0]-x[1][1]))) assert dgms[0][0][1][0] == pytest.approx(2.) assert dgms[0][0][1][1] == pytest.approx(3.) -- cgit v1.2.3 From ef8284cce27a8f11947e7f076034aa2fd8b5a395 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 4 May 2022 15:27:34 +0200 Subject: Ask for file_path as parameter of remote fetching functions instead of both dirname and filename Modify remote fetching test --- src/python/gudhi/datasets/remote.py | 106 +++++++++++++++----------------- src/python/test/test_remote_datasets.py | 94 ++++++++++------------------ 2 files changed, 83 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 8b3baef4..5b535911 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -7,7 +7,7 @@ # Modification(s): # - YYYY/MM Author: Description of the modification -from os.path import join, exists, expanduser +from os.path import join, split, exists, expanduser from os import makedirs, remove from urllib.request import urlretrieve @@ -60,7 +60,7 @@ def _checksum_sha256(file_path): Parameters ---------- file_path: string - Full path of the created file. + Full path of the created file including filename. Returns ------- @@ -77,7 +77,7 @@ def _checksum_sha256(file_path): sha256_hash.update(buffer) return sha256_hash.hexdigest() -def _fetch_remote(url, filename, dirname, file_checksum = None, accept_license = False): +def _fetch_remote(url, file_path, file_checksum = None): """ Fetch the wanted dataset from the given url and save it in file_path. @@ -85,21 +85,11 @@ def _fetch_remote(url, filename, dirname, file_checksum = None, accept_license = ---------- url : string The url to fetch the dataset from. - filename : string - The name to give to downloaded file. - dirname : string - The directory to save the file to. + file_path : string + Full path of the downloaded file including filename. file_checksum : string The file checksum using sha256 to check against the one computed on the downloaded file. Default is 'None', which means the checksum is not checked. - accept_license : boolean - Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. - Default is False. - - Returns - ------- - file_path: string - Full path of the created file. Raises ------ @@ -107,8 +97,6 @@ def _fetch_remote(url, filename, dirname, file_checksum = None, accept_license = If the computed SHA256 checksum of file does not match the one given by the user. """ - file_path = join(dirname, filename) - # Get the file urlretrieve(url, file_path) @@ -121,36 +109,41 @@ def _fetch_remote(url, filename, dirname, file_checksum = None, accept_license = "different from expected : {}." "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, file_checksum)) - # Print license terms unless accept_license is set to True - if not accept_license: - license_file = join(dirname, "LICENSE") - if exists(license_file) and (file_path != license_file): - with open(license_file, 'r') as f: - print(f.read()) +def _get_archive_path(file_path, label): + """ + Get archive path based on file_path given by user and label. - return file_path + Parameters + ---------- + file_path: string + Full path of the file to get including filename, or None. + label: string + Label used along with 'data_home' to get archive path, in case 'file_path' is None. -def _get_archive_and_dir(dirname, filename, label): - if dirname is None: - dirname = join(get_data_home(dirname), label) + Returns + ------- + Full path of archive including filename. + """ + if file_path is None: + archive_path = join(get_data_home(), label) + dirname = split(archive_path)[0] makedirs(dirname, exist_ok=True) else: - dirname = get_data_home(dirname) - - archive_path = join(dirname, filename) + archive_path = file_path + dirname = split(archive_path)[0] + makedirs(dirname, exist_ok=True) - return archive_path, dirname + return archive_path -def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): +def fetch_spiral_2d(file_path = None): """ Fetch spiral_2d dataset remotely. Parameters ---------- - filename : string - The name to give to downloaded file. Default is "spiral_2d.npy". - dirname : string - The directory to save the file to. Default is None, meaning that the downloaded file will be put in "~/gudhi_data/points/spiral_2d". + file_path : string + Full path of the downloaded file including filename. + Default is None, meaning that it's set to "data_home/points/spiral_2d/spiral_2d.npy". Returns ------- @@ -158,28 +151,25 @@ def fetch_spiral_2d(filename = "spiral_2d.npy", dirname = None): Array of shape (114562, 2). """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy" - file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf' + file_checksum = '2226024da76c073dd2f24b884baefbfd14928b52296df41ad2d9b9dc170f2401' - archive_path, dirname = _get_archive_and_dir(dirname, filename, "points/spiral_2d") + archive_path = _get_archive_path(file_path, "points/spiral_2d/spiral_2d.npy") if not exists(archive_path): - file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum) + _fetch_remote(file_url, archive_path, file_checksum) - return np.load(file_path_pkl, mmap_mode='r') - else: - return np.load(archive_path, mmap_mode='r') + return np.load(archive_path, mmap_mode='r') -def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): +def fetch_bunny(file_path = None, accept_license = False): """ Fetch Stanford bunny dataset remotely and its LICENSE file. This dataset contains 35947 vertices. Parameters ---------- - filename : string - The name to give to downloaded file. Default is "bunny.npy". - dirname : string - The directory to save the file to. Default is None, meaning that the downloaded files will be put in "~/gudhi_data/points/bunny". + file_path : string + Full path of the downloaded file including filename. + Default is None, meaning that it's set to "data_home/points/bunny/bunny.npy". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. @@ -191,16 +181,20 @@ def fetch_bunny(filename = "bunny.npy", dirname = None, accept_license = False): """ file_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy" - file_checksum = '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b' - license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE" + file_checksum = 'f382482fd89df8d6444152dc8fd454444fe597581b193fd139725a85af4a6c6e' + license_url = "https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.LICENSE" license_checksum = 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a' - archive_path, dirname = _get_archive_and_dir(dirname, filename, "points/bunny") + archive_path = _get_archive_path(file_path, "points/bunny/bunny.npy") if not exists(archive_path): - license_path = _fetch_remote(license_url, "LICENSE", dirname, license_checksum) - file_path_pkl = _fetch_remote(file_url, filename, dirname, file_checksum, accept_license) - - return np.load(file_path_pkl, mmap_mode='r') - else: - return np.load(archive_path, mmap_mode='r') + _fetch_remote(file_url, archive_path, file_checksum) + license_path = join(split(archive_path)[0], "bunny.LICENSE") + _fetch_remote(license_url, license_path, license_checksum) + # Print license terms unless accept_license is set to True + if not accept_license: + if exists(license_path): + with open(license_path, 'r') as f: + print(f.read()) + + return np.load(archive_path, mmap_mode='r') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index c44ac22b..5d0d397d 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -9,76 +9,48 @@ from gudhi.datasets import remote -import re import shutil import io import sys import pytest -from os.path import isfile, isdir, expanduser -from os import makedirs +from os.path import isdir, expanduser, exists +from os import remove -def _check_dir_file_names(path_file_dw, filename, dirname): - assert isfile(path_file_dw) +def test_data_home(): + # Test get_data_home and clear_data_home on new empty folder + empty_data_home = remote.get_data_home(data_home="empty_folder_for_test") + assert isdir(empty_data_home) - names_dw = re.split(r' |/|\\', path_file_dw) - # Case where inner directories are created in "test_gudhi_data/"; e.g: "test_gudhi_data/bunny" - if len(names_dw) >= 3: - for i in range(len(names_dw)-1): - assert re.split(r' |/|\\', dirname)[i] == names_dw[i] - assert filename == names_dw[i+1] - else: - assert dirname == names_dw[0] - assert filename == names_dw[1] + remote.clear_data_home(data_home=empty_data_home) + assert not isdir(empty_data_home) -def _check_fetch_output(url, filename, dirname = "test_gudhi_data", file_checksum = None): - makedirs(dirname, exist_ok=True) - path_file_dw = remote._fetch_remote(url, filename, dirname, file_checksum) - _check_dir_file_names(path_file_dw, filename, dirname) +def test_fetch_remote(): + # Test fetch with a wrong checksum + with pytest.raises(OSError): + remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "tmp_spiral_2d.npy", file_checksum = 'XXXXXXXXXX') + assert not exists("tmp_spiral_2d.npy") def _get_bunny_license_print(accept_license = False): capturedOutput = io.StringIO() # Redirect stdout sys.stdout = capturedOutput - makedirs("test_gudhi_data/bunny", exist_ok=True) + bunny_arr = remote.fetch_bunny("./tmp_for_test/bunny.npy", accept_license) + assert bunny_arr.shape == (35947, 3) + remove("./tmp_for_test/bunny.npy") - remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/bunny.npy", "bunny.npy", "test_gudhi_data/bunny", - '13f7842ebb4b45370e50641ff28c88685703efa5faab14edf0bb7d113a965e1b', accept_license) # Reset redirect sys.stdout = sys.__stdout__ return capturedOutput -def test_fetch_remote_datasets(): - # Test fetch with a wrong checksum - with pytest.raises(OSError): - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy", file_checksum = 'XXXXXXXXXX') - - # Test files download from given urls with checksums provided - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy", - file_checksum = '88312ffd6df2e2cb2bde9c0e1f962d7d644c6f58dc369c7b377b298dacdc4eaf') - - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off", - file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88') - - # Test files download from given urls without checksums - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d/spiral_2d.npy", "spiral_2d.npy") - - _check_fetch_output("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off") - - # Test printing existing LICENSE file when fetching bunny.npy with accept_license = False (default) - # Fetch LICENSE file - makedirs("test_gudhi_data/bunny", exist_ok=True) - remote._fetch_remote("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/bunny/LICENSE", "LICENSE", "test_gudhi_data/bunny", - 'b763dbe1b2fc6015d05cbf7bcc686412a2eb100a1f2220296e3b4a644c69633a') - with open("test_gudhi_data/bunny/LICENSE") as f: - assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") - +def test_print_bunny_license(): # Test not printing bunny.npy LICENSE when accept_license = True assert "" == _get_bunny_license_print(accept_license = True).getvalue() - - # Remove "test_gudhi_data" directory and all its content - shutil.rmtree("test_gudhi_data") + # Test printing bunny.LICENSE file when fetching bunny.npy with accept_license = False (default) + with open("./tmp_for_test/bunny.LICENSE") as f: + assert f.read().rstrip("\n") == _get_bunny_license_print().getvalue().rstrip("\n") + shutil.rmtree("./tmp_for_test") def test_fetch_remote_datasets_wrapped(): # Check if gudhi_data default dir exists already @@ -93,27 +65,27 @@ def test_fetch_remote_datasets_wrapped(): # Check that default dir was created assert isdir(expanduser("~/gudhi_data")) + # Check downloaded files + assert exists(expanduser("~/gudhi_data/points/spiral_2d/spiral_2d.npy")) + assert exists(expanduser("~/gudhi_data/points/bunny/bunny.npy")) + assert exists(expanduser("~/gudhi_data/points/bunny/bunny.LICENSE")) # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default - spiral_2d_arr = remote.fetch_spiral_2d(dirname = "./another_fetch_folder_for_test") + spiral_2d_arr = remote.fetch_spiral_2d("./another_fetch_folder_for_test/spiral_2d.npy") assert spiral_2d_arr.shape == (114562, 2) - bunny_arr = remote.fetch_bunny(dirname = "./another_fetch_folder_for_test") + bunny_arr = remote.fetch_bunny("./another_fetch_folder_for_test/bunny.npy") assert bunny_arr.shape == (35947, 3) - assert isdir(expanduser("./another_fetch_folder_for_test")) + assert isdir("./another_fetch_folder_for_test") + # Check downloaded files + assert exists("./another_fetch_folder_for_test/spiral_2d.npy") + assert exists("./another_fetch_folder_for_test/bunny.npy") + assert exists("./another_fetch_folder_for_test/bunny.LICENSE") # Remove test folders del spiral_2d_arr del bunny_arr if to_be_removed: shutil.rmtree(expanduser("~/gudhi_data")) - shutil.rmtree(expanduser("./another_fetch_folder_for_test")) - -def test_data_home(): - # Test get_data_home and clear_data_home on new empty folder - empty_data_home = remote.get_data_home(data_home="empty_folder_for_test") - assert isdir(empty_data_home) - - remote.clear_data_home(data_home=empty_data_home) - assert not isdir(empty_data_home) + shutil.rmtree("./another_fetch_folder_for_test") -- cgit v1.2.3 From 52d5b524403a43bfdc0b27a7feeec04e9c9c34c2 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Thu, 5 May 2022 17:43:12 +0200 Subject: Add GUDHI_DATA environment variable option --- src/python/gudhi/datasets/remote.py | 16 +++++++++++----- src/python/test/test_remote_datasets.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 5b535911..eac8caf3 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -8,7 +8,7 @@ # - YYYY/MM Author: Description of the modification from os.path import join, split, exists, expanduser -from os import makedirs, remove +from os import makedirs, remove, environ from urllib.request import urlretrieve import hashlib @@ -21,13 +21,16 @@ def get_data_home(data_home = None): Return the path of the remote datasets directory. This folder is used to store remotely fetched datasets. By default the datasets directory is set to a folder named 'gudhi_data' in the user home folder. - Alternatively, it can be set by giving an explicit folder path. The '~' symbol is expanded to the user home folder. + Alternatively, it can be set by the 'GUDHI_DATA' environment variable. + The '~' symbol is expanded to the user home folder. If the folder does not already exist, it is automatically created. Parameters ---------- data_home : string - The path to remote datasets directory. Default is `None`, meaning that the data home directory will be set to "~/gudhi_data". + The path to remote datasets directory. + Default is `None`, meaning that the data home directory will be set to "~/gudhi_data", + if the 'GUDHI_DATA' environment variable does not exist. Returns ------- @@ -35,7 +38,7 @@ def get_data_home(data_home = None): The path to remote datasets directory. """ if data_home is None: - data_home = join("~", "gudhi_data") + data_home = environ.get("GUDHI_DATA", join("~", "gudhi_data")) data_home = expanduser(data_home) makedirs(data_home, exist_ok=True) return data_home @@ -48,7 +51,9 @@ def clear_data_home(data_home = None): Parameters ---------- data_home : string, default is None. - The path to remote datasets directory. If `None`, the default directory to be removed is set to "~/gudhi_data". + The path to remote datasets directory. + If `None` and the 'GUDHI_DATA' environment variable does not exist, + the default directory to be removed is set to "~/gudhi_data". """ data_home = get_data_home(data_home) shutil.rmtree(data_home) @@ -170,6 +175,7 @@ def fetch_bunny(file_path = None, accept_license = False): file_path : string Full path of the downloaded file including filename. Default is None, meaning that it's set to "data_home/points/bunny/bunny.npy". + In this case, the LICENSE file would be downloaded as "data_home/points/bunny/bunny.LICENSE". accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. Default is False. diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 5d0d397d..af26d77c 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -15,7 +15,7 @@ import sys import pytest from os.path import isdir, expanduser, exists -from os import remove +from os import remove, environ def test_data_home(): # Test get_data_home and clear_data_home on new empty folder @@ -89,3 +89,14 @@ def test_fetch_remote_datasets_wrapped(): if to_be_removed: shutil.rmtree(expanduser("~/gudhi_data")) shutil.rmtree("./another_fetch_folder_for_test") + +def test_gudhi_data_env(): + # Set environment variable "GUDHI_DATA" + environ["GUDHI_DATA"] = "./test_folder_from_env_var" + bunny_arr = remote.fetch_bunny() + assert bunny_arr.shape == (35947, 3) + assert exists("./test_folder_from_env_var/points/bunny/bunny.npy") + assert exists("./test_folder_from_env_var/points/bunny/bunny.LICENSE") + # Remove test folder + del bunny_arr + shutil.rmtree("./test_folder_from_env_var") -- cgit v1.2.3 From f344700ebee65de9ccc8799f2ec4e1c633ab864e Mon Sep 17 00:00:00 2001 From: Hind-M Date: Thu, 5 May 2022 18:07:52 +0200 Subject: Remove default data home test (because of 'GUDHI_DATA' environment variable option) --- src/python/test/test_remote_datasets.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index af26d77c..6f569fd2 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -53,30 +53,16 @@ def test_print_bunny_license(): shutil.rmtree("./tmp_for_test") def test_fetch_remote_datasets_wrapped(): - # Check if gudhi_data default dir exists already - to_be_removed = not isdir(expanduser("~/gudhi_data")) - # Test fetch_spiral_2d and fetch_bunny wrapping functions (twice, to test case of already fetched files) + # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default (twice, to test case of already fetched files) + # Default case is not tested because it would fail in case the user sets the 'GUDHI_DATA' environment variable locally for i in range(2): - spiral_2d_arr = remote.fetch_spiral_2d() + spiral_2d_arr = remote.fetch_spiral_2d("./another_fetch_folder_for_test/spiral_2d.npy") assert spiral_2d_arr.shape == (114562, 2) - bunny_arr = remote.fetch_bunny() + bunny_arr = remote.fetch_bunny("./another_fetch_folder_for_test/bunny.npy") assert bunny_arr.shape == (35947, 3) - # Check that default dir was created - assert isdir(expanduser("~/gudhi_data")) - # Check downloaded files - assert exists(expanduser("~/gudhi_data/points/spiral_2d/spiral_2d.npy")) - assert exists(expanduser("~/gudhi_data/points/bunny/bunny.npy")) - assert exists(expanduser("~/gudhi_data/points/bunny/bunny.LICENSE")) - - # Test fetch_spiral_2d and fetch_bunny wrapping functions with data directory different from default - spiral_2d_arr = remote.fetch_spiral_2d("./another_fetch_folder_for_test/spiral_2d.npy") - assert spiral_2d_arr.shape == (114562, 2) - - bunny_arr = remote.fetch_bunny("./another_fetch_folder_for_test/bunny.npy") - assert bunny_arr.shape == (35947, 3) - + # Check that the directory was created assert isdir("./another_fetch_folder_for_test") # Check downloaded files assert exists("./another_fetch_folder_for_test/spiral_2d.npy") @@ -86,8 +72,6 @@ def test_fetch_remote_datasets_wrapped(): # Remove test folders del spiral_2d_arr del bunny_arr - if to_be_removed: - shutil.rmtree(expanduser("~/gudhi_data")) shutil.rmtree("./another_fetch_folder_for_test") def test_gudhi_data_env(): -- cgit v1.2.3 From a809771b6d7381d233656f7a0b02211559189bfe Mon Sep 17 00:00:00 2001 From: Hind-M Date: Fri, 6 May 2022 09:52:26 +0200 Subject: Delete bunny array before removing the file --- src/python/test/test_remote_datasets.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index 6f569fd2..cde9fa22 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -38,6 +38,7 @@ def _get_bunny_license_print(accept_license = False): bunny_arr = remote.fetch_bunny("./tmp_for_test/bunny.npy", accept_license) assert bunny_arr.shape == (35947, 3) + del bunny_arr remove("./tmp_for_test/bunny.npy") # Reset redirect -- cgit v1.2.3 From 9e3d0f79234fcc27ee10c4a4f36726775ee262f7 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Fri, 20 May 2022 17:54:27 +0200 Subject: Fix unbalanced groups and some doxygen typos --- .../Permutahedral_representation_iterators.h | 10 ++++++---- src/Persistent_cohomology/concept/FilteredComplex.h | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 11 +++++++---- .../include/gudhi/Simplex_tree/Simplex_tree_iterators.h | 17 +++++++++-------- .../Simplex_tree/Simplex_tree_node_explicit_storage.h | 8 ++++---- .../include/gudhi/Simplex_tree/Simplex_tree_siblings.h | 12 ++++++------ .../include/gudhi/Simplex_tree/indexing_tag.h | 2 +- .../include/gudhi/Active_witness/Active_witness.h | 2 +- .../gudhi/Active_witness/Active_witness_iterator.h | 2 +- .../include/gudhi/Strong_witness_complex.h | 2 +- src/Witness_complex/include/gudhi/Witness_complex.h | 2 +- .../include/gudhi/Witness_complex/all_faces_in.h | 2 +- 12 files changed, 39 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h index db145741..1a63d2f7 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h @@ -26,12 +26,12 @@ namespace Gudhi { namespace coxeter_triangulation { -/* \addtogroup coxeter_triangulation +/** \addtogroup coxeter_triangulation * Iterator types for Permutahedral_representation * @{ */ -/* \brief Iterator over the vertices of a simplex +/** \brief Iterator over the vertices of a simplex * represented by its permutahedral representation. * * Forward iterator, 'value_type' is Permutahedral_representation::Vertex.*/ @@ -83,7 +83,7 @@ class Vertex_iterator }; // Vertex_iterator /*---------------------------------------------------------------------------*/ -/* \brief Iterator over the k-faces of a simplex +/** \brief Iterator over the k-faces of a simplex * given by its permutahedral representation. * * Forward iterator, value_type is Permutahedral_representation. */ @@ -141,7 +141,7 @@ class Face_iterator : public boost::iterator_facade Dictionary; - /* \brief Set of nodes sharing a same parent in the simplex tree. */ - /* \brief Set of nodes sharing a same parent in the simplex tree. */ + /** \brief Set of nodes sharing a same parent in the simplex tree. */ typedef Simplex_tree_siblings Siblings; @@ -1338,7 +1341,7 @@ class Simplex_tree { } } - /* \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given + /** \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given * Vertex_handle if the Vertex_handle is found in the Simplex_handle children list. * Returns null_simplex() if it does not exist */ @@ -1801,7 +1804,7 @@ struct Simplex_tree_options_fast_persistence { static const bool contiguous_vertices = true; }; -/** @} */ // end defgroup simplex_tree +/** @}*/ // end addtogroup simplex_tree } // namespace Gudhi diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h index 394c6ee1..b63a5595 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h @@ -22,12 +22,12 @@ namespace Gudhi { -/* \addtogroup simplex_tree +/** \addtogroup simplex_tree * Iterators and range types for the Simplex_tree. - * @{ + * @{ */ -/* \brief Iterator over the vertices of a simplex +/** \brief Iterator over the vertices of a simplex * in a SimplexTree. * * Forward iterator, 'value_type' is SimplexTree::Vertex_handle.*/ @@ -73,7 +73,7 @@ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade< }; /*---------------------------------------------------------------------------*/ -/* \brief Iterator over the simplices of the boundary of a +/** \brief Iterator over the simplices of the boundary of a * simplex. * * Forward iterator, value_type is SimplexTree::Simplex_handle.*/ @@ -181,7 +181,7 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< SimplexTree * st_; // simplex containing the simplicial complex }; -/* \brief Iterator over the simplices of the boundary of a simplex and their opposite vertices. +/** \brief Iterator over the simplices of the boundary of a simplex and their opposite vertices. * * Forward iterator, value_type is std::pair.*/ template @@ -291,7 +291,7 @@ class Simplex_tree_boundary_opposite_vertex_simplex_iterator : public boost::ite }; /*---------------------------------------------------------------------------*/ -/* \brief Iterator over the simplices of a simplicial complex. +/** \brief Iterator over the simplices of a simplicial complex. * * Forward iterator, value_type is SimplexTree::Simplex_handle.*/ template @@ -364,7 +364,7 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade< SimplexTree * st_; }; -/* \brief Iterator over the simplices of the skeleton of a given +/** \brief Iterator over the simplices of the skeleton of a given * dimension of the simplicial complex. * * Forward iterator, value_type is SimplexTree::Simplex_handle.*/ @@ -447,7 +447,8 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< int curr_dim_; }; -/* @} */ // end addtogroup simplex_tree +/** @}*/ // end addtogroup simplex_tree + } // namespace Gudhi #endif // SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h index ae140859..b18fa029 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h @@ -15,13 +15,12 @@ namespace Gudhi { -/* \addtogroup simplex_tree +/** \addtogroup simplex_tree * Represents a node of a Simplex_tree. * @{ */ -/* - * \brief Node of a simplex tree with filtration value +/** \brief Node of a simplex tree with filtration value * and simplex key. * * It stores explicitely its own filtration value and its own Simplex_key. @@ -54,7 +53,8 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base Siblings * children_; }; -/* @} */ // end addtogroup simplex_tree +/** @}*/ // end addtogroup simplex_tree + } // namespace Gudhi #endif // SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h index ae25d290..d849eeba 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h @@ -20,12 +20,12 @@ namespace Gudhi { -/* \addtogroup simplex_tree +/** \addtogroup simplex_tree * Represents a set of node of a Simplex_tree that share the same parent. * @{ */ -/* \brief Data structure to store a set of nodes in a SimplexTree sharing +/** \brief Data structure to store a set of nodes in a SimplexTree sharing * the same parent node.*/ template class Simplex_tree_siblings { @@ -58,7 +58,7 @@ class Simplex_tree_siblings { members_() { } - /* \brief Constructor with initialized set of members. + /** \brief Constructor with initialized set of members. * * 'members' must be sorted and unique.*/ template @@ -72,8 +72,7 @@ class Simplex_tree_siblings { } } - /* - * \brief Inserts a Node in the set of siblings nodes. + /** \brief Inserts a Node in the set of siblings nodes. * * If already present, assigns the minimal filtration value * between input filtration_value and the value already @@ -114,7 +113,8 @@ class Simplex_tree_siblings { Dictionary members_; }; -/* @} */ // end addtogroup simplex_tree +/** @}*/ // end addtogroup simplex_tree + } // namespace Gudhi #endif // SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h index 3e395ae2..29c76e50 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h @@ -20,7 +20,7 @@ namespace Gudhi { struct linear_indexing_tag { }; -/* \brief Tag for a zigzag ordering of simplices. */ +/** \brief Tag for a zigzag ordering of simplices. */ // struct zigzag_indexing_tag {}; } // namespace Gudhi diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h index 2ae1d6e0..1aebb045 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h @@ -18,7 +18,7 @@ namespace Gudhi { namespace witness_complex { - /* \class Active_witness + /** \class Active_witness * \brief Class representing a list of nearest neighbors to a given witness. * \details Every element is a pair of a landmark identifier and the squared distance to it. */ diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h index 4f8fddba..18f19650 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h @@ -18,7 +18,7 @@ namespace Gudhi { namespace witness_complex { -/* \brief Iterator in the nearest landmark list. +/** \brief Iterator in the nearest landmark list. * \details After the iterator reaches the end of the list, * the list is augmented by a (nearest landmark, distance) pair if possible. * If all the landmarks are present in the list, iterator returns the specific end value diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index b3699f77..ddc0da32 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -125,7 +125,7 @@ class Strong_witness_complex { //@} private: - /* \brief Adds recursively all the faces of a certain dimension dim-1 witnessed by the same witness. + /** \brief Adds recursively all the faces of a certain dimension dim-1 witnessed by the same witness. * Iterator is needed to know until how far we can take landmarks to form simplexes. * simplex is the prefix of the simplexes to insert. * The landmark pointed by aw_it is added to all formed simplices. diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index d655c7f6..66ae7af2 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -127,7 +127,7 @@ class Witness_complex { //@} private: - /* \brief Adds recursively all the faces of a certain dimension dim witnessed by the same witness. + /** \brief Adds recursively all the faces of a certain dimension dim witnessed by the same witness. * Iterator is needed to know until how far we can take landmarks to form simplexes. * simplex is the prefix of the simplexes to insert. * The output value indicates if the witness rests active or not. diff --git a/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h index 5845728a..007ab084 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h +++ b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h @@ -11,7 +11,7 @@ #ifndef WITNESS_COMPLEX_ALL_FACES_IN_H_ #define WITNESS_COMPLEX_ALL_FACES_IN_H_ -/* \brief Check if the facets of the k-dimensional simplex witnessed +/** \brief Check if the facets of the k-dimensional simplex witnessed * by witness witness_id are already in the complex. * inserted_vertex is the handle of the (k+1)-th vertex witnessed by witness_id */ -- cgit v1.2.3 From f043cf8aaf676cc88e84082de49f70dd3492ecb0 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 22 May 2022 12:08:58 +0200 Subject: Documentation: handling references to examples in a more transparent way In case we have the files`Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp` this will be linked to `_random_bitmap_cubical_complex_8cpp-example.html` and this is now hard coded. When the setting of `CASE_SENSE_NAMES` is set to `YES` the mapping is to `Random_bitmap_cubical_complex_8cpp-example.html` but the hard coded link is still to `_random_bitmap_cubical_complex_8cpp-example.html` so the link cannot be resolved (at runtime!). Same could happen when the `CASE_SENSE_NAMES` is left blank and the the value is system dependent. It is unlikely that this happens but ... By introducing the `ALIASES` `gudhi_example_link` this can be handled by doxygen in a more transparent way. Furthermore wit 2 examples there was a double `cpp` in the text part, this has been corrected as well Notre this solution supersedes #621 and maked #621 obsolete. --- src/Doxyfile.in | 2 +- src/common/doc/installation.h | 234 ++++++++++++++---------------------------- 2 files changed, 79 insertions(+), 157 deletions(-) (limited to 'src') diff --git a/src/Doxyfile.in b/src/Doxyfile.in index f76ba2bd..b15d47a6 100644 --- a/src/Doxyfile.in +++ b/src/Doxyfile.in @@ -229,7 +229,7 @@ TAB_SIZE = 2 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = +ALIASES = gudhi_example_link{2}="@ref \2 \"\1/\2\"" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 67d026bd..fb5ee665 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -76,58 +76,32 @@ make \endverbatim * * The following examples/utilities require the Computational Geometry Algorithms * Library (CGAL \cite cgal:eb-19b) and will not be built if CGAL version 4.11.0 or higher is not installed: - * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_strong_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_sphere.cpp - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * \li - * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp - * \li - * Bottleneck_distance/bottleneck_basic_example.cpp - * \li - * Bottleneck_distance/bottleneck_distance.cpp - * \li - * Nerve_GIC/CoordGIC.cpp - * \li - * Nerve_GIC/FuncGIC.cpp - * \li - * Nerve_GIC/Nerve.cpp - * \li - * Nerve_GIC/VoronoiGIC.cpp - * \li - * Spatial_searching/example_spatial_searching.cpp - * \li - * Subsampling/example_choose_n_farthest_points.cpp - * \li - * Subsampling/example_pick_n_random_points.cpp - * \li - * Subsampling/example_sparsify_point_set.cpp - * \li - * Tangential_complex/example_basic.cpp - * \li - * Tangential_complex/example_with_perturb.cpp - * \li - * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Coxeter_triangulation/manifold_tracing_flat_torus_with_boundary.cpp + * \li \gudhi_example_link{Simplex_tree,example_alpha_shapes_3_simplex_tree_from_off_file.cpp} + * \li \gudhi_example_link{Witness_complex,strong_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,weak_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,example_strong_witness_complex_off.cpp} + * \li \gudhi_example_link{Witness_complex,example_witness_complex_off.cpp} + * \li \gudhi_example_link{Witness_complex,example_witness_complex_sphere.cpp} + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_off.cpp} + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_points.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_persistence.cpp} + * \li \gudhi_example_link{Persistent_cohomology,custom_persistence_sort.cpp} + * \li \gudhi_example_link{Bottleneck_distance,alpha_rips_persistence_bottleneck_distance.cpp} + * \li \gudhi_example_link{Bottleneck_distance,bottleneck_basic_example.cpp} + * \li \gudhi_example_link{Bottleneck_distance,bottleneck_distance.cpp} + * \li \gudhi_example_link{Nerve_GIC,CoordGIC.cpp} + * \li \gudhi_example_link{Nerve_GIC,FuncGIC.cpp} + * \li \gudhi_example_link{Nerve_GIC,Nerve.cpp} + * \li \gudhi_example_link{Nerve_GIC,VoronoiGIC.cpp} + * \li \gudhi_example_link{Spatial_searching,example_spatial_searching.cpp} + * \li \gudhi_example_link{Subsampling,example_choose_n_farthest_points.cpp} + * \li \gudhi_example_link{Subsampling,example_pick_n_random_points.cpp} + * \li \gudhi_example_link{Subsampling,example_sparsify_point_set.cpp} + * \li \gudhi_example_link{Tangential_complex,example_basic.cpp} + * \li \gudhi_example_link{Tangential_complex,example_with_perturb.cpp} + * \li \gudhi_example_link{Alpha_complex,Weighted_alpha_complex_3d_from_points.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_3d_persistence.cpp} + * \li \gudhi_example_link{Coxeter_triangulation,manifold_tracing_flat_torus_with_boundary.cpp} * * \subsection eigen Eigen * Some GUDHI modules (cf. \ref main_page "modules list"), and few examples require @@ -136,48 +110,27 @@ make \endverbatim * * The following examples/utilities require the Eigen and will not be * built if Eigen is not installed: - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp - * \li - * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * \li - * Spatial_searching/example_spatial_searching.cpp - * \li - * Subsampling/example_choose_n_farthest_points.cpp - * \li - * Subsampling/example_pick_n_random_points.cpp - * \li - * Subsampling/example_sparsify_point_set.cpp - * \li - * Tangential_complex/example_basic.cpp - * \li - * Tangential_complex/example_with_perturb.cpp - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_strong_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_sphere.cpp - * \li - * Coxeter_triangulation/cell_complex_from_basic_circle_manifold.cpp - * \li - * Coxeter_triangulation/manifold_tracing_custom_function.cpp - * \li - * Coxeter_triangulation/manifold_tracing_flat_torus_with_boundary.cpp + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_off.cpp} + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_points.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_persistence.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_3d_persistence.cpp} + * \li \gudhi_example_link{Alpha_complex,Weighted_alpha_complex_3d_from_points.cpp} + * \li \gudhi_example_link{Bottleneck_distance,alpha_rips_persistence_bottleneck_distance.cpp} + * \li \gudhi_example_link{Persistent_cohomology,custom_persistence_sort.cpp} + * \li \gudhi_example_link{Spatial_searching,example_spatial_searching.cpp} + * \li \gudhi_example_link{Subsampling,example_choose_n_farthest_points.cpp} + * \li \gudhi_example_link{Subsampling,example_pick_n_random_points.cpp} + * \li \gudhi_example_link{Subsampling,example_sparsify_point_set.cpp} + * \li \gudhi_example_link{Tangential_complex,example_basic.cpp} + * \li \gudhi_example_link{Tangential_complex,example_with_perturb.cpp} + * \li \gudhi_example_link{Witness_complex,strong_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,weak_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,example_strong_witness_complex_off.cpp} + * \li \gudhi_example_link{Witness_complex,example_witness_complex_off.cpp} + * \li \gudhi_example_link{Witness_complex,example_witness_complex_sphere.cpp} + * \li \gudhi_example_link{Coxeter_triangulation,cell_complex_from_basic_circle_manifold.cpp} + * \li \gudhi_example_link{Coxeter_triangulation,manifold_tracing_custom_function.cpp} + * \li \gudhi_example_link{Coxeter_triangulation,manifold_tracing_flat_torus_with_boundary.cpp} * * \subsection tbb Threading Building Blocks * Intel® TBB lets you easily write parallel @@ -187,68 +140,37 @@ make \endverbatim * Having Intel® TBB installed is recommended to parallelize and accelerate some GUDHI computations. * * The following examples/utilities are using Intel® TBB if installed: - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Bitmap_cubical_complex/cubical_complex_persistence.cpp - * \li - * Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp - * \li - * Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp - * \li - * Nerve_GIC/CoordGIC.cpp - * \li - * Nerve_GIC/FuncGIC.cpp - * \li - * Nerve_GIC/Nerve.cpp - * \li - * Nerve_GIC/VoronoiGIC.cpp - * \li - * Simplex_tree/simple_simplex_tree.cpp - * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - * \li - * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - * \li - * Simplex_tree/graph_expansion_with_blocker.cpp - * \li - * Persistent_cohomology/alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/alpha_complex_persistence.cpp - * \li - * Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp - * \li - * Persistent_cohomology/persistence_from_file.cpp - * \li - * Persistent_cohomology/persistence_from_simple_simplex_tree.cpp - * \li - * Persistent_cohomology/plain_homology.cpp - * \li - * Persistent_cohomology/rips_multifield_persistence.cpp - * \li - * Persistent_cohomology/rips_persistence_step_by_step.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * \li - * Rips_complex/example_one_skeleton_rips_from_points.cpp - * \li - * Rips_complex/example_rips_complex_from_off_file.cpp - * \li - * Rips_complex/rips_distance_matrix_persistence.cpp - * \li - * Rips_complex/rips_persistence.cpp - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_nearest_landmark_table.cpp + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_off.cpp} + * \li \gudhi_example_link{Alpha_complex,Alpha_complex_from_points.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_3d_persistence.cpp} + * \li \gudhi_example_link{Alpha_complex,alpha_complex_persistence.cpp} + * \li \gudhi_example_link{Bitmap_cubical_complex,cubical_complex_persistence.cpp} + * \li \gudhi_example_link{Bitmap_cubical_complex,periodic_cubical_complex_persistence.cpp} + * \li \gudhi_example_link{Bitmap_cubical_complex,Random_bitmap_cubical_complex.cpp} + * \li \gudhi_example_link{Nerve_GIC,CoordGIC.cpp} + * \li \gudhi_example_link{Nerve_GIC,FuncGIC.cpp} + * \li \gudhi_example_link{Nerve_GIC,Nerve.cpp} + * \li \gudhi_example_link{Nerve_GIC,VoronoiGIC.cpp} + * \li \gudhi_example_link{Simplex_tree,simple_simplex_tree.cpp} + * \li \gudhi_example_link{Simplex_tree,example_alpha_shapes_3_simplex_tree_from_off_file.cpp} + * \li \gudhi_example_link{Simplex_tree,simplex_tree_from_cliques_of_graph.cpp} + * \li \gudhi_example_link{Simplex_tree,graph_expansion_with_blocker.cpp} + * \li \gudhi_example_link{Persistent_cohomology,alpha_complex_3d_persistence.cpp} + * \li \gudhi_example_link{Persistent_cohomology,alpha_complex_persistence.cpp} + * \li \gudhi_example_link{Persistent_cohomology,rips_persistence_via_boundary_matrix.cpp} + * \li \gudhi_example_link{Persistent_cohomology,persistence_from_file.cpp} + * \li \gudhi_example_link{Persistent_cohomology,persistence_from_simple_simplex_tree.cpp} + * \li \gudhi_example_link{Persistent_cohomology,plain_homology.cpp} + * \li \gudhi_example_link{Persistent_cohomology,rips_multifield_persistence.cpp} + * \li \gudhi_example_link{Persistent_cohomology,rips_persistence_step_by_step.cpp} + * \li \gudhi_example_link{Persistent_cohomology,custom_persistence_sort.cpp} + * \li \gudhi_example_link{Rips_complex,example_one_skeleton_rips_from_points.cpp} + * \li \gudhi_example_link{Rips_complex,example_rips_complex_from_off_file.cpp} + * \li \gudhi_example_link{Rips_complex,rips_distance_matrix_persistence.cpp} + * \li \gudhi_example_link{Rips_complex,rips_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,strong_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,weak_witness_persistence.cpp} + * \li \gudhi_example_link{Witness_complex,example_nearest_landmark_table.cpp} * * \section Contributions Bug reports and contributions * Please help us improving the quality of the GUDHI library. -- cgit v1.2.3 From a00ce1990b112aa34f72e5504ae0cfe14f11e292 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 22 May 2022 17:58:57 +0200 Subject: Spelling corrections A number of spelling corrections as reported by the codespell (see: https://github.com/codespell-project/codespell) program and lists. Some remarks: - not considered are grammatical errors - not considered are names in the code although there are a number that could be improved (like `childs` -> `children`) - in the documentation it could be made clearer what are variables and what is running text (e.g. by placing variables in running text between backticks) - some comments are in the French language, I think it would be better to have them in the English (United States version). --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 2 +- .../include/gudhi/Bitmap_cubical_complex.h | 2 +- .../include/gudhi/Bitmap_cubical_complex_base.h | 2 +- src/Bottleneck_distance/include/gudhi/Neighbors_finder.h | 2 +- src/Cech_complex/include/gudhi/Miniball.hpp | 2 +- src/Collapse/example/edge_collapse_conserve_persistence.cpp | 2 +- src/Collapse/include/gudhi/Flag_complex_edge_collapser.h | 2 +- .../distance_matrix_edge_collapse_rips_persistence.cpp | 2 +- .../utilities/point_cloud_edge_collapse_rips_persistence.cpp | 2 +- src/Contraction/doc/so3.svg | 2 +- src/Contraction/example/Garland_heckbert/Error_quadric.h | 2 +- src/Contraction/include/gudhi/Edge_contraction.h | 8 ++++---- src/Contraction/include/gudhi/Skeleton_blocker_contractor.h | 6 +++--- .../Coxeter_triangulation/Cell_complex/Hasse_diagram_cell.h | 6 +++--- .../include/gudhi/Functions/Function_affine_plane_in_Rd.h | 4 ++-- .../include/gudhi/Permutahedral_representation/Size_range.h | 2 +- src/GudhUI/todo.txt | 2 +- src/GudhUI/utils/Critical_points.h | 2 +- src/GudhUI/utils/Edge_contractor.h | 2 +- src/GudhUI/utils/Furthest_point_epsilon_net.h | 4 ++-- src/GudhUI/utils/K_nearest_builder.h | 2 +- src/GudhUI/utils/Lloyd_builder.h | 2 +- src/GudhUI/utils/Vertex_collapsor.h | 2 +- src/Nerve_GIC/utilities/km.py.COPYRIGHT | 2 +- .../include/gudhi/Persistence_intervals.h | 4 ++-- .../benchmark/performance_rips_persistence.cpp | 2 +- .../example/custom_persistence_sort.cpp | 2 +- .../example/persistence_from_simple_simplex_tree.cpp | 2 +- .../example/rips_multifield_persistence.cpp | 2 +- .../include/gudhi/Persistent_cohomology.h | 2 +- .../example_one_skeleton_rips_from_correlation_matrix.cpp | 2 +- src/Simplex_tree/example/graph_expansion_with_blocker.cpp | 2 +- src/Simplex_tree/example/simple_simplex_tree.cpp | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- .../gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h | 2 +- .../test/simplex_tree_graph_expansion_unit_test.cpp | 4 ++-- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 4 ++-- .../gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h | 2 +- .../gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h | 8 ++++---- .../include/gudhi/Skeleton_blocker/internal/Trie.h | 2 +- .../iterators/Skeleton_blockers_triangles_iterators.h | 4 ++-- .../include/gudhi/Skeleton_blocker_complex.h | 12 ++++++------ src/Tangential_complex/include/gudhi/Tangential_complex.h | 2 +- src/cmake/modules/FindTBB.cmake | 6 +++--- src/cmake/modules/GUDHI_modules.cmake | 4 ++-- src/cmake/modules/GUDHI_options.cmake | 10 +++++----- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/common/include/gudhi/reader_utils.h | 2 +- src/common/include/gudhi/writing_persistence_to_file.h | 4 ++-- src/python/CMakeLists.txt | 6 +++--- ...agram_persistence_from_correlation_matrix_file_example.py | 2 +- src/python/gudhi/hera/wasserstein.cc | 2 +- src/python/gudhi/persistence_graphical_tools.py | 2 +- src/python/gudhi/wasserstein/barycenter.py | 6 +++--- src/python/test/test_simplex_tree.py | 2 +- src/python/test/test_subsampling.py | 4 ++-- 56 files changed, 91 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 028ec9bb..b1a9407b 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -69,7 +69,7 @@ template struct Is_Epeck_D> { static const bool val * \ingroup alpha_complex * * \details - * The data structure is constructing a CGAL Delaunay triangulation (for more informations on CGAL Delaunay + * The data structure is constructing a CGAL Delaunay triangulation (for more information on CGAL Delaunay * triangulation, please refer to the corresponding chapter in page http://doc.cgal.org/latest/Triangulation/) from a * range of points or from an OFF file (cf. Points_off_reader). * diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h index aa255ec2..51f6a273 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -237,7 +237,7 @@ class Bitmap_cubical_complex : public T { * Filtration_simplex_iterator class provides an iterator though the whole structure in the order of filtration. * Secondary criteria for filtration are: * (1) Dimension of a cube (lower dimensional comes first). - * (2) Position in the data structure (the ones that are earlies in the data structure comes first). + * (2) Position in the data structure (the ones that are earliest in the data structure comes first). **/ class Filtration_simplex_range; diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h index f8f80ded..bafe7981 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h @@ -43,7 +43,7 @@ namespace cubical_complex { * Each cell is represented by a single * bit (in case of black and white bitmaps, or by a single element of a type T * (here T is a filtration type of a bitmap, typically a double). - * All the informations needed for homology and + * All the information needed for homology and * persistent homology computations (like dimension of a cell, boundary and * coboundary elements of a cell, are then obtained from the * position of the element in C. diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h index c65e6082..1d56f0b4 100644 --- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h +++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h @@ -86,7 +86,7 @@ class Neighbors_finder { }; /** \internal \brief data structure used to find any point (including projections) in V near to a query point from U - * (which can be a projection) in a layered graph layer given as parmeter. + * (which can be a projection) in a layered graph layer given as parameter. * * V points have to be added manually using their index and before the first pull. A neighbor pulled is automatically * removed. diff --git a/src/Cech_complex/include/gudhi/Miniball.hpp b/src/Cech_complex/include/gudhi/Miniball.hpp index ce6cbb5b..55387a8a 100644 --- a/src/Cech_complex/include/gudhi/Miniball.hpp +++ b/src/Cech_complex/include/gudhi/Miniball.hpp @@ -1,4 +1,4 @@ -// Copright (C) 1999-2013, Bernd Gaertner +// Copyright (C) 1999-2013, Bernd Gaertner // $Rev: 3581 $ // // This program is free software: you can redistribute it and/or modify diff --git a/src/Collapse/example/edge_collapse_conserve_persistence.cpp b/src/Collapse/example/edge_collapse_conserve_persistence.cpp index b2c55e7a..19960597 100644 --- a/src/Collapse/example/edge_collapse_conserve_persistence.cpp +++ b/src/Collapse/example/edge_collapse_conserve_persistence.cpp @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) { Gudhi::Euclidean_distance()); if (num_edges(proximity_graph) <= 0) { - std::cerr << "Total number of egdes are zero." << std::endl; + std::cerr << "Total number of edges is zero." << std::endl; exit(-1); } diff --git a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h index c823901f..d0b3fe4a 100644 --- a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h +++ b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h @@ -53,7 +53,7 @@ struct Flag_complex_edge_collapser { #ifdef GUDHI_COLLAPSE_USE_DENSE_ARRAY // Minimal matrix interface // Using this matrix generally helps performance, but the memory use may be excessive for a very sparse graph - // (and in extreme cases the constant initialization of the matrix may start to dominate the runnning time). + // (and in extreme cases the constant initialization of the matrix may start to dominate the running time). // Are there cases where the matrix is too big but a hash table would help? std::vector neighbors_data; void init_neighbors_dense(){ diff --git a/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp b/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp index 11ee5871..38efb9e6 100644 --- a/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp +++ b/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { min_persistence); Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file(csv_matrix_file); - std::cout << "Read the distance matrix succesfully, of size: " << distances.size() << std::endl; + std::cout << "Read the distance matrix successfully, of size: " << distances.size() << std::endl; Proximity_graph proximity_graph = Gudhi::compute_proximity_graph(boost::irange((size_t)0, distances.size()), diff --git a/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp b/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp index 0eea742c..d8f42ab6 100644 --- a/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp +++ b/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { Gudhi::Euclidean_distance()); if (num_edges(proximity_graph) <= 0) { - std::cerr << "Total number of egdes are zero." << std::endl; + std::cerr << "Total number of edges is zero." << std::endl; exit(-1); } diff --git a/src/Contraction/doc/so3.svg b/src/Contraction/doc/so3.svg index adea3f38..f10cab98 100644 --- a/src/Contraction/doc/so3.svg +++ b/src/Contraction/doc/so3.svg @@ -177,7 +177,7 @@ x="309.4176" y="300.58682" id="tspan4515-4" - style="text-align:center;text-anchor:middle">Rips complex built uppon these pointsRips complex built upon these points class Error_quadric { * Quadric corresponding to the L2 distance to the plane. * * According to the notation of Garland Heckbert, they - * denote a quadric symetric matrix as : + * denote a quadric symmetric matrix as : * Q = [ q11 q12 q13 q14] * [ q12 q22 q23 q24] * [ q13 q23 q33 q34] diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h index 58d627c2..0b43c3b3 100644 --- a/src/Contraction/include/gudhi/Edge_contraction.h +++ b/src/Contraction/include/gudhi/Edge_contraction.h @@ -46,7 +46,7 @@ the operations needed for edge contraction algorithms have polynomial complexity Therefore, the simplification can be done without enumerating the set of simplices that is often non tracktable in high-dimension and is then very efficient (sub-linear with regards to the number of simplices in practice). -A typical application of this package is homology group computation. It is illustrated in the next figure where a Rips complex is built uppon a set of high-dimensional points and +A typical application of this package is homology group computation. It is illustrated in the next figure where a Rips complex is built upon a set of high-dimensional points and simplified with edge contractions. It has initially a big number of simplices (around 20 millions) but simplifying it to a much reduced form with only 15 vertices (and 714 simplices) takes only few seconds on a desktop machine (see the example bellow). One can then compute homology group with a simplicial complex having very few simplices instead of running the homology algorithm on the much bigger initial set of @@ -65,7 +65,7 @@ This class design is policy based and heavily inspired from the similar edge col Four policies can be customized in this package: \li Cost_policy: specify how much cost an edge contraction of a given edge. The edge with lowest cost is iteratively picked and contracted if valid. -\li Valid_contraction_policy: specify if a given edge contraction is valid. For instance, this policy can check the link condition which ensures that the homotopy type is preserved afer the edge contraction. +\li Valid_contraction_policy: specify if a given edge contraction is valid. For instance, this policy can check the link condition which ensures that the homotopy type is preserved after the edge contraction. \li Placement_policy: every time an edge is contracted, its points are merge to one point specified by this policy. This may be the middle of the edge of some more sophisticated point such as the minimum of a cost as in \cite Garland. @@ -92,7 +92,7 @@ Despite this package is able to deal with \a arbitrary simplicial complexes (any it is still \a 65% times faster than the CGAL package which is focused on 2-manifold. The main reason is that few blockers appears during the simplification and hence, the algorithm only have to deal with the graph and not higher-dimensional simplices -(in this case triangles). However, we recall that higher-dimensional simplices are \a implicitely +(in this case triangles). However, we recall that higher-dimensional simplices are \a implicitly stored in the \ref skbl data-structure. Hence, one has to store simplices in an external map if some information needs to be associated with them (information that could be a filtration value or an orientation for instance). @@ -153,7 +153,7 @@ void build_rips(ComplexType& complex, double offset){ int main (int argc, char *argv[]) { if (argc!=3){ - std::cerr << "Usage "< { std::size_t id = 0; - // xxx do a parralel for + // xxx do a parallel for for (auto edge : complex_.edge_range()) { complex_[edge].index() = id++; Profile const& profile = create_profile(edge); @@ -474,7 +474,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> { } void update_changed_edges() { - // xxx do a parralel for + // xxx do a parallel for DBG("update edges"); // sequential loop @@ -530,7 +530,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> { // by definition of a blocker // todo uniqument utile pour la link condition - // laisser a l'utilisateur ? booleen update_heap_on_removed_blocker? + // laisser a l'utilisateur ? boolean update_heap_on_removed_blocker? Simplex blocker_copy(*blocker); for (auto x = blocker_copy.begin(); x != blocker_copy.end(); ++x) { for (auto y = x; ++y != blocker_copy.end();) { diff --git a/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation/Cell_complex/Hasse_diagram_cell.h b/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation/Cell_complex/Hasse_diagram_cell.h index 59e9a350..9b57da3c 100644 --- a/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation/Cell_complex/Hasse_diagram_cell.h +++ b/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation/Cell_complex/Hasse_diagram_cell.h @@ -95,7 +95,7 @@ class Hasse_diagram_cell { deleted_(false) {} /** - * Construcor of a cell of dimension dim having given additional information. + * Constructor of a cell of dimension dim having given additional information. **/ Hasse_diagram_cell(Additional_information ai, int dim) : dimension(dim), additional_info(ai), position(0), deleted_(false) {} @@ -125,7 +125,7 @@ class Hasse_diagram_cell { inline Additional_information& get_additional_information() { return this->additional_info; } /** - * Procedure to retrive position of the cell in the structure. It is used in + * Procedure to retrieve the position of the cell in the structure. It is used in * the implementation of Hasse diagram and set by it. Note that removal of * cell and subsequent call of clean_up_the_structure will change those * positions. @@ -186,7 +186,7 @@ class Hasse_diagram_cell { friend std::ostream& operator<<( std::ostream& out, const Hasse_diagram_cell& c) { // cout << "position : " << c.position << ", dimension : " << c.dimension << ", filtration: " << c.filtration << ", - // size of boudary : " << c.boundary.size() << "\n"; + // size of boundary : " << c.boundary.size() << "\n"; out << c.position << " " << c.dimension << " " << c.filtration << std::endl; for (std::size_t bd = 0; bd != c.boundary.size(); ++bd) { // do not write out the cells that has been deleted diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h index b29f0906..dc6f5f90 100644 --- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h +++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h @@ -51,7 +51,7 @@ struct Function_affine_plane_in_Rd { * plane in the d-dimensional Euclidean space. * * @param[in] normal_matrix A normal matrix of the affine plane. The number of rows should - * correspond to the ambient dimension, the number of columns should corespond to + * correspond to the ambient dimension, the number of columns should correspond to * the size of the normal basis (codimension). * @param[in] offset The offset vector of the affine plane. * The dimension of the vector should be the ambient dimension of the manifold. @@ -66,7 +66,7 @@ struct Function_affine_plane_in_Rd { * plane in the d-dimensional Euclidean space that passes through origin. * * @param[in] normal_matrix A normal matrix of the affine plane. The number of rows should - * correspond to the ambient dimension, the number of columns should corespond to + * correspond to the ambient dimension, the number of columns should correspond to * the size of the normal basis (codimension). */ Function_affine_plane_in_Rd(const Eigen::MatrixXd& normal_matrix) diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h index c43effc8..6b137744 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h @@ -19,7 +19,7 @@ namespace Gudhi { namespace coxeter_triangulation { -/** \brief Auxillary iterator class for sizes of parts in an ordered set partition. +/** \brief Auxiliary iterator class for sizes of parts in an ordered set partition. */ template class Size_iterator diff --git a/src/GudhUI/todo.txt b/src/GudhUI/todo.txt index 19d99a77..e59d06d4 100644 --- a/src/GudhUI/todo.txt +++ b/src/GudhUI/todo.txt @@ -18,5 +18,5 @@ x faire le lien MainWindow - Model -- bug -x bug ordre contraction -> just that first vertex placement dont work great +x bug ordre contraction -> just that first vertex placement doesn't work great x pb construction rips diff --git a/src/GudhUI/utils/Critical_points.h b/src/GudhUI/utils/Critical_points.h index 97e58737..65695434 100644 --- a/src/GudhUI/utils/Critical_points.h +++ b/src/GudhUI/utils/Critical_points.h @@ -103,7 +103,7 @@ template class Critical_points { // reduced to one point -> contractible return 1; else - // we dont know + // we don't know return 2; } diff --git a/src/GudhUI/utils/Edge_contractor.h b/src/GudhUI/utils/Edge_contractor.h index 0707b186..a71d0742 100644 --- a/src/GudhUI/utils/Edge_contractor.h +++ b/src/GudhUI/utils/Edge_contractor.h @@ -65,7 +65,7 @@ template class Edge_contractor { /** * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. + * symmetric graph. */ Edge_contractor(SkBlComplex& complex, unsigned num_contractions) : complex_(complex), num_contractions_(num_contractions) { diff --git a/src/GudhUI/utils/Furthest_point_epsilon_net.h b/src/GudhUI/utils/Furthest_point_epsilon_net.h index 6eb71071..195d0014 100644 --- a/src/GudhUI/utils/Furthest_point_epsilon_net.h +++ b/src/GudhUI/utils/Furthest_point_epsilon_net.h @@ -27,7 +27,7 @@ template class Furthest_point_epsilon_net { /** * Let V be the set of vertices. - * Initially v0 is one arbitrarly vertex and the set V0 is {v0}. + * Initially v0 is one, arbitrary, vertex and the set V0 is {v0}. * Then Vk is computed as follows. * First we compute the vertex pk that is the furthest from Vk * then Vk = Vk \cup pk. @@ -54,7 +54,7 @@ template class Furthest_point_epsilon_net { /** * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. + * symmetric graph. */ Furthest_point_epsilon_net(SkBlComplex& complex) : complex_(complex) { diff --git a/src/GudhUI/utils/K_nearest_builder.h b/src/GudhUI/utils/K_nearest_builder.h index 34483e58..454b2587 100644 --- a/src/GudhUI/utils/K_nearest_builder.h +++ b/src/GudhUI/utils/K_nearest_builder.h @@ -41,7 +41,7 @@ template class K_nearest_builder { public: /** * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. + * symmetric graph. */ K_nearest_builder(SkBlComplex& complex, unsigned k) : complex_(complex) { complex.keep_only_vertices(); diff --git a/src/GudhUI/utils/Lloyd_builder.h b/src/GudhUI/utils/Lloyd_builder.h index c042564f..57e3dc0f 100644 --- a/src/GudhUI/utils/Lloyd_builder.h +++ b/src/GudhUI/utils/Lloyd_builder.h @@ -27,7 +27,7 @@ template class Lloyd_builder { /** * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. + * symmetric graph. */ Lloyd_builder(SkBlComplex& complex, unsigned num_iterations) : complex_(complex), dim(-1) { if (!complex_.empty()) { diff --git a/src/GudhUI/utils/Vertex_collapsor.h b/src/GudhUI/utils/Vertex_collapsor.h index 030e4bb0..b1c48efd 100644 --- a/src/GudhUI/utils/Vertex_collapsor.h +++ b/src/GudhUI/utils/Vertex_collapsor.h @@ -31,7 +31,7 @@ template class Vertex_collapsor { /** * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. + * symmetric graph. */ Vertex_collapsor(SkBlComplex& complex, size_t num_collapses) : complex_(complex), num_collapses_(num_collapses) { diff --git a/src/Nerve_GIC/utilities/km.py.COPYRIGHT b/src/Nerve_GIC/utilities/km.py.COPYRIGHT index bef7b121..5358d287 100644 --- a/src/Nerve_GIC/utilities/km.py.COPYRIGHT +++ b/src/Nerve_GIC/utilities/km.py.COPYRIGHT @@ -1,7 +1,7 @@ km.py is a fork of https://github.com/MLWave/kepler-mapper. Only the visualization part has been kept (Mapper part has been removed). -This file has te following Copyright : +This file has the following Copyright : The MIT License (MIT) diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h index a6c1d6f0..f4324cb2 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h +++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h @@ -109,7 +109,7 @@ class Persistence_intervals { std::vector cumulative_histogram_of_lengths(size_t number_of_bins = 10) const; /** - * In this procedure we assume that each barcode is a characteristic function of a hight equal to its length. The + * In this procedure we assume that each barcode is a characteristic function of a height equal to its length. The *persistence diagram is a sum of such a functions. The procedure below construct a function being a * sum of the characteristic functions of persistence intervals. The first two parameters are the range in which the *function is to be computed and the last parameter is the number of bins in @@ -207,7 +207,7 @@ class Persistence_intervals { /** * This is a simple function projecting the persistence intervals to a real number. The function we use here is a sum *of squared lengths of intervals. It can be naturally interpreted as - * sum of step function, where the step hight it equal to the length of the interval. + * sum of step function, where the step height it equal to the length of the interval. * At the moment this function is not tested, since it is quite likely to be changed in the future. Given this, when *using it, keep in mind that it * will be most likely changed in the next versions. diff --git a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp index 030b072a..3bec8830 100644 --- a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp +++ b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp @@ -49,7 +49,7 @@ void timing_persistence(FilteredComplex & cpx * with a Hasse diagram. The Hasse diagram represents explicitly all * codimension 1 incidence relations in the complex, and hence leads to * a faster computation of persistence because boundaries are precomputed. - * Hovewer, the simplex tree may be constructed directly from a point cloud and + * However, the simplex tree may be constructed directly from a point cloud and * is more compact. * We compute persistent homology with coefficient fields Z/2Z and Z/1223Z. * We present also timings for the computation of multi-field persistent diff --git a/src/Persistent_cohomology/example/custom_persistence_sort.cpp b/src/Persistent_cohomology/example/custom_persistence_sort.cpp index 410cd987..bba0b2f7 100644 --- a/src/Persistent_cohomology/example/custom_persistence_sort.cpp +++ b/src/Persistent_cohomology/example/custom_persistence_sort.cpp @@ -33,7 +33,7 @@ using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomolog Gudhi::persistent_cohomology::Field_Zp >; std::vector random_points() { - // Instanciate a random point generator + // Instantiate a random point generator CGAL::Random rng(0); // Generate "points_number" random points in a vector diff --git a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp index bffaabdd..3da6771e 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -95,7 +95,7 @@ int main(int argc, char * const argv[]) { SimplexVector = {9, 10, 11}; st.insert_simplex_and_subfaces(SimplexVector, 0.3); - // ++ NINETH + // ++ NINTH std::clog << " - INSERT (2,10,12)" << std::endl; SimplexVector = {2, 10, 12}; st.insert_simplex_and_subfaces(SimplexVector, 0.3); diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index 2edf5bc4..d154bcde 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -104,7 +104,7 @@ void program_options(int argc, char * argv[] ("min-field-charac,p", po::value(&min_p)->default_value(2), "Minimal characteristic p of the coefficient field Z/pZ.") ("max-field-charac,q", po::value(&max_p)->default_value(1223), - "Minimial characteristic q of the coefficient field Z/pZ.") + "Minimal characteristic q of the coefficient field Z/pZ.") ("min-persistence,m", po::value(&min_persistence), "Minimal lifetime of homology feature to be recorded. Default is 0"); diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index d428e497..2301a66b 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -211,7 +211,7 @@ class Persistent_cohomology { /** \brief Update the cohomology groups under the insertion of an edge. * * The 0-homology is maintained with a simple Union-Find data structure, which - * explains the existance of a specific function of edge insertions. */ + * explains the existence of a specific function of edge insertions. */ void update_cohomology_groups_edge(Simplex_handle sigma) { Simplex_handle u, v; boost::tie(u, v) = cpx_->endpoints(sigma); diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp index 3d2ba54f..3811d1f1 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp @@ -40,7 +40,7 @@ int main() { throw "The input matrix is not a correlation matrix. The program will now terminate.\n"; } correlations[i][j] = 1 - correlations[i][j]; - // Here we make sure that we will get the treshold value equal to maximal + // Here we make sure that we will get the threshold value equal to maximal // distance in the matrix. if (correlations[i][j] > threshold) threshold = correlations[i][j]; } diff --git a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp index df52bf43..eef8b665 100644 --- a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp +++ b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp @@ -42,7 +42,7 @@ int main(int argc, char* const argv[]) { std::clog << vertex << ", "; } std::clog << "] ( " << stree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boundaries) stree.assign_filtration(sh, stree.filtration(sh) + 1.); std::clog << " + 1. ) = " << result << std::endl; diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index e8bec596..965711da 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -129,7 +129,7 @@ int main(int argc, char* const argv[]) { std::clog << " - 3 NOT INSERTED" << std::endl; } - // ++ NINETH + // ++ NINTH std::clog << " * INSERT (3,0)" << std::endl; typeVectorVertex ninethSimplexVector = {3, 0}; returnValue = simplexTree.insert_simplex(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 34bc5ace..629a1f9c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -965,7 +965,7 @@ class Simplex_tree { // If we reached the end of the vertices, and the simplex has more vertices than the given simplex // => we found a coface - // Add a coface if we wan't the star or if the number of vertices of the current simplex matches with nbVertices + // Add a coface if we want the star or if the number of vertices of the current simplex matches with nbVertices bool addCoface = (star || curr_nbVertices == nbVertices); if (addCoface) cofaces.push_back(simplex); @@ -1491,7 +1491,7 @@ class Simplex_tree { int sh_dimension = dimension(sh); if (sh_dimension >= dimension_) - // Stop browsing as soon as the dimension is reached, no need to go furter + // Stop browsing as soon as the dimension is reached, no need to go further return false; new_dimension = (std::max)(new_dimension, sh_dimension); } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h index ae140859..ad53710c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h @@ -24,7 +24,7 @@ namespace Gudhi { * \brief Node of a simplex tree with filtration value * and simplex key. * - * It stores explicitely its own filtration value and its own Simplex_key. + * It stores explicitly its own filtration value and its own Simplex_key. */ template struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base, SimplexTree::Key_simplex_base { diff --git a/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp index 6d63d8ae..54e23204 100644 --- a/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_3, typeST, li std::clog << vertex << ", "; } std::clog << "] ( " << simplex_tree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boundaries) simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); std::clog << " + 1. ) = " << result << std::endl; @@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_2, typeST, li std::clog << vertex << ", "; } std::clog << "] ( " << simplex_tree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boundaries) simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); std::clog << " + 1. ) = " << result << std::endl; diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index b18e2ec4..79bb5a93 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var set_and_test_simplex_tree_dim_fil(st, eighthSimplexVector.size(), eighthSimplex.second); BOOST_CHECK(st.num_vertices() == (size_t) 4); - // ++ NINETH + // ++ NINTH std::clog << " - INSERT (3,0)" << std::endl; typeVectorVertex ninethSimplexVector{3, 0}; BOOST_CHECK(ninethSimplexVector.size() == 2); @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var test_simplex_tree_contains(st, seventhSimplex, 8); // (2,1,0) -> 8 std::clog << "simplex_tree_insertion - eighth - 3" << std::endl; test_simplex_tree_contains(st, eighthSimplex, 3); // (3) -> 3 - std::clog << "simplex_tree_insertion - nineth - 7" << std::endl; + std::clog << "simplex_tree_insertion - ninth - 7" << std::endl; test_simplex_tree_contains(st, ninethSimplex, 7); // (3,0) -> 7 // Display the Simplex_tree - Can not be done in the middle of 2 inserts diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h index 12fe6469..d83c0ab3 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h @@ -134,7 +134,7 @@ class Skeleton_blocker_simplex { } /** - * Substracts a from the simplex. + * Subtracts a from the simplex. */ void difference(const Skeleton_blocker_simplex & a) { std::vector v; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h index 4c48ff31..5abd64d7 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h @@ -76,8 +76,8 @@ class Skeleton_blocker_sub_complex : public ComplexType { public: /** * Add a vertex 'global' of K to L. When added to L, this vertex will receive - * another number, addresses(global), its local adress. - * return the adress where the vertex lay on L. + * another number, addresses(global), its local address. + * return the address where the vertex lay on L. * The vertex corresponding to 'global' must not be already present * in the complex. */ @@ -174,7 +174,7 @@ class Skeleton_blocker_sub_complex : public ComplexType { // /** // * Allocates a simplex in L corresponding to the simplex s in K - // * with its local adresses and returns an AddressSimplex. + // * with its local addresses and returns an AddressSimplex. // */ // boost::optional get_address(const Root_simplex_handle & s) const; @@ -226,7 +226,7 @@ bool proper_face_in_union( } // Remark: this function should be friend in order to leave get_adresses private -// however doing so seemes currently not possible due to a visual studio bug c2668 +// however doing so seems currently not possible due to a visual studio bug c2668 // "the compiler does not support partial ordering of template functions as specified in the C++ Standard" // http://www.serkey.com/error-c2668-ambiguous-call-to-overloaded-function-bb45ft.html diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h index a43fa034..18ae6a92 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h @@ -107,7 +107,7 @@ struct Trie { } /** - * Goes to the root in the trie to consitute simplex + * Goes to the root in the trie to constitute simplex */ void add_vertices_up_to_the_root(Simplex& res) const { res.add_vertex(v); diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h index 37c0b4d3..2c49a1b8 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h @@ -21,7 +21,7 @@ namespace skeleton_blocker { /** * \brief Iterator over the triangles that are * adjacent to a vertex of the simplicial complex. - * \remark Will be removed soon -> dont look + * \remark Will be removed soon -> don't look */ template class Triangle_around_vertex_iterator : public boost::iterator_facade @@ -95,7 +95,7 @@ class Triangle_around_vertex_iterator : public boost::iterator_facade /** * \brief Iterator over the triangles of the * simplicial complex. - * \remark Will be removed soon -> dont look + * \remark Will be removed soon -> don't look * */ template diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 031bcb9c..8ceaa480 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -438,7 +438,7 @@ class Skeleton_blocker_complex { } /** - * return the id of a vertex of adress local present in the graph + * return the id of a vertex of address local present in the graph */ Root_vertex_handle get_id(Vertex_handle local) const { assert(0 <= local.vertex && local.vertex < boost::num_vertices(skeleton)); @@ -740,7 +740,7 @@ class Skeleton_blocker_complex { * complex to the smallest flag complex that contains it. */ void remove_blockers() { - // Desallocate the blockers + // Deallocate the blockers while (!blocker_map_.empty()) { delete_blocker(blocker_map_.begin()->second); } @@ -764,8 +764,8 @@ class Skeleton_blocker_complex { public: /** - * Removes the simplex s from the set of blockers - * and desallocate s. + * Removes the simplex sigma from the set of blockers + * and deallocate sigma. */ void delete_blocker(Blocker_handle sigma) { if (visitor) @@ -960,7 +960,7 @@ class Skeleton_blocker_complex { } /* - * @brief returnrs true iff the complex is empty. + * @brief returns true iff the complex is empty. */ bool empty() const { return num_vertices() == 0; @@ -1043,7 +1043,7 @@ class Skeleton_blocker_complex { if (num_vertices() == 1) return true; for (auto vi : vertex_range()) { - // xxx todo faire une methode bool is_in_blocker(Vertex_handle) + // xxx todo create a method: bool is_in_blocker(Vertex_handle) if (blocker_map_.find(vi) == blocker_map_.end()) { // no blocker passes through the vertex, we just need to // check if the current vertex is linked to all others vertices of the complex diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h index f3491f91..cc424810 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h @@ -1152,7 +1152,7 @@ class Tangential_complex { #ifdef GUDHI_TC_VERY_VERBOSE std::cerr << "Inserted " << num_inserted_points << " points / " << num_attempts_to_insert_points - << " attemps to compute the star\n"; + << " attempts to compute the star\n"; #endif update_star(i); diff --git a/src/cmake/modules/FindTBB.cmake b/src/cmake/modules/FindTBB.cmake index 13f4d929..e6c42dc7 100644 --- a/src/cmake/modules/FindTBB.cmake +++ b/src/cmake/modules/FindTBB.cmake @@ -34,7 +34,7 @@ # # GvdB: Mac OS X distribution places libraries directly in lib directory. # -# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER. +# For backwards compatibility, you may explicitly set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER. # TBB_ARCHITECTURE [ ia32 | em64t | itanium ] # which architecture to use # TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9 @@ -54,8 +54,8 @@ # TBB_MALLOC_DEBUG_LIBRARY, the TBB debug malloc library # TBB_FOUND, If false, don't try to use TBB. # TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h -# TBB_MALLOCPROXY_DEBUG_LIBRARY, the TBB debug malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal) -# TBB_MALLOCPROXY_RELEASE_LIBRARY, the TBB release malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal) +# TBB_MALLOCPROXY_DEBUG_LIBRARY, the TBB debug malloc_proxy library (not included in TBB_LIBRARIES since it's optional) +# TBB_MALLOCPROXY_RELEASE_LIBRARY, the TBB release malloc_proxy library (not included in TBB_LIBRARIES since it's optional) include(CheckCXXSourceCompiles) diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index 13248f7e..ec1f756b 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -2,7 +2,7 @@ set(GUDHI_MODULES_FULL_LIST "") function(add_gudhi_module file_path) - option("WITH_MODULE_GUDHI_${file_path}" "Activate/desactivate ${file_path} compilation and installation" ON) + option("WITH_MODULE_GUDHI_${file_path}" "Activate/deactivate ${file_path} compilation and installation" ON) if (WITH_MODULE_GUDHI_${file_path}) set(GUDHI_MODULES ${GUDHI_MODULES} ${file_path} CACHE INTERNAL "GUDHI_MODULES") else() @@ -10,7 +10,7 @@ function(add_gudhi_module file_path) endif() # Required by user_version set(GUDHI_MODULES_FULL_LIST ${GUDHI_MODULES_FULL_LIST} ${file_path} PARENT_SCOPE) - # Include module headers is independant - You may ask for no Alpha complex module but Python interface i.e. + # Include module headers is independent - You may ask for no Alpha complex module but Python interface i.e. if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/${file_path}/include/) include_directories(src/${file_path}/include/) endif() diff --git a/src/cmake/modules/GUDHI_options.cmake b/src/cmake/modules/GUDHI_options.cmake index 3cd0a489..bffb3ffc 100644 --- a/src/cmake/modules/GUDHI_options.cmake +++ b/src/cmake/modules/GUDHI_options.cmake @@ -1,5 +1,5 @@ -option(WITH_GUDHI_BENCHMARK "Activate/desactivate benchmark compilation" OFF) -option(WITH_GUDHI_EXAMPLE "Activate/desactivate examples compilation and installation" OFF) -option(WITH_GUDHI_PYTHON "Activate/desactivate python module compilation and installation" ON) -option(WITH_GUDHI_TEST "Activate/desactivate examples compilation and installation" ON) -option(WITH_GUDHI_UTILITIES "Activate/desactivate utilities compilation and installation" ON) +option(WITH_GUDHI_BENCHMARK "Activate/deactivate benchmark compilation" OFF) +option(WITH_GUDHI_EXAMPLE "Activate/deactivate examples compilation and installation" OFF) +option(WITH_GUDHI_PYTHON "Activate/deactivate python module compilation and installation" ON) +option(WITH_GUDHI_TEST "Activate/deactivate examples compilation and installation" ON) +option(WITH_GUDHI_UTILITIES "Activate/deactivate utilities compilation and installation" ON) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 6a94d1f5..6ba822ad 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -174,7 +174,7 @@ if (WITH_GUDHI_PYTHON) message(FATAL_ERROR "ERROR: GUDHI_PYTHON_PATH is not valid.") endif(NOT GUDHI_PYTHON_PATH) - option(WITH_GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS "Build with setting runtime_library_dirs. Usefull when setting rpath is not allowed" ON) + option(WITH_GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS "Build with setting runtime_library_dirs. Useful when setting rpath is not allowed" ON) if(PYTHONINTERP_FOUND AND CYTHON_FOUND) if(SPHINX_FOUND) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 29d5423d..a7d82541 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -231,7 +231,7 @@ std::vector> read_lower_triangular_matrix_from_csv std::string line; - // the first line is emtpy, so we ignore it: + // the first line is empty, so we ignore it: std::getline(in, line); std::vector values_in_this_line; result.push_back(values_in_this_line); diff --git a/src/common/include/gudhi/writing_persistence_to_file.h b/src/common/include/gudhi/writing_persistence_to_file.h index 2e36b831..3a0df1a8 100644 --- a/src/common/include/gudhi/writing_persistence_to_file.h +++ b/src/common/include/gudhi/writing_persistence_to_file.h @@ -48,7 +48,7 @@ class Persistence_interval_common { : birth_(birth), death_(death), dimension_(dim), arith_element_(field) {} /** - * Operator to compare two persistence pairs. During the comparision all the + * Operator to compare two persistence pairs. During the comparison all the * fields: birth, death, dimensiona and arith_element_ are taken into account * and they all have to be equal for two pairs to be equal. **/ @@ -65,7 +65,7 @@ class Persistence_interval_common { /** * Operator to compare objects of a type Persistence_interval_common. * One intervals is smaller than the other if it has lower persistence. - * Note that this operator do not take Arith_element into account when doing comparisions. + * Note that this operator do not take Arith_element into account when doing comparisons. **/ bool operator<(const Persistence_interval_common& i2) const { return fabs(this->death_ - this->birth_) < fabs(i2.death_ - i2.birth_); diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 54221151..af0b6115 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -329,9 +329,9 @@ if(PYTHONINTERP_FOUND) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 5.1.0) set (GUDHI_SPHINX_MESSAGE "Generating API documentation with Sphinx in ${CMAKE_CURRENT_BINARY_DIR}/sphinx/") # User warning - Sphinx is a static pages generator, and configured to work fine with user_version - # Images and biblio warnings because not found on developper version + # Images and biblio warnings because not found on developer version if (GUDHI_PYTHON_PATH STREQUAL "src/python") - set (GUDHI_SPHINX_MESSAGE "${GUDHI_SPHINX_MESSAGE} \n WARNING : Sphinx is configured for user version, you run it on developper version. Images and biblio will miss") + set (GUDHI_SPHINX_MESSAGE "${GUDHI_SPHINX_MESSAGE} \n WARNING : Sphinx is configured for user version, you run it on developer version. Images and biblio will miss") endif() # sphinx target requires gudhi.so, because conf.py reads gudhi version from it add_custom_target(sphinx @@ -484,7 +484,7 @@ if(PYTHONINTERP_FOUND) add_gudhi_py_test(test_euclidean_witness_complex) # Datasets generators - add_gudhi_py_test(test_datasets_generators) # TODO separate full python datasets generators in another test file independant from CGAL ? + add_gudhi_py_test(test_datasets_generators) # TODO separate full python datasets generators in another test file independent from CGAL ? endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py b/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py index ea2eb7e1..0b35dbc5 100755 --- a/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py +++ b/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py @@ -40,7 +40,7 @@ parser.add_argument( args = parser.parse_args() if not (-1.0 < args.min_edge_correlation < 1.0): - print("Wrong value of the treshold corelation (should be between -1 and 1).") + print("Wrong value of the threshold corelation (should be between -1 and 1).") sys.exit(1) print("#####################################################################") diff --git a/src/python/gudhi/hera/wasserstein.cc b/src/python/gudhi/hera/wasserstein.cc index 1a21f02f..fa0cf8aa 100644 --- a/src/python/gudhi/hera/wasserstein.cc +++ b/src/python/gudhi/hera/wasserstein.cc @@ -29,7 +29,7 @@ double wasserstein_distance( if(std::isinf(internal_p)) internal_p = hera::get_infinity(); params.internal_p = internal_p; params.delta = delta; - // The extra parameters are purposedly not exposed for now. + // The extra parameters are purposely not exposed for now. return hera::wasserstein_dist(diag1, diag2, params); } diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py index 7ed11360..21275cdd 100644 --- a/src/python/gudhi/persistence_graphical_tools.py +++ b/src/python/gudhi/persistence_graphical_tools.py @@ -332,7 +332,7 @@ def plot_persistence_diagram( axes.plot([axis_start, axis_end], [infinity, infinity], linewidth=1.0, color="k", alpha=alpha) # Infinity label yt = axes.get_yticks() - yt = yt[np.where(yt < axis_end)] # to avoid ploting ticklabel higher than infinity + yt = yt[np.where(yt < axis_end)] # to avoid plotting ticklabel higher than infinity yt = np.append(yt, infinity) ytl = ["%.3f" % e for e in yt] # to avoid float precision error ytl[-1] = r"$+\infty$" diff --git a/src/python/gudhi/wasserstein/barycenter.py b/src/python/gudhi/wasserstein/barycenter.py index d67bcde7..bb6e641e 100644 --- a/src/python/gudhi/wasserstein/barycenter.py +++ b/src/python/gudhi/wasserstein/barycenter.py @@ -37,7 +37,7 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): :param init: The initial value for barycenter estimate. If ``None``, init is made on a random diagram from the dataset. Otherwise, it can be an ``int`` (then initialization is made on ``pdiagset[init]``) - or a `(n x 2)` ``numpy.array`` enconding a persistence diagram with `n` points. + or a `(n x 2)` ``numpy.array`` encoding a persistence diagram with `n` points. :type init: ``int``, or (n x 2) ``np.array`` :param verbose: if ``True``, returns additional information about the barycenter. :type verbose: boolean @@ -45,7 +45,7 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): (local minimum of the energy function). If ``pdiagset`` is empty, returns ``None``. If verbose, returns a couple ``(Y, log)`` where ``Y`` is the barycenter estimate, - and ``log`` is a ``dict`` that contains additional informations: + and ``log`` is a ``dict`` that contains additional information: - `"groupings"`, a list of list of pairs ``(i,j)``. Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates that `pdiagset[k][i]`` is matched to ``Y[j]`` if ``i = -1`` or ``j = -1``, it means they represent the diagonal. @@ -73,7 +73,7 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): nb_iter = 0 - converged = False # stoping criterion + converged = False # stopping criterion while not converged: nb_iter += 1 K = len(Y) # current nb of points in Y (some might be on diagonal) diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 688f4fd6..ba8c455f 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -528,7 +528,7 @@ def test_expansion_with_blocker(): def blocker(simplex): try: - # Block all simplices that countains vertex 6 + # Block all simplices that contains vertex 6 simplex.index(6) print(simplex, ' is blocked') return True diff --git a/src/python/test/test_subsampling.py b/src/python/test/test_subsampling.py index 4019852e..3431f372 100755 --- a/src/python/test/test_subsampling.py +++ b/src/python/test/test_subsampling.py @@ -91,7 +91,7 @@ def test_simple_choose_n_farthest_points_randomed(): assert gudhi.choose_n_farthest_points(points=[], nb_points=1) == [] assert gudhi.choose_n_farthest_points(points=point_set, nb_points=0) == [] - # Go furter than point set on purpose + # Go further than point set on purpose for iter in range(1, 10): sub_set = gudhi.choose_n_farthest_points(points=point_set, nb_points=iter) for sub in sub_set: @@ -117,7 +117,7 @@ def test_simple_pick_n_random_points(): assert gudhi.pick_n_random_points(points=[], nb_points=1) == [] assert gudhi.pick_n_random_points(points=point_set, nb_points=0) == [] - # Go furter than point set on purpose + # Go further than point set on purpose for iter in range(1, 10): sub_set = gudhi.pick_n_random_points(points=point_set, nb_points=iter) for sub in sub_set: -- cgit v1.2.3 From 7fc251e83602d0bce697dbaa744099e57d6df397 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 22 May 2022 18:41:40 +0200 Subject: Update src/Persistent_cohomology/example/rips_multifield_persistence.cpp Co-authored-by: Marc Glisse --- src/Persistent_cohomology/example/rips_multifield_persistence.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index d154bcde..ca26a5b9 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -104,7 +104,7 @@ void program_options(int argc, char * argv[] ("min-field-charac,p", po::value(&min_p)->default_value(2), "Minimal characteristic p of the coefficient field Z/pZ.") ("max-field-charac,q", po::value(&max_p)->default_value(1223), - "Minimal characteristic q of the coefficient field Z/pZ.") + "Maximal characteristic q of the coefficient field Z/pZ.") ("min-persistence,m", po::value(&min_persistence), "Minimal lifetime of homology feature to be recorded. Default is 0"); -- cgit v1.2.3 From 6c8024c5d17fe3dc03584f97bc883b7f56f71b7e Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 22 May 2022 18:41:52 +0200 Subject: Update src/python/test/test_simplex_tree.py Co-authored-by: Marc Glisse --- src/python/test/test_simplex_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index ba8c455f..678bc905 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -528,7 +528,7 @@ def test_expansion_with_blocker(): def blocker(simplex): try: - # Block all simplices that contains vertex 6 + # Block all simplices that contain vertex 6 simplex.index(6) print(simplex, ' is blocked') return True -- cgit v1.2.3 From fa413a02065e03296d9cf375c2b74d5fd381f3bb Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 22 May 2022 18:42:34 +0200 Subject: Update src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h Co-authored-by: Marc Glisse --- src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h index 51f6a273..4a6af3a4 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -237,7 +237,7 @@ class Bitmap_cubical_complex : public T { * Filtration_simplex_iterator class provides an iterator though the whole structure in the order of filtration. * Secondary criteria for filtration are: * (1) Dimension of a cube (lower dimensional comes first). - * (2) Position in the data structure (the ones that are earliest in the data structure comes first). + * (2) Position in the data structure (the ones that are earliest in the data structure come first). **/ class Filtration_simplex_range; -- cgit v1.2.3 From 298ae783896d7a9fee43b58a3a01041c9106962c Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 23 May 2022 13:25:06 +0200 Subject: Documentation: handling references to examples in a more transparent way Adding the other examples also with `gudhi_example_link`. --- src/Cech_complex/doc/Intro_cech_complex.h | 5 ++--- .../doc/Intro_persistent_cohomology.h | 21 +++++++-------------- src/Rips_complex/doc/Intro_rips_complex.h | 5 ++--- src/Simplex_tree/doc/Intro_simplex_tree.h | 12 ++++-------- src/common/doc/installation.h | 3 +-- 5 files changed, 16 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Cech_complex/doc/Intro_cech_complex.h b/src/Cech_complex/doc/Intro_cech_complex.h index 698f9749..095fd320 100644 --- a/src/Cech_complex/doc/Intro_cech_complex.h +++ b/src/Cech_complex/doc/Intro_cech_complex.h @@ -70,9 +70,8 @@ namespace cech_complex { * This radius computation is the reason why the Cech_complex is taking much more time to be computed than the * \ref rips_complex but it offers more topological guarantees. * - * If the Cech_complex interfaces are not detailed enough for your need, please refer to - * - * cech_complex_step_by_step.cpp example, where the graph construction over the Simplex_tree is more detailed. + * If the Cech_complex interfaces are not detailed enough for your need, please refer to the example + * \gudhi_example_link{Cech_complex,cech_complex_step_by_step.cpp}, where the graph construction over the Simplex_tree is more detailed. * * \subsection cechpointscloudexample Example from a point cloud * diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index a3613d0d..94579564 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -131,8 +131,7 @@ namespace persistent_cohomology { We provide several example files: run these examples with -h for details on their use, and read the README file. -\li -Rips_complex/rips_persistence.cpp computes the Rips complex of a point cloud and outputs its persistence +\li \gudhi_example_link{Rips_complex,rips_persistence.cpp} computes the Rips complex of a point cloud and outputs its persistence diagram. \code $> ./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 \endcode \code The complex contains 177838 simplices @@ -144,12 +143,10 @@ diagram. More details on the Rips complex utilities dedicated page. -\li -Persistent_cohomology/rips_multifield_persistence.cpp computes the Rips complex of a point cloud and outputs its +\li \gudhi_example_link{Persistent_cohomology,rips_multifield_persistence.cpp} computes the Rips complex of a point cloud and outputs its persistence diagram with a family of field coefficients. -\li -Rips_complex/rips_distance_matrix_persistence.cpp computes the Rips complex of a distance matrix and +\li \gudhi_example_link{Rips_complex,rips_distance_matrix_persistence.cpp} computes the Rips complex of a distance matrix and outputs its persistence diagram. The file should contain square or lower triangular distance matrix with semicolons as separators. @@ -158,8 +155,7 @@ Please refer to data/distance_matrix/lower_triangular_distance_matrix.csv for an More details on the Rips complex utilities dedicated page. -\li -Rips_complex/rips_correlation_matrix_persistence.cpp +\li \gudhi_example_link{Rips_complex,rips_correlation_matrix_persistence.cpp} computes the Rips complex of a correlation matrix and outputs its persistence diagram. Note that no check is performed if the matrix given as the input is a correlation matrix. @@ -169,8 +165,7 @@ Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv More details on the Rips complex utilities dedicated page. -\li -Alpha_complex/alpha_complex_3d_persistence.cpp computes the persistent homology with +\li \gudhi_example_link{Alpha_complex,alpha_complex_3d_persistence.cpp} computes the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. \code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 \endcode \code Simplex_tree dim: 3 @@ -235,8 +230,7 @@ Note that the lengths of the sides of the periodic cuboid have to be the same. -Alpha_complex/alpha_complex_persistence.cpp computes the persistent homology with +\li \gudhi_example_link{Alpha_complex,alpha_complex_persistence.cpp} computes the persistent homology with \f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. \code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode \code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices. @@ -248,8 +242,7 @@ Simplex_tree dim: 3 More details on the Alpha complex utilities dedicated page. -\li -Persistent_cohomology/plain_homology.cpp computes the plain homology of a simple simplicial complex without +\li \gudhi_example_link{Persistent_cohomology,plain_homology.cpp} computes the plain homology of a simple simplicial complex without filtration values. */ diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 3888ec8f..cd77b327 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -63,9 +63,8 @@ namespace rips_complex { * value set with \f$max(filtration(4,5), filtration(4,6), filtration(5,6))\f$. * And so on for simplex (0,1,2,3). * - * If the Rips_complex interfaces are not detailed enough for your need, please refer to - * - * rips_persistence_step_by_step.cpp example, where the constructions of the graph and + * If the Rips_complex interfaces are not detailed enough for your need, please refer to the example + * \gudhi_example_link{Persistent_cohomology,rips_persistence_step_by_step.cpp} , where the constructions of the graph and * the Simplex_tree are more detailed. * * \section sparserips Sparse Rips complex diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h index ef8dec91..2d3ecdec 100644 --- a/src/Simplex_tree/doc/Intro_simplex_tree.h +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -39,11 +39,9 @@ namespace Gudhi { * \subsubsection filteredcomplexessimplextreeexamples Examples * * Here is a list of simplex tree examples : - * \li - * Simplex_tree/simple_simplex_tree.cpp - Simple simplex tree construction and basic function use. + * \li \gudhi_example_link{Simplex_tree,simple_simplex_tree.cpp} - Simple simplex tree construction and basic function use. * - * \li - * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - Simplex tree construction from cliques of graph read in + * \li \gudhi_example_link{Simplex_tree,simplex_tree_from_cliques_of_graph.cpp} - Simplex tree construction from cliques of graph read in * a file. * * Simplex tree construction with \f$\mathbb{Z}/3\mathbb{Z}\f$ coefficients on weighted graph Klein bottle file: @@ -54,12 +52,10 @@ Expand the simplex tree in 3.8e-05 s. Information of the Simplex Tree: Number of vertices = 10 Number of simplices = 98 \endcode * - * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - Simplex tree is computed and displayed + * \li \gudhi_example_link{Simplex_tree,example_alpha_shapes_3_simplex_tree_from_off_file.cpp} - Simplex tree is computed and displayed * from a 3D alpha complex (Requires CGAL, GMP and GMPXX to be installed). * - * \li - * Simplex_tree/graph_expansion_with_blocker.cpp - Simple simplex tree construction from a one-skeleton graph with + * \li \gudhi_example_link{Simplex_tree,graph_expansion_with_blocker.cpp} - Simple simplex tree construction from a one-skeleton graph with * a simple blocker expansion method. * * \subsection filteredcomplexeshassecomplex Hasse complex diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index fb5ee665..e786f53a 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -58,8 +58,7 @@ make \endverbatim * * The following example requires the GNU Multiple Precision Arithmetic * Library (GMP) and will not be built if GMP is not installed: - * \li - * Persistent_cohomology/rips_multifield_persistence.cpp + * \li \gudhi_example_link{Persistent_cohomology,rips_multifield_persistence.cpp} * * Having GMP version 4.2 or higher installed is recommended. * -- cgit v1.2.3 From fc28a5b76e47518e616a186f5db5be2a251c4b91 Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 23 May 2022 18:35:22 +0200 Subject: Documentation: Render formuals by means of MathJax 3 - create entries in Doxyfile.in for the use of MathJax - adjust formula so it is properly rendered in MathJax 3 (formula will also work with MathJax 2) (available in doxygen since doxygen 1.9.2) --- src/Alpha_complex/doc/Intro_alpha_complex.h | 2 ++ src/Doxyfile.in | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index 7f14f423..41e5e16d 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -107,6 +107,7 @@ Table of Contents * \subsection filtrationcomputation Filtration value computation algorithm *
* \f$ + * \begin{array}{l} * \textbf{for } \text{i : dimension } \rightarrow 0 \textbf{ do}\\ * \quad \textbf{for all } \sigma \text{ of dimension i}\\ * \quad\quad \textbf{if } \text{filtration(} \sigma ) \text{ is NaN} \textbf{ then}\\ @@ -127,6 +128,7 @@ Table of Contents * \textbf{end for}\\ * \text{make_filtration_non_decreasing()}\\ * \text{prune_above_filtration()}\\ + * \end{array} * \f$ * * \subsubsection dimension2 Dimension 2 diff --git a/src/Doxyfile.in b/src/Doxyfile.in index f76ba2bd..834fcfc1 100644 --- a/src/Doxyfile.in +++ b/src/Doxyfile.in @@ -1473,6 +1473,17 @@ FORMULA_TRANSPARENT = YES USE_MATHJAX = YES +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_3 + # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. @@ -1494,15 +1505,14 @@ MATHJAX_FORMAT = HTML-CSS # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2 +MATHJAX_RELPATH = # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = TeX/AMSmath \ - TeX/AMSsymbols +MATHJAX_EXTENSIONS = ams # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -- cgit v1.2.3 From 8e01047cd8da2275a76c91cb248d16369c6ad7c7 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 24 May 2022 10:02:01 +0200 Subject: Documentation: Render formulas by means of MathJax 3 Based on review, made a switch between MathJax 2 and MathJax 3 based on the doxygen version --- src/Doxyfile.in | 4 ++-- src/cmake/modules/GUDHI_doxygen_target.cmake | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Doxyfile.in b/src/Doxyfile.in index 834fcfc1..51a97952 100644 --- a/src/Doxyfile.in +++ b/src/Doxyfile.in @@ -1482,7 +1482,7 @@ USE_MATHJAX = YES # The default value is: MathJax_2. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_VERSION = MathJax_3 +@GUDHI_DOXYGEN_MATHJAX_VERSION@ # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: @@ -1512,7 +1512,7 @@ MATHJAX_RELPATH = # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = ams +MATHJAX_EXTENSIONS = @GUDHI_DOXYGEN_MATHJAX_EXTENSIONS@ # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site diff --git a/src/cmake/modules/GUDHI_doxygen_target.cmake b/src/cmake/modules/GUDHI_doxygen_target.cmake index 0f80b187..77fa02b5 100644 --- a/src/cmake/modules/GUDHI_doxygen_target.cmake +++ b/src/cmake/modules/GUDHI_doxygen_target.cmake @@ -44,6 +44,13 @@ if(DOXYGEN_FOUND) set(GUDHI_DOXYGEN_UTILS_PATH "utilities/*") endif() + if (DOXYGEN_VERSION VERSION_LESS 1.9.7) + set(GUDHI_DOXYGEN_MATHJAX_VERSION "MATHJAX_VERSION = MathJax_2") + set(GUDHI_DOXYGEN_MATHJAX_EXTENSIONS "TeX/AMSmath TeX/AMSsymbols") + else() + set(GUDHI_DOXYGEN_MATHJAX_VERSION "MATHJAX_VERSION = MathJax_3") + set(GUDHI_DOXYGEN_MATHJAX_EXTENSIONS "ams") + endif() configure_file(${GUDHI_DOXYGEN_SOURCE_PREFIX}/Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY) add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile -- cgit v1.2.3 From b48271108c0bc396a62ab55d9d4e25e988b1378f Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 24 May 2022 10:02:48 +0200 Subject: Documentation: Render formuals by means of MathJax 3 Oops left test version in it. --- src/cmake/modules/GUDHI_doxygen_target.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/cmake/modules/GUDHI_doxygen_target.cmake b/src/cmake/modules/GUDHI_doxygen_target.cmake index 77fa02b5..1e2062a5 100644 --- a/src/cmake/modules/GUDHI_doxygen_target.cmake +++ b/src/cmake/modules/GUDHI_doxygen_target.cmake @@ -44,7 +44,7 @@ if(DOXYGEN_FOUND) set(GUDHI_DOXYGEN_UTILS_PATH "utilities/*") endif() - if (DOXYGEN_VERSION VERSION_LESS 1.9.7) + if (DOXYGEN_VERSION VERSION_LESS 1.9.2) set(GUDHI_DOXYGEN_MATHJAX_VERSION "MATHJAX_VERSION = MathJax_2") set(GUDHI_DOXYGEN_MATHJAX_EXTENSIONS "TeX/AMSmath TeX/AMSsymbols") else() -- cgit v1.2.3 From 91b21f6cfdf8e225070514c34bd6fcae296e3d52 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 24 May 2022 10:34:43 +0200 Subject: Documentation: Obsolete CLASS_DIARAMS Since doxygen version 1.9.3 the settings `CLASS_DIAGRAMS` and `CLASS_GRAPH` have been integrated into `CLASS_GRAPH` and `CLASS_DIAGRAMS` is now obsolete. The value of `CLASS+GRAPH` doesn't have to be adjusted, in this case, as it was already set to `NO`. --- src/Doxyfile.in | 9 +-------- src/cmake/modules/GUDHI_doxygen_target.cmake | 6 ++++++ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Doxyfile.in b/src/Doxyfile.in index f76ba2bd..13668993 100644 --- a/src/Doxyfile.in +++ b/src/Doxyfile.in @@ -2082,14 +2082,7 @@ EXTERNAL_PAGES = YES # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = NO +@GUDHI_DOXYGEN_CLASS_DIAGRAMS@ # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The diff --git a/src/cmake/modules/GUDHI_doxygen_target.cmake b/src/cmake/modules/GUDHI_doxygen_target.cmake index 0f80b187..e8064466 100644 --- a/src/cmake/modules/GUDHI_doxygen_target.cmake +++ b/src/cmake/modules/GUDHI_doxygen_target.cmake @@ -44,6 +44,12 @@ if(DOXYGEN_FOUND) set(GUDHI_DOXYGEN_UTILS_PATH "utilities/*") endif() + if (DOXYGEN_VERSION VERSION_LESS 1.9.3) + set(GUDHI_DOXYGEN_CLASS_DIAGRAMS "CLASS_DIAGRAMS = NO") + else() + set(GUDHI_DOXYGEN_CLASS_DIAGRAMS "") + endif() + configure_file(${GUDHI_DOXYGEN_SOURCE_PREFIX}/Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY) add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile -- cgit v1.2.3 From dcd4204d62a4c9a4f3d9ebc61341fba25ae19687 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 24 May 2022 11:44:49 +0200 Subject: Use autofunction instead of automodule in doc and add 2d spiral image --- src/python/doc/datasets.rst | 16 ++++++++++++---- src/python/doc/img/spiral_2d.png | Bin 0 -> 279276 bytes 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/python/doc/img/spiral_2d.png (limited to 'src') diff --git a/src/python/doc/datasets.rst b/src/python/doc/datasets.rst index 62b7dca0..d2975533 100644 --- a/src/python/doc/datasets.rst +++ b/src/python/doc/datasets.rst @@ -112,13 +112,21 @@ Fetching datasets We provide some ready-to-use datasets that are not available by default when getting GUDHI, and need to be fetched explicitly. +.. autofunction:: gudhi.datasets.remote.fetch_bunny + .. figure:: ./img/bunny.png :figclass: align-center 3D Stanford bunny with 35947 vertices. -.. automodule:: gudhi.datasets.remote - :members: - :special-members: - :show-inheritance: +.. autofunction:: gudhi.datasets.remote.fetch_spiral_2d + +.. figure:: ./img/spiral_2d.png + :figclass: align-center + + 2D spiral with 114562 vertices. + +.. autofunction:: gudhi.datasets.remote.get_data_home + +.. autofunction:: gudhi.datasets.remote.clear_data_home diff --git a/src/python/doc/img/spiral_2d.png b/src/python/doc/img/spiral_2d.png new file mode 100644 index 00000000..abd247cd Binary files /dev/null and b/src/python/doc/img/spiral_2d.png differ -- cgit v1.2.3 From 4d2f5a1c165204765a04594a9f1f6ba9bcb939ba Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 24 May 2022 11:46:16 +0200 Subject: Specify in doc the use of cache when fetching datasets with wrapping functions --- src/python/gudhi/datasets/remote.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index eac8caf3..d2ae2a75 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -143,6 +143,8 @@ def _get_archive_path(file_path, label): def fetch_spiral_2d(file_path = None): """ Fetch spiral_2d dataset remotely. + Note that if the dataset already exists in the target location, it is not downloaded again, + and the corresponding array is returned from cache. Parameters ---------- @@ -169,6 +171,8 @@ def fetch_bunny(file_path = None, accept_license = False): """ Fetch Stanford bunny dataset remotely and its LICENSE file. This dataset contains 35947 vertices. + Note that if the dataset already exists in the target location, it is not downloaded again, + and the corresponding array is returned from cache. Parameters ---------- -- cgit v1.2.3 From dbaeddbfef69770757efcf153998bf997c085465 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 24 May 2022 12:16:02 +0200 Subject: No need to copy Doxyfile.in In my opinion there is no need to copy the `Doxyfile.in` file to the build directory (neither in the User nor the development version). The usage is: ``` configure_file(${GUDHI_DOXYGEN_SOURCE_PREFIX}/Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY) ``` in the file `src/cmake/modules/GUDHI_doxygen_target.cmake` and we see that this uses the file from its original source directory. --- src/cmake/modules/GUDHI_user_version_target.cmake | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/cmake/modules/GUDHI_user_version_target.cmake b/src/cmake/modules/GUDHI_user_version_target.cmake index 9e76c3d9..4487ad86 100644 --- a/src/cmake/modules/GUDHI_user_version_target.cmake +++ b/src/cmake/modules/GUDHI_user_version_target.cmake @@ -14,8 +14,6 @@ add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${GUDHI_USER_VERSION_DIR} COMMENT "user_version creation in ${GUDHI_USER_VERSION_DIR}") -file(COPY "${CMAKE_SOURCE_DIR}/src/Doxyfile.in" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") - # Generate bib files for Doxygen - cf. root CMakeLists.txt for explanation string(TIMESTAMP GUDHI_VERSION_YEAR "%Y") configure_file(${CMAKE_SOURCE_DIR}/biblio/how_to_cite_gudhi.bib.in "${CMAKE_CURRENT_BINARY_DIR}/biblio/how_to_cite_gudhi.bib" @ONLY) -- cgit v1.2.3 From ce34ee3e5c28c48d605f23332cfa3c10e471a047 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 24 May 2022 15:57:52 +0200 Subject: Make get_data_home function private --- src/python/doc/datasets.rst | 2 -- src/python/gudhi/datasets/remote.py | 6 +++--- src/python/test/test_remote_datasets.py | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/python/doc/datasets.rst b/src/python/doc/datasets.rst index d2975533..8b0912c4 100644 --- a/src/python/doc/datasets.rst +++ b/src/python/doc/datasets.rst @@ -127,6 +127,4 @@ We provide some ready-to-use datasets that are not available by default when get 2D spiral with 114562 vertices. -.. autofunction:: gudhi.datasets.remote.get_data_home - .. autofunction:: gudhi.datasets.remote.clear_data_home diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index d2ae2a75..7e6f647f 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -16,7 +16,7 @@ import shutil import numpy as np -def get_data_home(data_home = None): +def _get_data_home(data_home = None): """ Return the path of the remote datasets directory. This folder is used to store remotely fetched datasets. @@ -55,7 +55,7 @@ def clear_data_home(data_home = None): If `None` and the 'GUDHI_DATA' environment variable does not exist, the default directory to be removed is set to "~/gudhi_data". """ - data_home = get_data_home(data_home) + data_home = _get_data_home(data_home) shutil.rmtree(data_home) def _checksum_sha256(file_path): @@ -130,7 +130,7 @@ def _get_archive_path(file_path, label): Full path of archive including filename. """ if file_path is None: - archive_path = join(get_data_home(), label) + archive_path = join(_get_data_home(), label) dirname = split(archive_path)[0] makedirs(dirname, exist_ok=True) else: diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py index cde9fa22..e5d2de82 100644 --- a/src/python/test/test_remote_datasets.py +++ b/src/python/test/test_remote_datasets.py @@ -18,8 +18,8 @@ from os.path import isdir, expanduser, exists from os import remove, environ def test_data_home(): - # Test get_data_home and clear_data_home on new empty folder - empty_data_home = remote.get_data_home(data_home="empty_folder_for_test") + # Test _get_data_home and clear_data_home on new empty folder + empty_data_home = remote._get_data_home(data_home="empty_folder_for_test") assert isdir(empty_data_home) remote.clear_data_home(data_home=empty_data_home) -- cgit v1.2.3 From 1f3a5212939720a039cd0e084bffd882928c0b47 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 24 May 2022 17:29:33 +0200 Subject: Update src/cmake/modules/GUDHI_doxygen_target.cmake Co-authored-by: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> --- src/cmake/modules/GUDHI_doxygen_target.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/cmake/modules/GUDHI_doxygen_target.cmake b/src/cmake/modules/GUDHI_doxygen_target.cmake index 1e2062a5..6b9514de 100644 --- a/src/cmake/modules/GUDHI_doxygen_target.cmake +++ b/src/cmake/modules/GUDHI_doxygen_target.cmake @@ -44,6 +44,7 @@ if(DOXYGEN_FOUND) set(GUDHI_DOXYGEN_UTILS_PATH "utilities/*") endif() + message("++ Doxygen version ${DOXYGEN_VERSION}") if (DOXYGEN_VERSION VERSION_LESS 1.9.2) set(GUDHI_DOXYGEN_MATHJAX_VERSION "MATHJAX_VERSION = MathJax_2") set(GUDHI_DOXYGEN_MATHJAX_EXTENSIONS "TeX/AMSmath TeX/AMSsymbols") -- cgit v1.2.3 From 899fb73b33cb6976c39a42ba26a31cf2acde63ee Mon Sep 17 00:00:00 2001 From: Hind-M Date: Wed, 25 May 2022 16:53:04 +0200 Subject: Add info in the doc concerning default data_home and 'GUDHI_DATA' env variable --- src/python/doc/datasets.rst | 3 +++ src/python/gudhi/datasets/remote.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/python/doc/datasets.rst b/src/python/doc/datasets.rst index 8b0912c4..2d11a19d 100644 --- a/src/python/doc/datasets.rst +++ b/src/python/doc/datasets.rst @@ -112,6 +112,9 @@ Fetching datasets We provide some ready-to-use datasets that are not available by default when getting GUDHI, and need to be fetched explicitly. +By **default**, the fetched datasets directory is set to a folder named **'gudhi_data'** in the **user home folder**. +Alternatively, it can be set using the **'GUDHI_DATA'** environment variable. + .. autofunction:: gudhi.datasets.remote.fetch_bunny .. figure:: ./img/bunny.png diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 7e6f647f..48bdcfa6 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -143,6 +143,7 @@ def _get_archive_path(file_path, label): def fetch_spiral_2d(file_path = None): """ Fetch spiral_2d dataset remotely. + Note that if the dataset already exists in the target location, it is not downloaded again, and the corresponding array is returned from cache. @@ -150,8 +151,12 @@ def fetch_spiral_2d(file_path = None): ---------- file_path : string Full path of the downloaded file including filename. + Default is None, meaning that it's set to "data_home/points/spiral_2d/spiral_2d.npy". + The "data_home" directory is set by default to "~/gudhi_data", + unless the 'GUDHI_DATA' environment variable is set. + Returns ------- points: numpy array @@ -170,7 +175,9 @@ def fetch_spiral_2d(file_path = None): def fetch_bunny(file_path = None, accept_license = False): """ Fetch Stanford bunny dataset remotely and its LICENSE file. + This dataset contains 35947 vertices. + Note that if the dataset already exists in the target location, it is not downloaded again, and the corresponding array is returned from cache. @@ -178,10 +185,16 @@ def fetch_bunny(file_path = None, accept_license = False): ---------- file_path : string Full path of the downloaded file including filename. + Default is None, meaning that it's set to "data_home/points/bunny/bunny.npy". In this case, the LICENSE file would be downloaded as "data_home/points/bunny/bunny.LICENSE". + + The "data_home" directory is set by default to "~/gudhi_data", + unless the 'GUDHI_DATA' environment variable is set. + accept_license : boolean Flag to specify if user accepts the file LICENSE and prevents from printing the corresponding license terms. + Default is False. Returns -- cgit v1.2.3 From 2d20991dd44c621b7becd06c086948f666de4da4 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 7 Jun 2022 14:57:41 +0200 Subject: Rephrase description for fetch functions --- src/python/gudhi/datasets/remote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index 48bdcfa6..f6d3fe56 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -142,7 +142,7 @@ def _get_archive_path(file_path, label): def fetch_spiral_2d(file_path = None): """ - Fetch spiral_2d dataset remotely. + Load the spiral_2d dataset. Note that if the dataset already exists in the target location, it is not downloaded again, and the corresponding array is returned from cache. @@ -174,7 +174,7 @@ def fetch_spiral_2d(file_path = None): def fetch_bunny(file_path = None, accept_license = False): """ - Fetch Stanford bunny dataset remotely and its LICENSE file. + Load the Stanford bunny dataset. This dataset contains 35947 vertices. -- cgit v1.2.3