Skip to content
Snippets Groups Projects
Select Git revision
  • fdd9e7eee2ff3446871540768d582fa53ebf0ee3
  • master default protected
  • tut_ring_allen
  • docs_furo
  • docs_reorder_cable_cell
  • docs_graphviz
  • docs_rtd_dev
  • ebrains_mirror
  • doc_recat
  • docs_spike_source
  • docs_sim_sample_clar
  • docs_pip_warn
  • github_template_updates
  • docs_fix_link
  • cv_default_and_doc_clarification
  • docs_add_numpy_req
  • readme_zenodo_05
  • install_python_fix
  • install_require_numpy
  • typofix_propetries
  • docs_recipe_lookup
  • v0.10.0
  • v0.10.1
  • v0.10.0-rc5
  • v0.10.0-rc4
  • v0.10.0-rc3
  • v0.10.0-rc2
  • v0.10.0-rc
  • v0.9.0
  • v0.9.0-rc
  • v0.8.1
  • v0.8
  • v0.8-rc
  • v0.7
  • v0.6
  • v0.5.2
  • v0.5.1
  • v0.5
  • v0.4
  • v0.3
  • v0.2.2
41 results

functionexpander.cpp

Blame
  • config.cpp 1.44 KiB
    #include <iomanip>
    #include <ios>
    #include <sstream>
    
    #include <pybind11/pybind11.h>
    #include <pybind11/stl.h>
    
    #include <arbor/version.hpp>
    
    namespace pyarb {
    
    // Returns a python dictionary that python users can use to look up
    // which options the Arbor library was configured with at compile time.
    
    pybind11::dict config() {
        pybind11::dict dict;
    #ifdef ARB_MPI_ENABLED
        dict[pybind11::str("mpi")]     = pybind11::bool_(true);
    #else
        dict[pybind11::str("mpi")]     = pybind11::bool_(false);
    #endif
    #ifdef ARB_WITH_MPI4PY
        dict[pybind11::str("mpi4py")]  = pybind11::bool_(true);
    #else
        dict[pybind11::str("mpi4py")]  = pybind11::bool_(false);
    #endif
    #ifdef ARB_WITH_GPU
        dict[pybind11::str("gpu")]     = pybind11::bool_(true);
    #else
        dict[pybind11::str("gpu")]     = pybind11::bool_(false);
    #endif
        dict[pybind11::str("version")] = pybind11::str(ARB_VERSION);
        return dict;
    }
    
    void print_config(const pybind11::dict &d) {
        std::stringstream s;
        s << "Arbor's configuration:\n";
    
        for (auto x: d) {
            s << "     "
            << std::left << std::setw(7) << x.first << ": "
            << std::right << std::setw(10) << x.second << "\n";
        }
    
        pybind11::print(s.str());
    }
    
    // Register configuration
    void register_config(pybind11::module &m) {
    
        m.def("config", &config, "Get Arbor's configuration.")
         .def("print_config", [](const pybind11::dict& d){return print_config(d);}, "Print Arbor's configuration.");
    }
    } // namespace pyarb