diff options
author | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-09-10 05:51:46 +0000 |
---|---|---|
committer | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-09-10 05:51:46 +0000 |
commit | 074fc0031f495c8dd03f4b8924805ac818cc9f58 (patch) | |
tree | 9e1b78f43b133148c507cdcb0b91b92684eba668 | |
parent | bd9809aeede2b42a767e9bc884bd246e1204479d (diff) |
New try to initialize objects with static functions.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration@2653 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: aca67a9f22c0a0481143cd487d9c98071aa84f6a
-rw-r--r-- | src/cython/cython/persistence_representations_landscapes.pyx | 18 | ||||
-rw-r--r-- | src/cython/gudhi.pyx.in | 2 | ||||
-rw-r--r-- | src/cython/include/Persistence_landscape_interface.h | 15 | ||||
-rw-r--r-- | src/cython/include/Persistence_landscape_on_grid_interface.h | 3 |
4 files changed, 32 insertions, 6 deletions
diff --git a/src/cython/cython/persistence_representations_landscapes.pyx b/src/cython/cython/persistence_representations_landscapes.pyx index 035c7d58..416c5ba6 100644 --- a/src/cython/cython/persistence_representations_landscapes.pyx +++ b/src/cython/cython/persistence_representations_landscapes.pyx @@ -37,7 +37,7 @@ __license__ = "GPL v3" cdef extern from "Persistence_landscape_interface.h" namespace "Gudhi::Persistence_representations": cdef cppclass Persistence_landscape_interface "Gudhi::Persistence_representations::Persistence_landscape_interface": Persistence_landscape_interface() - Persistence_landscape_interface(vector[pair[double, double]], size_t) + Persistence_landscape_interface(vector[pair[double, double]], bool, size_t) Persistence_landscape_interface(const char*, size_t , size_t) void load_landscape_from_file(const char*) void print_to_file(const char*)const @@ -60,6 +60,13 @@ cdef extern from "Persistence_landscape_interface.h" namespace "Gudhi::Persisten double distance(const Persistence_landscape_interface&, double) double compute_scalar_product(const Persistence_landscape_interface&)const pair[double, double] get_y_range(size_t)const + #************** + #static methods + @staticmethod + Persistence_landscape_interface* construct_from_file( const char*, size_t, size_t) + #@staticmethod + #cdef Persistence_landscape_interface* Persistence_landscape_interface_construct_from_vector_of_pairs "Persistence_landscape_interface::construct_from_vector_of_pairs"( const vector[pair[double, double]], size_t) + #*************** @@ -124,13 +131,16 @@ cdef class PersistenceLandscapes: if (vector_of_intervals is None) and (file_with_intervals is not ''): if (dimension is not None): if os.path.isfile(file_with_intervals): - self.thisptr = new Persistence_landscape_interface(file_with_intervals, dimension, number_of_levels) + #self.thisptr = new Persistence_landscape_interface(file_with_intervals, dimension, number_of_levels) + self.thisptr = Persistence_landscape_interface::construct_from_file(file_with_intervals, dimension, number_of_levels) else: print("file " + file_with_intervals + " not found.") else: - self.thisptr = new Persistence_landscape_interface(file_with_intervals, number_of_levels) + #self.thisptr = new Persistence_landscape_interface(file_with_intervals, number_of_levels) + self.thisptr = Persistence_landscape_interface::construct_from_file(file_with_intervals,0, number_of_levels) elif (file_with_intervals is '') and (vector_of_intervals is not None): - self.thisptr = new Persistence_landscape_interface(vector_of_intervals, number_of_levels) + #self.thisptr = new Persistence_landscape_interface(vector_of_intervals, true, number_of_levels) + self.thisptr = Persistence_landscape_interface::construct_from_vector_of_pairs(vector_of_intervals, number_of_levels) else: print("Persistence interals can be constructed from vector of birth-death pairs, vector_of_intervals or a Gudhi-style file.") self.thisptr = new Persistence_landscape_interface() diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 0fa226db..53f09c4b 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -34,7 +34,7 @@ include "cython/witness_complex.pyx" include "cython/strong_witness_complex.pyx" include "cython/persistence_representations_intervals.pyx" include "cython/persistence_representations_landscapes.pyx" -include "cython/persistence_representations_landscapes_on_grid.pyx" +#include "cython/persistence_representations_landscapes_on_grid.pyx" @GUDHI_CYTHON_ALPHA_COMPLEX@ @GUDHI_CYTHON_EUCLIDEAN_WITNESS_COMPLEX@ @GUDHI_CYTHON_SUBSAMPLING@ diff --git a/src/cython/include/Persistence_landscape_interface.h b/src/cython/include/Persistence_landscape_interface.h index e5afffdc..3261c403 100644 --- a/src/cython/include/Persistence_landscape_interface.h +++ b/src/cython/include/Persistence_landscape_interface.h @@ -37,6 +37,21 @@ class Persistence_landscape_interface : public Persistence_landscape Persistence_landscape_interface(const std::vector<std::pair<double, double> >& p, size_t number_of_levels = std::numeric_limits<size_t>::max() ):Persistence_landscape(p,number_of_levels){} Persistence_landscape_interface(const char* filename, size_t dimension = std::numeric_limits<unsigned>::max() , size_t number_of_levels = std::numeric_limits<size_t>::max() ):Persistence_landscape(filename,dimension,number_of_levels){} + + + //**************** + static Persistence_landscape_interface* construct_from_file( const char* filename, size_t dimension = std::numeric_limits<unsigned>::max() , size_t number_of_levels = std::numeric_limits<size_t>::max() ) + { + Persistence_landscape_interface* result = new Persistence_landscape_interface(filename,dimension,number_of_levels); + return result; + } + static Persistence_landscape_interface* construct_from_vector_of_pairs( const std::vector<std::pair<double, double> >& p, size_t number_of_levels = std::numeric_limits<size_t>::max() ) + { + Persistence_landscape_interface* result = new Persistence_landscape_interface(p,number_of_levels); + return result; + } + + //**************** Persistence_landscape_interface* new_abs_interface() diff --git a/src/cython/include/Persistence_landscape_on_grid_interface.h b/src/cython/include/Persistence_landscape_on_grid_interface.h index e16f0e34..c8ba9f76 100644 --- a/src/cython/include/Persistence_landscape_on_grid_interface.h +++ b/src/cython/include/Persistence_landscape_on_grid_interface.h @@ -57,7 +57,8 @@ class Persistence_landscape_on_grid_interface : public Persistence_landscape_on_ Persistence_landscape_on_grid_interface(const char* filename, size_t number_of_points, uint16_t dimension = std::numeric_limits<uint16_t>::max()): - Persistence_landscape_on_grid(filename,number_of_points,dimension){} + Persistence_landscape_on_grid(filename,number_of_points,dimension){} + Persistence_landscape_on_grid_interface* new_abs_interface() { |