aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/contourpy/src/util.cpp
blob: 59b6e4da5580daa8699666f5db54d5bf72d422f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "util.h"
#include <thread>

namespace contourpy {

bool Util::_nan_loaded = false;

double Util::nan = 0.0;

void Util::ensure_nan_loaded()
{
    if (!_nan_loaded) {
        auto numpy = py::module_::import("numpy");
        nan = numpy.attr("nan").cast<double>();
        _nan_loaded = true;
    }
}

index_t Util::get_max_threads()
{
    return static_cast<index_t>(std::thread::hardware_concurrency());
}

} // namespace contourpy