diff --git a/python/dune/xt/CMakeLists.txt b/python/dune/xt/CMakeLists.txt index 8e23ce48b528617cb7581dda4a7220c5ea83fc79..1065bafcc1ef907c8c88c68d6944d2549b861434 100644 --- a/python/dune/xt/CMakeLists.txt +++ b/python/dune/xt/CMakeLists.txt @@ -9,4 +9,5 @@ # René Fritze (2018) # ~~~ -dune_pybindxi_add_module(_la EXCLUDE_FROM_ALL bindings.cc) +add_subdirectory(la) + diff --git a/python/dune/xt/la/CMakeLists.txt b/python/dune/xt/la/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e23ce48b528617cb7581dda4a7220c5ea83fc79 --- /dev/null +++ b/python/dune/xt/la/CMakeLists.txt @@ -0,0 +1,12 @@ +# ~~~ +# This file is part of the dune-xt-la project: +# https://github.com/dune-community/dune-xt-la +# Copyright 2009-2018 dune-xt-la developers and contributors. All rights reserved. +# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +# or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +# with "runtime exception" (http://www.dune-project.org/license.html) +# Authors: +# René Fritze (2018) +# ~~~ + +dune_pybindxi_add_module(_la EXCLUDE_FROM_ALL bindings.cc) diff --git a/python/dune/xt/la/__init__.py b/python/dune/xt/la/__init__.py index b7579569426ced9355f99496baa39332cde4d7d2..72516bb13ddeb53032810012a71d4e9be77be153 100644 --- a/python/dune/xt/la/__init__.py +++ b/python/dune/xt/la/__init__.py @@ -10,5 +10,10 @@ # René Fritze (2018) # ~~~ -import dune.xt -from dune.xt._la import * +from dune.xt import guarded_import + +for mod_name in ( + '_la', + ): + guarded_import(globals(), 'dune.xt.la', mod_name) + diff --git a/python/dune/xt/bindings.cc b/python/dune/xt/la/bindings.cc similarity index 66% rename from python/dune/xt/bindings.cc rename to python/dune/xt/la/bindings.cc index 1a0bf7d5bf727c4eef91cb2aa26a4fdfdf66ea99..b1570ae8ee6ddbc2c7e68fb892dd1a51f449dc61 100644 --- a/python/dune/xt/bindings.cc +++ b/python/dune/xt/la/bindings.cc @@ -40,6 +40,8 @@ PYBIND11_MODULE(_la, m) using namespace pybind11::literals; namespace LA = Dune::XT::LA; + Dune::XT::Common::bindings::add_initialization(m, "dune.xt.la", "_la"); + py::module::import("dune.xt.common"); LA::bind_Backends(m); @@ -86,46 +88,4 @@ PYBIND11_MODULE(_la, m) LA::bind_Solver<LA::EigenDenseMatrix<double>>(m); LA::bind_Solver<LA::EigenRowMajorSparseMatrix<double>>(m); #endif - - m.def("_init_mpi", - [](const std::vector<std::string>& args) { - int argc = Dune::XT::Common::numeric_cast<int>(args.size()); - char** argv = Dune::XT::Common::vector_to_main_args(args); - Dune::MPIHelper::instance(argc, argv); - }, - "args"_a = std::vector<std::string>()); - - m.def("_init_logger", - [](const ssize_t max_info_level, - const ssize_t max_debug_level, - const bool enable_warnings, - const bool enable_colors, - const std::string& info_color, - const std::string& debug_color, - const std::string& warning_color) { - Dune::XT::Common::TimedLogger().create( - max_info_level, max_debug_level, enable_warnings, enable_colors, info_color, debug_color, warning_color); - }, - "max_info_level"_a = std::numeric_limits<ssize_t>::max(), - "max_debug_level"_a = std::numeric_limits<ssize_t>::max(), - "enable_warnings"_a = true, - "enable_colors"_a = true, - "info_color"_a = "blue", - "debug_color"_a = "darkgray", - "warning_color"_a = "red"); - - m.def("_test_logger", - [](const bool info, const bool debug, const bool warning) { - auto logger = Dune::XT::Common::TimedLogger().get("dune.xt.la"); - if (info) - logger.info() << "info logging works!" << std::endl; - if (debug) - logger.debug() << "debug logging works!" << std::endl; - if (warning) - logger.warn() << "warning logging works!" << std::endl; - }, - "info"_a = true, - "debug"_a = true, - "warning"_a = true); - -} // PYBIND11_PLUGIN(la) +} // PYBIND11_MODULE(...)