From 587a845289a4e29014f67d4c3379b2b4d6b1f102 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 14 Jan 2020 14:40:41 +0100 Subject: print errors to stderr --- src/python/gudhi/alpha_complex.pyx | 2 ++ src/python/gudhi/cubical_complex.pyx | 9 ++++++--- src/python/gudhi/nerve_gic.pyx | 12 +++++++----- src/python/gudhi/off_reader.pyx | 4 +++- src/python/gudhi/periodic_cubical_complex.pyx | 8 +++++--- 5 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/python/gudhi') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index db11416c..4ff37437 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -7,12 +7,14 @@ # Modification(s): # - YYYY/MM Author: Description of the modification +from __future__ import print_function from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair from libcpp.string cimport string from libcpp cimport bool from libc.stdint cimport intptr_t +import sys import os from gudhi.simplex_tree cimport * diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 92ff6411..28913a32 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -7,11 +7,13 @@ # Modification(s): # - YYYY/MM Author: Description of the modification +from __future__ import print_function from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair from libcpp.string cimport string from libcpp cimport bool +import sys import os import numpy as np @@ -87,10 +89,11 @@ cdef class CubicalComplex: if os.path.isfile(perseus_file): self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file)) else: - print("file " + perseus_file + " not found.") + print("file " + perseus_file + " not found.", file=sys.stderr) else: print("CubicalComplex can be constructed from dimensions and " - "top_dimensional_cells or from a Perseus-style file name.") + "top_dimensional_cells or from a Perseus-style file name.", + file=sys.stderr) def __dealloc__(self): if self.thisptr != NULL: @@ -199,5 +202,5 @@ cdef class CubicalComplex: intervals_result = self.pcohptr.intervals_in_dimension(dimension) else: print("intervals_in_dim function requires persistence function" - " to be launched first.") + " to be launched first.", file=sys.stderr) return np.array(intervals_result) diff --git a/src/python/gudhi/nerve_gic.pyx b/src/python/gudhi/nerve_gic.pyx index 68c06432..5eb9be0d 100644 --- a/src/python/gudhi/nerve_gic.pyx +++ b/src/python/gudhi/nerve_gic.pyx @@ -7,11 +7,13 @@ # Modification(s): # - YYYY/MM Author: Description of the modification +from __future__ import print_function from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair from libcpp.string cimport string from libcpp cimport bool +import sys import os from libc.stdint cimport intptr_t @@ -182,7 +184,7 @@ cdef class CoverComplex: if os.path.isfile(off_file): return self.thisptr.read_point_cloud(str.encode(off_file)) else: - print("file " + off_file + " not found.") + print("file " + off_file + " not found.", file=sys.stderr) return False def set_automatic_resolution(self): @@ -214,7 +216,7 @@ cdef class CoverComplex: if os.path.isfile(color_file_name): self.thisptr.set_color_from_file(str.encode(color_file_name)) else: - print("file " + color_file_name + " not found.") + print("file " + color_file_name + " not found.", file=sys.stderr) def set_color_from_range(self, color): """Computes the function used to color the nodes of the simplicial @@ -235,7 +237,7 @@ cdef class CoverComplex: if os.path.isfile(cover_file_name): self.thisptr.set_cover_from_file(str.encode(cover_file_name)) else: - print("file " + cover_file_name + " not found.") + print("file " + cover_file_name + " not found.", file=sys.stderr) def set_cover_from_function(self): """Creates a cover C from the preimages of the function f. @@ -268,7 +270,7 @@ cdef class CoverComplex: if os.path.isfile(func_file_name): self.thisptr.set_function_from_file(str.encode(func_file_name)) else: - print("file " + func_file_name + " not found.") + print("file " + func_file_name + " not found.", file=sys.stderr) def set_function_from_range(self, function): """Creates the function f from a vector stored in memory. @@ -309,7 +311,7 @@ cdef class CoverComplex: if os.path.isfile(graph_file_name): self.thisptr.set_graph_from_file(str.encode(graph_file_name)) else: - print("file " + graph_file_name + " not found.") + print("file " + graph_file_name + " not found.", file=sys.stderr) def set_graph_from_OFF(self): """Creates a graph G from the triangulation given by the input OFF diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 58f05db8..ef8f420a 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -7,9 +7,11 @@ # Modification(s): # - YYYY/MM Author: Description of the modification +from __future__ import print_function from cython cimport numeric from libcpp.vector cimport vector from libcpp.string cimport string +import sys import os __author__ = "Vincent Rouvreau" @@ -32,6 +34,6 @@ def read_points_from_off_file(off_file=''): if os.path.isfile(off_file): return read_points_from_OFF_file(str.encode(off_file)) else: - print("file " + off_file + " not found.") + print("file " + off_file + " not found.", file=sys.stderr) return [] diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index b5dece10..4ec06524 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -7,11 +7,13 @@ # Modification(s): # - YYYY/MM Author: Description of the modification +from __future__ import print_function from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair from libcpp.string cimport string from libcpp cimport bool +import sys import os import numpy as np @@ -95,12 +97,12 @@ cdef class PeriodicCubicalComplex: if os.path.isfile(perseus_file): self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file)) else: - print("file " + perseus_file + " not found.") + print("file " + perseus_file + " not found.", file=sys.stderr) else: print("CubicalComplex can be constructed from dimensions, " "top_dimensional_cells and periodic_dimensions, or from " "top_dimensional_cells and periodic_dimensions or from " - "a Perseus-style file name.") + "a Perseus-style file name.", file=sys.stderr) def __dealloc__(self): if self.thisptr != NULL: @@ -209,5 +211,5 @@ cdef class PeriodicCubicalComplex: intervals_result = self.pcohptr.intervals_in_dimension(dimension) else: print("intervals_in_dim function requires persistence function" - " to be launched first.") + " to be launched first.", file=sys.stderr) return np.array(intervals_result) -- cgit v1.2.3