Skip to content

Commit 07cf96b

Browse files
authored
Merge pull request #53 from hschreiber/plot_fix
small fixes
2 parents b57a104 + e46c69e commit 07cf96b

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

multipers/io.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _multi_critical_from_slicer(
309309
str algo:Literal["path","tree"]="path",
310310
degree:Optional[int]=None,
311311
bool clear = True,
312-
swedish:Optional[bool] = None,
312+
swedish = None,
313313
bool verbose = False,
314314
bool kcritical=False,
315315
str filtration_container = "flat",

multipers/multiparameter_module_approximation/approximation.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define APPROXIMATION_H_INCLUDED
2121

2222
#include <algorithm>
23+
#include <cassert>
2324
#include <cmath>
2425
#include <cstddef>
2526
#include <cstdint>
@@ -403,33 +404,36 @@ class Summand {
403404
Summand<int64_t> grid_squeeze(const std::vector<std::vector<value_type>> &grid) const;
404405

405406
void evaluate_in_grid(const std::vector<std::vector<value_type>> &grid) {
407+
using T = typename filtration_type::value_type;
406408
if (birth_corners_.num_generators() == 0) return;
407-
auto num_parameters = birth_corners_.num_parameters();
408-
auto snap = [](value_type x) {
409-
value_type a = std::floor(x);
410-
value_type b = std::ceil(x);
411-
size_t out;
409+
auto snap = [](T x) {
410+
T a = std::floor(x);
411+
T b = std::ceil(x);
412+
std::size_t out;
412413
if (x - a < b - x)
413-
out = static_cast<size_t>(a);
414+
out = static_cast<std::size_t>(a);
414415
else
415-
out = static_cast<size_t>(b);
416+
out = static_cast<std::size_t>(b);
416417
return out;
417418
};
418419
auto todo = [&](auto &corners) {
419-
return [&](size_t g) {
420+
return [&](std::size_t g) {
420421
// auto &x = corners[i];
421422
// for (auto g = 0u; g < x.num_generators(); ++g) {
422423
for (auto p = 0u; p < corners.num_parameters(); ++p) {
423-
value_type snapped = snap(corners(g, p));
424-
corners(g, p) = (snapped >= grid[p].size() ? filtration_type::inf(num_parameters)(0,p) : grid[p][snapped]);
424+
assert(corners(g, p) >= 0);
425+
if (corners(g, p) != filtration_type::T_inf) {
426+
std::size_t snapped = snap(corners(g, p));
427+
corners(g, p) = (snapped >= grid[p].size() ? filtration_type::T_inf : grid[p][snapped]);
428+
}
425429
}
426430
// }
427431
};
428432
};
429433

430-
tbb::parallel_for(size_t(0), birth_corners_.size(), todo(birth_corners_));
434+
tbb::parallel_for(std::size_t(0), birth_corners_.size(), todo(birth_corners_));
431435
if (death_corners_.num_generators() == 0) return;
432-
tbb::parallel_for(size_t(0), death_corners_.size(), todo(death_corners_));
436+
tbb::parallel_for(std::size_t(0), death_corners_.size(), todo(death_corners_));
433437
};
434438

435439
void snap_to_integers() {

0 commit comments

Comments
 (0)