summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-09 14:39:34 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-09 14:39:34 +0000
commit6f6467ac9cc71598c2946b7e84abcd3adea98528 (patch)
tree36b06883464280efcd3bb3996d4465cf5a30e04a
parent739faa55c4b48613183562aed305d905fd3b42a1 (diff)
Catch if file does not exist
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1267 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b5490aa143b0303da6a92fcc7f7df7656101592a
-rwxr-xr-xsrc/cython/example/cubical_complex_from_perseus_file_example.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/cython/example/cubical_complex_from_perseus_file_example.py b/src/cython/example/cubical_complex_from_perseus_file_example.py
index 9fc083ff..23f7ece6 100755
--- a/src/cython/example/cubical_complex_from_perseus_file_example.py
+++ b/src/cython/example/cubical_complex_from_perseus_file_example.py
@@ -4,7 +4,7 @@ import gudhi
import numpy
import argparse
import operator
-
+import os
"""This file is part of the Gudhi Library. The Gudhi library
(Geometric Understanding in Higher Dimensions) is a generic C++
@@ -36,18 +36,21 @@ parser = argparse.ArgumentParser(description='Cubical complex from a perseus'
'file style name.',
epilog='Example: '
'./cubical_complex_from_perseus_file_example.py'
- '../data/bitmap/CubicalTwoSphere.txt')
-parser.add_argument('perseus_file', type=str, required=True,
- help='Perseus file style name')
+ ' -f ../data/bitmap/CubicalTwoSphere.txt')
+
+parser.add_argument("-f", "--file", type=str, required=True)
args = parser.parse_args()
-print("#####################################################################")
-print("CubicalComplex creation")
-cubical_complex = gudhi.CubicalComplex(perseus_file=args.perseus_file)
+if os.access(args.file, os.R_OK):
+ print("#####################################################################")
+ print("CubicalComplex creation")
+ cubical_complex = gudhi.CubicalComplex(perseus_file=args.file)
-print("persistence(homology_coeff_field=2, min_persistence=0)=")
-print(cubical_complex.persistence(homology_coeff_field=2, min_persistence=0))
+ print("persistence(homology_coeff_field=2, min_persistence=0)=")
+ print(cubical_complex.persistence(homology_coeff_field=2, min_persistence=0))
-print("betti_numbers()=")
-print(cubical_complex.betti_numbers()) \ No newline at end of file
+ print("betti_numbers()=")
+ print(cubical_complex.betti_numbers())
+else:
+ print(args.file, "is unreachable")