Skip to content

Commit dada538

Browse files
author
Felipe Garrido R.
committed
get_partitions now returns python list
1 parent a66c851 commit dada538

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

include/spatialize/abstract_esi.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,32 @@ namespace sptlz{
404404
std::vector<std::vector<std::vector<float>>> partitions;
405405
int n = mondrian_forest.size();
406406

407+
long count = 0;
408+
std::cout << "UNO" << std::endl;
407409
for(int i=0; i<n; i++){
410+
408411
std::vector<std::vector<float>> this_partition;
409412
// get leaves for i-th tree
410413
for(auto leaf: mondrian_forest.at(i)->leaves){
414+
std::cout << "aaaa" << std::endl;
411415
std::vector<float> this_leaf;
416+
std::cout << "bbbb" << std::endl;
412417
this_leaf.push_back(leaf->leaf_id);
418+
std::cout << "cccc" << std::endl;
413419
for(auto ax_lims: leaf->bbox){
420+
std::cout << "dddd" << std::endl;
414421
this_leaf.push_back(ax_lims[0]);
422+
std::cout << "eeee" << std::endl;
415423
this_leaf.push_back(ax_lims[1]);
416424
}
425+
count += this_leaf.size();
426+
std::cout << "ffff" << std::endl;
417427
this_partition.push_back(this_leaf);
418428
}
429+
std::cout << "gggg" << std::endl;
419430
partitions.push_back(this_partition);
420431
}
432+
std::cout << "hhhh " << (8*count/1024.0) << std::endl;
421433
return(partitions);
422434
}
423435

src/c++/libspatialize.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace py = pybind11;
1616

17-
py::array_t<float> get_partitions_using_esi(py::array_t<float> samples, int forest_size, float alpha, std::optional<py::function> visitor, int seed){
17+
std::vector<std::vector<std::vector<float>>> get_partitions_using_esi(py::array_t<float> samples, int forest_size, float alpha, std::optional<py::function> visitor, int seed){
1818
py::buffer_info smp_info = samples.request();
1919

2020
if (smp_info.ndim != 2)
@@ -41,7 +41,8 @@ py::array_t<float> get_partitions_using_esi(py::array_t<float> samples, int fore
4141

4242
delete esi;
4343

44-
return(sptlz::vector_3d_to_ndarray(&r));
44+
// return(sptlz::vector_3d_to_ndarray(&r));
45+
return(r);
4546
}
4647

4748
py::array_t<float> get_leaf_for_samples_using_esi(py::array_t<float> samples, int forest_size, float alpha, std::optional<py::function> visitor, int seed){
@@ -1267,8 +1268,8 @@ PYBIND11_MODULE(libspatialize, m) {
12671268
"get leaves bbox for every partition"
12681269
);
12691270
m.def(
1270-
"get_leaves_by_samples_using_esi",
1271-
&get_leaves_by_samples_using_esi,
1271+
"get_leaf_for_samples_using_esi",
1272+
&get_leaf_for_samples_using_esi,
12721273
"get several partitions using MondrianTree"
12731274
);
12741275
/* plain NN IDW*/

0 commit comments

Comments
 (0)