From d091cf5369c2eba0bb301942842d56606a45af76 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 9 Nov 2019 21:03:13 +0100 Subject: Replace 'is' with == or similar. Related to issue #113, but I did not touch persistence_graphical_tools.py which is handled in PR #119. I don't know if I got them all, I guess we'll start seeing the warnings with python-3.8 soon enough. --- src/python/gudhi/euclidean_strong_witness_complex.pyx | 2 +- src/python/gudhi/euclidean_witness_complex.pyx | 2 +- src/python/gudhi/off_reader.pyx | 2 +- src/python/gudhi/periodic_cubical_complex.pyx | 4 ++-- src/python/gudhi/reader_utils.pyx | 6 +++--- src/python/gudhi/strong_witness_complex.pyx | 2 +- src/python/gudhi/subsampling.pyx | 14 +++++++------- src/python/gudhi/tangential_complex.pyx | 2 +- src/python/gudhi/witness_complex.pyx | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/python/gudhi/euclidean_strong_witness_complex.pyx b/src/python/gudhi/euclidean_strong_witness_complex.pyx index 5d6e4fb9..0e5b544a 100644 --- a/src/python/gudhi/euclidean_strong_witness_complex.pyx +++ b/src/python/gudhi/euclidean_strong_witness_complex.pyx @@ -71,7 +71,7 @@ cdef class EuclideanStrongWitnessComplex: """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - if limit_dimension is not -1: + if limit_dimension != -1: self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square, limit_dimension) else: diff --git a/src/python/gudhi/euclidean_witness_complex.pyx b/src/python/gudhi/euclidean_witness_complex.pyx index 2531919b..86d2d996 100644 --- a/src/python/gudhi/euclidean_witness_complex.pyx +++ b/src/python/gudhi/euclidean_witness_complex.pyx @@ -71,7 +71,7 @@ cdef class EuclideanWitnessComplex: """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - if limit_dimension is not -1: + if limit_dimension != -1: self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square, limit_dimension) else: diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 9efd97ff..27a89870 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -29,7 +29,7 @@ def read_off(off_file=''): :returns: The point set. :rtype: vector[vector[double]] """ - if off_file is not '': + if off_file: if os.path.isfile(off_file): return read_points_from_OFF_file(str.encode(off_file)) else: diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index 724fadd4..88223afb 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -68,9 +68,9 @@ cdef class PeriodicCubicalComplex: # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, periodic_dimensions=None, perseus_file=''): - if (dimensions is not None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file is ''): + if (dimensions is not None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file == ''): self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) - elif (dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file is not ''): + elif (dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file != ''): if os.path.isfile(perseus_file): self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file)) else: diff --git a/src/python/gudhi/reader_utils.pyx b/src/python/gudhi/reader_utils.pyx index 147fae71..b266c783 100644 --- a/src/python/gudhi/reader_utils.pyx +++ b/src/python/gudhi/reader_utils.pyx @@ -37,7 +37,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): :returns: The lower triangular matrix. :rtype: vector[vector[double]] """ - if csv_file is not '': + if csv_file: if path.isfile(csv_file): return read_matrix_from_csv_file(str.encode(csv_file), ord(separator[0])) print("file " + csv_file + " not set or not found.") @@ -56,7 +56,7 @@ def read_persistence_intervals_grouped_by_dimension(persistence_file=''): :returns: The persistence pairs grouped by dimension. :rtype: map[int, vector[pair[double, double]]] """ - if persistence_file is not '': + if persistence_file: if path.isfile(persistence_file): return read_pers_intervals_grouped_by_dimension(str.encode(persistence_file)) print("file " + persistence_file + " not set or not found.") @@ -79,7 +79,7 @@ def read_persistence_intervals_in_dimension(persistence_file='', only_this_dim=- :returns: The persistence intervals. :rtype: numpy array of dimension 2 """ - if persistence_file is not '': + if persistence_file: if path.isfile(persistence_file): return np_array(read_pers_intervals_in_dimension(str.encode( persistence_file), only_this_dim)) diff --git a/src/python/gudhi/strong_witness_complex.pyx b/src/python/gudhi/strong_witness_complex.pyx index e757abea..e35ba6ad 100644 --- a/src/python/gudhi/strong_witness_complex.pyx +++ b/src/python/gudhi/strong_witness_complex.pyx @@ -69,7 +69,7 @@ cdef class StrongWitnessComplex: """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - if limit_dimension is not -1: + if limit_dimension != -1: self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square, limit_dimension) else: diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index 1135c1fb..e622ac99 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -44,15 +44,15 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi :param nb_points: Number of points of the subsample. :type nb_points: unsigned. :param starting_point: The iteration starts with the landmark `starting \ - point`,which is the index of the poit to start with. If not set, this \ - index is choosen randomly. + point`,which is the index of the point to start with. If not set, this \ + index is chosen randomly. :type starting_point: unsigned. :returns: The subsample point set. :rtype: vector[vector[double]] """ - if off_file is not '': + if off_file: if os.path.isfile(off_file): - if starting_point is '': + if starting_point == '': return subsampling_n_farthest_points_from_file(str.encode(off_file), nb_points) else: @@ -65,7 +65,7 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi if points is None: # Empty points points=[] - if starting_point is '': + if starting_point == '': return subsampling_n_farthest_points(points, nb_points) else: return subsampling_n_farthest_points(points, nb_points, @@ -87,7 +87,7 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): :returns: The subsample point set. :rtype: vector[vector[double]] """ - if off_file is not '': + if off_file: if os.path.isfile(off_file): return subsampling_n_random_points_from_file(str.encode(off_file), nb_points) @@ -117,7 +117,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): :returns: The subsample point set. :rtype: vector[vector[double]] """ - if off_file is not '': + if off_file: if os.path.isfile(off_file): return subsampling_sparsify_points_from_file(str.encode(off_file), min_squared_dist) diff --git a/src/python/gudhi/tangential_complex.pyx b/src/python/gudhi/tangential_complex.pyx index 3a945fe2..9ef15567 100644 --- a/src/python/gudhi/tangential_complex.pyx +++ b/src/python/gudhi/tangential_complex.pyx @@ -65,7 +65,7 @@ cdef class TangentialComplex: # The real cython constructor def __cinit__(self, intrisic_dim, points=None, off_file=''): - if off_file is not '': + if off_file: if os.path.isfile(off_file): self.thisptr = new Tangential_complex_interface(intrisic_dim, str.encode(off_file), True) else: diff --git a/src/python/gudhi/witness_complex.pyx b/src/python/gudhi/witness_complex.pyx index baa70b7a..c19ccf2b 100644 --- a/src/python/gudhi/witness_complex.pyx +++ b/src/python/gudhi/witness_complex.pyx @@ -69,7 +69,7 @@ cdef class WitnessComplex: """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - if limit_dimension is not -1: + if limit_dimension != -1: self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square, limit_dimension) else: -- cgit v1.2.3 From c3414741af6ef98703ba9414803aff5a2d08777d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 16 Nov 2019 06:34:54 +0100 Subject: More 'is' to '==' --- src/python/gudhi/alpha_complex.pyx | 2 +- src/python/gudhi/cubical_complex.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index 6d6309db..a85c47c8 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -68,7 +68,7 @@ cdef class AlphaComplex: # The real cython constructor def __cinit__(self, points=None, off_file=''): - if off_file is not '': + if off_file: if os.path.isfile(off_file): self.thisptr = new Alpha_complex_interface(str.encode(off_file), True) else: diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 0dc133d1..579c942b 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -66,9 +66,9 @@ cdef class CubicalComplex: # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, perseus_file=''): - if (dimensions is not None) and (top_dimensional_cells is not None) and (perseus_file is ''): + if (dimensions is not None) and (top_dimensional_cells is not None) and (perseus_file == ''): self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) - elif (dimensions is None) and (top_dimensional_cells is None) and (perseus_file is not ''): + elif (dimensions is None) and (top_dimensional_cells is None) and (perseus_file != ''): if os.path.isfile(perseus_file): self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file)) else: -- cgit v1.2.3