Skip to content

Commit fa03aff

Browse files
committed
windows: disable persistence algebra
1 parent c6a95be commit fa03aff

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

cmake/MultipersBuild.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endif()
2222
multipers_default_disable_flag("multi_critical" MULTIPERS_DISABLE_MULTI_CRITICAL_INTERFACE)
2323
multipers_default_disable_flag("rhomboid" MULTIPERS_DISABLE_RHOMBOID_TILING_INTERFACE)
2424
multipers_default_disable_flag("hera" MULTIPERS_DISABLE_HERA_INTERFACE)
25+
multipers_default_disable_flag("persistence_algebra" MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE)
2526

2627
if(WIN32)
2728
set(MULTIPERS_DISABLE_MPFREE_INTERFACE ON)
@@ -38,6 +39,8 @@ if(WIN32)
3839
message(STATUS "[rhomboid] Forced MULTIPERS_DISABLE_RHOMBOID_TILING_INTERFACE=${MULTIPERS_DISABLE_RHOMBOID_TILING_INTERFACE} on WIN32")
3940
set(MULTIPERS_DISABLE_HERA_INTERFACE ON)
4041
message(STATUS "[hera] Forced MULTIPERS_DISABLE_HERA_INTERFACE=${MULTIPERS_DISABLE_HERA_INTERFACE} on WIN32")
42+
set(MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE ON)
43+
message(STATUS "[persistence_algebra] Forced MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE=${MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE} on WIN32")
4144
endif()
4245

4346
if(NOT MULTIPERS_HAS_FLAT_FILTRATION_CONTAINER)
@@ -111,6 +114,7 @@ set(MULTIPERS_INTERFACE_DISABLE_FLAGS
111114
MULTIPERS_DISABLE_MULTI_CRITICAL_INTERFACE
112115
MULTIPERS_DISABLE_RHOMBOID_TILING_INTERFACE
113116
MULTIPERS_DISABLE_HERA_INTERFACE
117+
MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
114118
)
115119

116120
set(MULTIPERS_INTERFACE_DISABLE_DEFINITIONS "")
@@ -876,10 +880,12 @@ function(multipers_configure_module module_name target_name)
876880
endif()
877881

878882
elseif(module_name STREQUAL "_persistence_algebra_interface")
879-
multipers_link_nanobind_runtime(${target_name})
880-
multipers_link_openmp(${target_name})
881-
multipers_link_tbb(${target_name})
882-
target_include_directories(${target_name} PRIVATE "${CMAKE_SOURCE_DIR}/ext/Persistence-Algebra/include")
883+
if(NOT MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE)
884+
multipers_link_nanobind_runtime(${target_name})
885+
multipers_link_openmp(${target_name})
886+
multipers_link_tbb(${target_name})
887+
target_include_directories(${target_name} PRIVATE "${CMAKE_SOURCE_DIR}/ext/Persistence-Algebra/include")
888+
endif()
883889

884890
elseif(module_name STREQUAL "_hera_interface")
885891
if(NOT MULTIPERS_DISABLE_HERA_INTERFACE)

multipers/_persistence_algebra_interface.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
#include <stdexcept>
99

1010
#include "ext_interface/persistence_algebra_interface.hpp"
11+
12+
#if !MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
1113
#include "ext_interface/nanobind_registry_runtime.hpp"
14+
#endif
1215

1316
namespace nb = nanobind;
1417
using namespace nb::literals;
1518

1619
namespace mppai {
1720

21+
#if !MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
22+
1823
using CanonicalWrapper = multipers::nanobind_helpers::canonical_contiguous_f64_slicer_wrapper;
1924

2025
inline multipers::packed_morphism_columns packed_columns(
@@ -80,6 +85,8 @@ inline nb::object algebra_operation_for_target(nb::object source,
8085
throw std::invalid_argument("Unknown Persistence-Algebra operation.");
8186
}
8287

88+
#endif
89+
8390
} // namespace mppai
8491

8592
NB_MODULE(_persistence_algebra_interface, m) {
@@ -188,6 +195,15 @@ NB_MODULE(_persistence_algebra_interface, m) {
188195
nb::ndarray<nb::numpy, const std::uint64_t, nb::ndim<1>, nb::c_contig> column_indptr,
189196
nb::ndarray<nb::numpy, const std::uint32_t, nb::ndim<1>, nb::c_contig> row_indices,
190197
int degree) {
198+
#if MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
199+
(void)op;
200+
(void)source;
201+
(void)target;
202+
(void)column_indptr;
203+
(void)row_indices;
204+
(void)degree;
205+
throw std::runtime_error("Persistence-Algebra interface is disabled at compile time.");
206+
#else
191207
auto columns = mppai::packed_columns(column_indptr, row_indices);
192208
if (!multipers::persistence_algebra_interface_available()) {
193209
throw std::runtime_error("Persistence-Algebra interface is not available.");
@@ -203,6 +219,7 @@ NB_MODULE(_persistence_algebra_interface, m) {
203219
return out;
204220
}
205221
return multipers::nanobind_helpers::astype_slicer_to_original_type(owner, out);
222+
#endif
206223
},
207224
"op"_a,
208225
"source"_a,
@@ -217,6 +234,12 @@ NB_MODULE(_persistence_algebra_interface, m) {
217234
(void)use_clearing;
218235
(void)use_chunk;
219236
(void)verbose;
237+
#if MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
238+
(void)slicer;
239+
(void)degree;
240+
(void)full_resolution;
241+
throw std::runtime_error("Persistence-Algebra interface is disabled at compile time.");
242+
#else
220243
if (!multipers::persistence_algebra_interface_available()) {
221244
throw std::runtime_error("Persistence-Algebra interface is not available.");
222245
}
@@ -226,6 +249,7 @@ NB_MODULE(_persistence_algebra_interface, m) {
226249
return out;
227250
}
228251
return multipers::nanobind_helpers::astype_slicer_to_original_type(slicer, out);
252+
#endif
229253
},
230254
"slicer"_a,
231255
"degree"_a,
@@ -237,6 +261,11 @@ NB_MODULE(_persistence_algebra_interface, m) {
237261
m.def(
238262
"death_curve_presentation",
239263
[](nb::object slicer, int degree) {
264+
#if MULTIPERS_DISABLE_PERSISTENCE_ALGEBRA_INTERFACE
265+
(void)slicer;
266+
(void)degree;
267+
throw std::runtime_error("Persistence-Algebra interface is disabled at compile time.");
268+
#else
240269
if (!multipers::persistence_algebra_interface_available()) {
241270
throw std::runtime_error("Persistence-Algebra interface is not available.");
242271
}
@@ -249,6 +278,7 @@ NB_MODULE(_persistence_algebra_interface, m) {
249278
return out;
250279
}
251280
return multipers::nanobind_helpers::astype_slicer_to_original_type(slicer, out);
281+
#endif
252282
},
253283
"slicer"_a,
254284
"degree"_a);

0 commit comments

Comments
 (0)