Skip to content

Commit

Permalink
[python] Place modules into pytriqs.applications.* package hierarchy
Browse files Browse the repository at this point in the history
* New package name is pytriqs.applications.analytical_continuation.som
* Added a workaround based on use of sitecustomize.py (Cf. TRIQS/cthyb#50)
  • Loading branch information
krivenko committed Mar 12, 2017
1 parent ef0cc9b commit d355778
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# start configuration
cmake_minimum_required(VERSION 2.8)
project(triqs_som CXX)
project(som CXX)
set(CMAKE_BUILD_TYPE Release)

# Version number of the application
Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
* Test all kernels and close #3 accordingly
* Add automatic Python tests chi_* and chi_auto_*
* Place Python module into pytriqs.applications package
* Make adding new kernels more straightforward
2 changes: 1 addition & 1 deletion benchmark/chi/som.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pytriqs.gf.local import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som

from sys import argv
from params import *
Expand Down
2 changes: 1 addition & 1 deletion benchmark/microgap/microgap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytriqs.gf.local.descriptors import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
import numpy as np
import time

Expand Down
2 changes: 1 addition & 1 deletion benchmark/semicircle/semicircle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytriqs.gf.local.descriptors import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
import numpy as np
import time

Expand Down
2 changes: 1 addition & 1 deletion benchmark/triangles/triangles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytriqs.gf.local.descriptors import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
import numpy as np
import time

Expand Down
8 changes: 8 additions & 0 deletions cmake/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def application_pytriqs_import(name,*args,**kwargs):
if name.startswith('@package_name@'):
name = name[len('@package_name@')+1:]
return builtin_import(name,*args,**kwargs)

import __builtin__
__builtin__.__import__, builtin_import = application_pytriqs_import, __builtin__.__import__

2 changes: 1 addition & 1 deletion doc/documentation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. module:: triqs_som.som
.. module:: pytriqs.applications.analytical_continuation.som

.. _documentation:

Expand Down
2 changes: 1 addition & 1 deletion doc/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytriqs.utility.mpi as mpi

# Import main SOM class
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som

n_tau = 500 # Number of tau-slices for the input GF

Expand Down
16 changes: 12 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# where will the python end up in triqs?
set(python_destination pytriqs/applications/analytical_continuation/som)

# site_customize for build
set(package_name "pytriqs.applications.analytical_continuation")
configure_file(${CMAKE_SOURCE_DIR}/cmake/sitecustomize.py ${CMAKE_CURRENT_BINARY_DIR}/sitecustomize.py @ONLY)

# make a local pytriqs copy
triqs_prepare_local_pytriqs(${CMAKE_PROJECT_NAME})
triqs_prepare_local_pytriqs(${python_destination})

# Build the python modules
triqs_python_extension_and_install(core)
triqs_python_extension(core ${python_destination})
target_link_libraries(core som_c ${TRIQS_LIBRARY_ALL})
triqs_set_rpath_for_target(core)
file(COPY parameters.rst DESTINATION .)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/include ${TRIQS_INCLUDE_ALL})

install(FILES som.py __init__.py DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${CMAKE_PROJECT_NAME})
install(TARGETS core DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${python_destination})
install(FILES som.py __init__.py DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${python_destination})

# add version file
configure_file(version.py.in version.py)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${CMAKE_PROJECT_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${python_destination})
2 changes: 1 addition & 1 deletion python/converters.hxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DO NOT EDIT
// Generated automatically using libclang using the command :
// c++2py.py ../c++/som_core.hpp --only_converters --compiler_options=-DCACHE_SIZE=0x10000 -p -m som -o som --appname triqs_som --moduledoc "The Stochastic Optimization Method"
// c++2py.py ../c++/som_core.hpp --only_converters --compiler_options=-DCACHE_SIZE=0x10000 -p -mpytriqs.applications.analytical_continuation.som.core -o core --moduledoc "The Stochastic Optimization Method"


// --- C++ Python converter for run_parameters_t
Expand Down
5 changes: 3 additions & 2 deletions python/core_desc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generated automatically using the command :
# c++2py.py ../c++/som_core.hpp --compiler_options=-DCACHE_SIZE=0x10000 -p -m som -o som --appname triqs_som --moduledoc "The Stochastic Optimization Method"
# c++2py.py ../c++/som_core.hpp --compiler_options=-DCACHE_SIZE=0x10000 -p -mpytriqs.applications.analytical_continuation.som.core -o core --moduledoc "The Stochastic Optimization Method"
from wrap_generator import *

# The module
module = module_(full_name = "core", doc = "The Stochastic Optimization Method", app_name = "triqs_som")
module = module_(full_name = "pytriqs.applications.analytical_continuation.som.core",
doc = "The Stochastic Optimization Method")

# All the triqs C++/Python modules
module.use_module('gf', 'triqs')
Expand Down
2 changes: 1 addition & 1 deletion test/python/gf_imfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytriqs.gf.local import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
from pytriqs.utility.comparison_tests import *

arch = HDFArchive('gf_imfreq.ref.h5', 'r')
Expand Down
2 changes: 1 addition & 1 deletion test/python/gf_imtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytriqs.gf.local import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
from pytriqs.utility.comparison_tests import *

arch = HDFArchive('gf_imtime.ref.h5', 'r')
Expand Down
2 changes: 1 addition & 1 deletion test/python/gf_legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytriqs.gf.local import *
from pytriqs.archive import HDFArchive
import pytriqs.utility.mpi as mpi
from triqs_som.som import Som
from pytriqs.applications.analytical_continuation.som import Som
from pytriqs.utility.comparison_tests import *

arch = HDFArchive('gf_legendre.ref.h5', 'r')
Expand Down

0 comments on commit d355778

Please sign in to comment.