BoostConfig#
-
class numpy::BoostConfig#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use BoostConfig
BoostConfig obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
Backend |
BOOST_CONFIG.H:92 |
Other Methods#
Code Examples#
The following examples are extracted from the test suite.
get_default_backend (np_test_1_all.cpp:25367)
25357 // std::cout << "[OK] BoostInfo tests passed" << std::endl;
25358 }
25359
25360 void test_boost_config() {
25361 std::cout << "========= Testing BoostConfig ===================";
25362
25363 using namespace numpy::boost_lib;
25364
25365 // Test default backend
25366 Backend default_backend = BoostConfig::get_default_backend();
25367 // std::cout << "Default backend: "
25368 // << (default_backend == Backend::AUTO ? "AUTO" :
25369 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD")
25370 // << std::endl;
25371
25372 // Test backend resolution
25373 Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO);
25374 // std::cout << "Resolved AUTO backend: "
25375 // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD")
25376 // << std::endl;
resolve_backend (np_test_1_all.cpp:25374)
25364 using namespace numpy::boost_lib;
25365
25366 // Test default backend
25367 Backend default_backend = BoostConfig::get_default_backend();
25368 // std::cout << "Default backend: "
25369 // << (default_backend == Backend::AUTO ? "AUTO" :
25370 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD")
25371 // << std::endl;
25372
25373 // Test backend resolution
25374 Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO);
25375 // std::cout << "Resolved AUTO backend: "
25376 // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD")
25377 // << std::endl;
25378
25379 // Test should_use_boost
25380 bool use_boost = BoostConfig::should_use_boost(Backend::AUTO);
25381 // std::cout << "Should use Boost (AUTO): " << (use_boost ? "Yes" : "No") << std::endl;
25382
25383 // Verify consistency
25384 if (BoostInfo::is_runtime_available()) {
set_default_backend (np_test_1_all.cpp:25414)
25404 // Test forced STANDARD backend
25405 bool use_standard = BoostConfig::should_use_boost(Backend::STANDARD);
25406 if (use_standard) {
25407 throw std::runtime_error("Forced STANDARD backend not working");
25408 }
25409 // std::cout << "[OK] Forced STANDARD backend works" << std::endl;
25410
25411 // Test backend setting
25412 Backend original = BoostConfig::get_default_backend();
25413 BoostConfig::set_default_backend(Backend::STANDARD);
25414 if (BoostConfig::get_default_backend() != Backend::STANDARD) {
25415 throw std::runtime_error("Backend setting not working");
25416 }
25417 BoostConfig::set_default_backend(original); // Restore
25418 // std::cout << "[OK] Backend setting works" << std::endl;
25419
25420 // std::cout << "[OK] BoostConfig tests passed" << std::endl;
25421 }
25422
25423#if BOOST_ENABLED
should_use_boost (np_test_1_all.cpp:25380)
25370 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD")
25371 // << std::endl;
25372
25373 // Test backend resolution
25374 Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO);
25375 // std::cout << "Resolved AUTO backend: "
25376 // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD")
25377 // << std::endl;
25378
25379 // Test should_use_boost
25380 bool use_boost = BoostConfig::should_use_boost(Backend::AUTO);
25381 // std::cout << "Should use Boost (AUTO): " << (use_boost ? "Yes" : "No") << std::endl;
25382
25383 // Verify consistency
25384 if (BoostInfo::is_runtime_available()) {
25385 // If Boost is available, AUTO should resolve to BOOST
25386 if (resolved_auto != Backend::BOOST) {
25387 throw std::runtime_error("Backend resolution incorrect when Boost available");
25388 }
25389 if (!use_boost) {
25390 throw std::runtime_error("should_use_boost incorrect when Boost available");