summaryrefslogtreecommitdiff
path: root/src/python/example/alpha_rips_persistence_bottleneck_distance.py
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-02-06 10:51:43 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-02-06 10:51:43 +0100
commit24a76cc53c935dee93f2367f176143c015009e3f (patch)
tree29db475b3db31074108c8d178f421f34caf1824d /src/python/example/alpha_rips_persistence_bottleneck_distance.py
parentc6b5f941e94fdabb3649637d195d3d85c645796b (diff)
Use exceptions uinstead of error message for non existing files
Diffstat (limited to 'src/python/example/alpha_rips_persistence_bottleneck_distance.py')
-rwxr-xr-xsrc/python/example/alpha_rips_persistence_bottleneck_distance.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/python/example/alpha_rips_persistence_bottleneck_distance.py b/src/python/example/alpha_rips_persistence_bottleneck_distance.py
index 7b4aa3e7..f156826d 100755
--- a/src/python/example/alpha_rips_persistence_bottleneck_distance.py
+++ b/src/python/example/alpha_rips_persistence_bottleneck_distance.py
@@ -3,10 +3,13 @@
import gudhi
import argparse
import math
-import sys
+import errno
+import os
-""" 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.
+""" 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): Vincent Rouvreau
Copyright (C) 2016 Inria
@@ -37,7 +40,7 @@ with open(args.file, "r") as f:
first_line = f.readline()
if (first_line == "OFF\n") or (first_line == "nOFF\n"):
point_cloud = gudhi.read_points_from_off_file(off_file=args.file)
- print("#####################################################################")
+ print("##############################################################")
print("RipsComplex creation from points read in a OFF file")
message = "RipsComplex with max_edge_length=" + repr(args.threshold)
@@ -47,14 +50,15 @@ with open(args.file, "r") as f:
points=point_cloud, max_edge_length=args.threshold
)
- rips_stree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension)
+ rips_stree = rips_complex.create_simplex_tree(
+ max_dimension=args.max_dimension)
message = "Number of simplices=" + repr(rips_stree.num_simplices())
print(message)
rips_diag = rips_stree.persistence()
- print("#####################################################################")
+ print("##############################################################")
print("AlphaComplex creation from points read in a OFF file")
message = "AlphaComplex with max_edge_length=" + repr(args.threshold)
@@ -94,13 +98,13 @@ with open(args.file, "r") as f:
print(message)
max_b_distance = max(bottleneck_distance, max_b_distance)
- print(
- "================================================================================"
- )
+ print("==============================================================")
message = "Bottleneck distance is " + repr(max_b_distance)
print(message)
else:
- print(args.file, "is not a valid OFF file", file=sys.stderr)
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT),
+ args.file)
+
f.close()