summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHind Montassif <hind.montassif@gmail.com>2021-05-10 10:58:36 +0200
committerHind Montassif <hind.montassif@gmail.com>2021-05-10 10:58:36 +0200
commit62510e70009ff2fc65028b88b56886fb53743e51 (patch)
tree90aed209b182fe5983f22b85237a6b3497db9110
parent2b694f9beae0e5fa78ae5b8923e7f2905c58777f (diff)
Rename dim to ambient_dim for sphere (to be consistent with dim in torus)
-rw-r--r--src/python/example/alpha_complex_from_generated_points_on_sphere_example.py2
-rw-r--r--src/python/gudhi/datasets/generators/points.cc18
2 files changed, 10 insertions, 10 deletions
diff --git a/src/python/example/alpha_complex_from_generated_points_on_sphere_example.py b/src/python/example/alpha_complex_from_generated_points_on_sphere_example.py
index e73584d3..267e6436 100644
--- a/src/python/example/alpha_complex_from_generated_points_on_sphere_example.py
+++ b/src/python/example/alpha_complex_from_generated_points_on_sphere_example.py
@@ -22,7 +22,7 @@ print("#####################################################################")
print("AlphaComplex creation from generated points on sphere")
-gen_points = points.sphere(n_samples = 50, dim = 2, radius = 1, sample = "random")
+gen_points = points.sphere(n_samples = 50, ambient_dim = 2, radius = 1, sample = "random")
# Create an alpha complex
alpha_complex = AlphaComplex(points = gen_points)
diff --git a/src/python/gudhi/datasets/generators/points.cc b/src/python/gudhi/datasets/generators/points.cc
index f02c7d73..e2626b09 100644
--- a/src/python/gudhi/datasets/generators/points.cc
+++ b/src/python/gudhi/datasets/generators/points.cc
@@ -21,27 +21,27 @@ namespace py = pybind11;
typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kern;
-py::array_t<double> generate_points_on_sphere(size_t n_samples, int dim, double radius, std::string sample) {
+py::array_t<double> generate_points_on_sphere(size_t n_samples, int ambient_dim, double radius, std::string sample) {
if (sample != "random") {
throw pybind11::value_error("sample type is not supported");
}
- py::array_t<double> points({n_samples, (size_t)dim});
+ py::array_t<double> points({n_samples, (size_t)ambient_dim});
py::buffer_info buf = points.request();
double *ptr = static_cast<double *>(buf.ptr);
GUDHI_CHECK(n_samples == buf.shape[0], "Py array first dimension not matching n_samples on sphere");
- GUDHI_CHECK(dim == buf.shape[1], "Py array second dimension not matching the ambient space dimension");
+ GUDHI_CHECK(ambient_dim == buf.shape[1], "Py array second dimension not matching the ambient space dimension");
py::gil_scoped_release release;
- auto points_generated = Gudhi::generate_points_on_sphere_d<Kern>(n_samples, dim, radius);
+ auto points_generated = Gudhi::generate_points_on_sphere_d<Kern>(n_samples, ambient_dim, radius);
for (size_t i = 0; i < n_samples; i++)
- for (int j = 0; j < dim; j++)
- ptr[i*dim+j] = points_generated[i][j];
+ for (int j = 0; j < ambient_dim; j++)
+ ptr[i*ambient_dim+j] = points_generated[i][j];
return points;
}
@@ -49,15 +49,15 @@ py::array_t<double> generate_points_on_sphere(size_t n_samples, int dim, double
PYBIND11_MODULE(points, m) {
m.attr("__license__") = "LGPL v3";
m.def("sphere", &generate_points_on_sphere,
- py::arg("n_samples"), py::arg("dim"),
+ py::arg("n_samples"), py::arg("ambient_dim"),
py::arg("radius") = 1, py::arg("sample") = "random",
R"pbdoc(
Generate random i.i.d. points uniformly on a (d-1)-sphere in R^d
:param n_samples: The number of points to be generated.
:type n_samples: integer
- :param dim: The ambient dimension d.
- :type dim: integer
+ :param ambient_dim: The ambient dimension d.
+ :type ambient_dim: integer
:param radius: The radius.
:type radius: float
:param sample: The sample type.