diff --git a/c++/app4triqs/toto.cpp b/c++/app4triqs/app4triqs.cpp similarity index 97% rename from c++/app4triqs/toto.cpp rename to c++/app4triqs/app4triqs.cpp index 6186f754..4e9ab6ab 100644 --- a/c++/app4triqs/toto.cpp +++ b/c++/app4triqs/app4triqs.cpp @@ -1,5 +1,5 @@ #include -#include "./toto.hpp" +#include "./app4triqs.hpp" namespace app4triqs { diff --git a/c++/app4triqs/toto.hpp b/c++/app4triqs/app4triqs.hpp similarity index 81% rename from c++/app4triqs/toto.hpp rename to c++/app4triqs/app4triqs.hpp index 92353c44..88f7550d 100644 --- a/c++/app4triqs/toto.hpp +++ b/c++/app4triqs/app4triqs.hpp @@ -7,6 +7,7 @@ namespace app4triqs { * A very useful and important class * * @note A Useful note + * @include app4triqs/app4triqs.hpp */ class toto { @@ -73,26 +74,5 @@ namespace app4triqs { * @remark */ int chain(int i, int j); - - /** - * Chain digits of three integers - * - * @param i The first integer - * @param j The second integer - * @param k The third integer - * @return An integer containing the digits of both i and j - * - * @remark - */ - int chain(int i, int j, int k); - - /** - * Chain digits of one integers - * - * @param i The first integer - * - * @remark - */ - int chain(int i); } // namespace app4triqs diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index cb7dacd7..0d26b4a9 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -35,7 +35,7 @@ macro(generate_docs header_file) ) endmacro(generate_docs) -generate_docs(${PROJECT_SOURCE_DIR}/c++/app4triqs/toto.hpp) +generate_docs(${PROJECT_SOURCE_DIR}/c++/app4triqs/app4triqs.hpp) # -------------------------------------------------------- # Build & Run the C++ doc examples and capture the output diff --git a/doc/contents.rst b/doc/contents.rst index 725589f8..4f990b6a 100644 --- a/doc/contents.rst +++ b/doc/contents.rst @@ -10,4 +10,3 @@ Table of contents issues changelog about - diff --git a/doc/documentation.rst b/doc/documentation.rst index 4f59764e..3a01e533 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -36,8 +36,7 @@ Python reference manual .. automodule:: app4triqs :members: -.. autoclass:: app4triqs.toto_module.Toto +.. autoclass:: app4triqs.app4triqs_module.Toto :members: -.. autofunction:: app4triqs.toto_module.chain - +.. autofunction:: app4triqs.app4triqs_module.chain diff --git a/python/app4triqs/CMakeLists.txt b/python/app4triqs/CMakeLists.txt index 6ec57050..7b8b47dd 100644 --- a/python/app4triqs/CMakeLists.txt +++ b/python/app4triqs/CMakeLists.txt @@ -1,7 +1,3 @@ -# Build the python module -add_cpp2py_module(toto_module) -target_link_libraries(toto_module app4triqs_c) - # Configure the version configure_file(version.py.in version.py) @@ -13,7 +9,14 @@ foreach(file ${python_sources}) configure_file(${file} ${file} COPYONLY) endforeach() -# Install python module to proper location +# Build any python modules +foreach(gen ${wrap_generators}) + string(REPLACE "_desc.py" "" module_name ${gen}) + add_cpp2py_module(${module_name}) + target_link_libraries(${module_name} app4triqs_c) +endforeach() + +# Install python modules to proper location set(PYTHON_LIB_DEST ${TRIQS_PYTHON_LIB_DEST_ROOT}/app4triqs) get_property(CPP2PY_MODULES_LIST GLOBAL PROPERTY CPP2PY_MODULES_LIST) install(TARGETS ${CPP2PY_MODULES_LIST} DESTINATION ${PYTHON_LIB_DEST}) diff --git a/python/app4triqs/__init__.py b/python/app4triqs/__init__.py index 591133ee..2fabf532 100644 --- a/python/app4triqs/__init__.py +++ b/python/app4triqs/__init__.py @@ -25,6 +25,6 @@ r""" DOC """ -from toto_module import Toto, chain +from app4triqs_module import Toto, chain __all__ = ['Toto', 'chain'] diff --git a/python/app4triqs/toto_module_desc.py b/python/app4triqs/app4triqs_module_desc.py similarity index 78% rename from python/app4triqs/toto_module_desc.py rename to python/app4triqs/app4triqs_module_desc.py index e7eea446..74872947 100644 --- a/python/app4triqs/toto_module_desc.py +++ b/python/app4triqs/app4triqs_module_desc.py @@ -1,15 +1,14 @@ # Generated automatically using the command : -# c++2py ../../c++/app4triqs/toto.hpp -p --members_read_only -N app4triqs -a app4triqs -m toto_module -o toto_module -C pytriqs --cxxflags="-std=c++17 " +# c++2py ../../c++/app4triqs/app4triqs.hpp -p --members_read_only -N app4triqs -a app4triqs -m app4triqs_module -o app4triqs_module -C pytriqs --cxxflags="-std=c++17 " from cpp2py.wrap_generator import * # The module -module = module_(full_name = "toto_module", doc = "", app_name = "app4triqs") +module = module_(full_name = "app4triqs_module", doc = r"", app_name = "app4triqs") # Imports -module.add_imports(*[]) # Add here all includes -module.add_include("app4triqs/toto.hpp") +module.add_include("app4triqs/app4triqs.hpp") # Add here anything to add in the C++ code at the start, e.g. namespace using module.add_preamble(""" @@ -54,14 +53,12 @@ c.add_method("""std::string hdf5_scheme ()""", c.add_property(name = "i", getter = cfunction("int get_i ()"), - doc = """Simple accessor""") + doc = r"""Simple accessor""") module.add_class(c) module.add_function ("int app4triqs::chain (int i, int j)", doc = r"""Chain digits of two integers - Chain the decimal digits of two integers i and j, and return the result - Parameters ---------- i diff --git a/test/c++/toto.cpp b/test/c++/basic.cpp similarity index 92% rename from test/c++/toto.cpp rename to test/c++/basic.cpp index a94b4946..f8866fa7 100644 --- a/test/c++/toto.cpp +++ b/test/c++/basic.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace app4triqs; diff --git a/test/python/Toto.py b/test/python/Basic.py similarity index 78% rename from test/python/Toto.py rename to test/python/Basic.py index 744235f9..9576522d 100644 --- a/test/python/Toto.py +++ b/test/python/Basic.py @@ -2,7 +2,7 @@ import unittest -from app4triqs import Toto +from app4triqs import Toto, chain from pytriqs.archive import * from pytriqs.utility import mpi @@ -37,6 +37,14 @@ class test_toto(unittest.TestCase): self.assertEqual(a, Toto(1)) +class test_chain(unittest.TestCase): + + def test_chain(self): + + i = 111 + j = 222 + ij = chain(i,j) + self.assertEqual(ij, 111222) if __name__ == '__main__': unittest.main() diff --git a/test/python/CMakeLists.txt b/test/python/CMakeLists.txt index e4a2c0c6..da8f6dcb 100644 --- a/test/python/CMakeLists.txt +++ b/test/python/CMakeLists.txt @@ -5,11 +5,11 @@ foreach(file ${all_h5_ref_files}) endforeach() # List of all tests -set(all_tests Toto chain) +set(all_tests Basic) foreach(test ${all_tests}) get_filename_component(test_name ${test} NAME_WE) get_filename_component(test_dir ${test} DIRECTORY) - add_test(NAME ${test_name} COMMAND ${TRIQS_PYTHON_INTERPRETER} ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir}/${test_name}.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir}) - set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD}) + add_test(NAME Py_${test_name} COMMAND ${TRIQS_PYTHON_INTERPRETER} ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir}/${test_name}.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir}) + set_property(TEST Py_${test_name} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD}) endforeach() diff --git a/test/python/chain.py b/test/python/chain.py deleted file mode 100644 index e0dcfc8e..00000000 --- a/test/python/chain.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -import unittest - -from app4triqs import chain - -class test_chain(unittest.TestCase): - - def test_chain(self): - - i = 111 - j = 222 - ij = chain(i,j) - self.assertEqual(ij, 111222) - -if __name__ == '__main__': - unittest.main()