summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorHind-M <hind.montassif@gmail.com>2021-06-07 17:07:55 +0200
committerHind-M <hind.montassif@gmail.com>2021-06-07 17:07:55 +0200
commitb9160fb8410bbb999913b0b4e91f1aa1ff58d2cd (patch)
tree410795193a098deeb42ddc120e51d0a7250ecb4c /src/python
parentb04759faf8f474ff98e9e229c41d85ff3bf009da (diff)
Replace 'uniform' flag of torus generation with 'sample' taking two possible values: 'grid'(i.e uniform==True) or 'random' (i.e uniform==False)
Diffstat (limited to 'src/python')
-rw-r--r--src/python/doc/datasets_generators.rst8
-rw-r--r--src/python/gudhi/datasets/generators/_points.cc10
2 files changed, 9 insertions, 9 deletions
diff --git a/src/python/doc/datasets_generators.rst b/src/python/doc/datasets_generators.rst
index ef21c9d2..2802eccd 100644
--- a/src/python/doc/datasets_generators.rst
+++ b/src/python/doc/datasets_generators.rst
@@ -52,9 +52,9 @@ First module : **_points**
""""""""""""""""""""""""""
The user should provide the number of points to be generated on the torus :code:`n_samples`, and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`.
-The flag :code:`uniform` is optional and is set to **False** by default, meaning that the points will be generated randomly.
+The :code:`sample` argument is optional and is set to **'random'** by default.
In this case, the returned generated points would be an array of shape :math:`(n\_samples, 2*dim)`.
-Otherwise, if set to **True**, the points are generated as a grid and would be given as an array of shape :
+Otherwise, if set to **'grid'**, the points are generated on a grid and would be given as an array of shape :
.. math::
@@ -70,7 +70,7 @@ Example
gen_points = _points.torus(n_samples = 50, dim = 3)
# Generate 27 points on a torus as a grid in R^6
- gen_points = _points.torus(n_samples = 50, dim = 3, uniform = True)
+ gen_points = _points.torus(n_samples = 50, dim = 3, sample = 'grid')
.. autofunction:: gudhi.datasets.generators._points.torus
@@ -79,7 +79,7 @@ Second module : **points**
The user should provide the number of points to be generated on the torus :code:`n_samples` and the dimension :code:`dim` of the torus on which points would be generated in :math:`R^{2dim}`.
The :code:`sample` argument is optional and is set to **'random'** by default.
-The other allowed value of sample type is **'grid'** and is equivalent to :code:`uniform = True` in the first module.
+The other allowed value of sample type is **'grid'**.
Example
"""""""
diff --git a/src/python/gudhi/datasets/generators/_points.cc b/src/python/gudhi/datasets/generators/_points.cc
index 55b21b2b..6bbdf284 100644
--- a/src/python/gudhi/datasets/generators/_points.cc
+++ b/src/python/gudhi/datasets/generators/_points.cc
@@ -46,13 +46,13 @@ py::array_t<double> generate_points_on_sphere(size_t n_samples, int ambient_dim,
return points;
}
-py::array_t<double> generate_points_on_torus(size_t n_samples, int dim, bool uniform) {
+py::array_t<double> generate_points_on_torus(size_t n_samples, int dim, std::string sample) {
std::vector<typename Kern::Point_d> points_generated;
{
py::gil_scoped_release release;
- points_generated = Gudhi::generate_points_on_torus_d<Kern>(n_samples, dim, uniform);
+ points_generated = Gudhi::generate_points_on_torus_d<Kern>(n_samples, dim, sample);
}
size_t npoints = points_generated.size();
@@ -93,7 +93,7 @@ PYBIND11_MODULE(_points, m) {
)pbdoc");
m.def("torus", &generate_points_on_torus,
- py::arg("n_samples"), py::arg("dim"), py::arg("uniform") = false,
+ py::arg("n_samples"), py::arg("dim"), py::arg("sample") = "random",
R"pbdoc(
Generate random i.i.d. points on a d-torus in R^2d
@@ -101,8 +101,8 @@ PYBIND11_MODULE(_points, m) {
:type n_samples: integer
:param dim: The dimension of the torus on which points would be generated in R^2*dim.
:type dim: integer
- :param uniform: A flag to define if the points generation is uniform (i.e generated as a grid).
- :type uniform: bool
+ :param sample: The sample type. Available values are: `"random"` and `"grid"`. Default value is `"random"`.
+ :type sample: string
:rtype: numpy array of float
:returns: the generated points on a torus.
)pbdoc");