diff --git a/.ci_support/run_docker_linux.sh b/.ci_support/run_docker_linux.sh index b4612c4..77ed331 100755 --- a/.ci_support/run_docker_linux.sh +++ b/.ci_support/run_docker_linux.sh @@ -6,19 +6,18 @@ cd /tmp mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=~/.local \ -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=32 \ - -DCMAKE_CXX_FLAGS="-Wall -Wextra -D_GLIBCXX_ASSERTIONS" \ - -DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter" \ + -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Wshadow -Werror -D_GLIBCXX_ASSERTIONS" \ + -DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter -Wno-shadow" \ -DSPHINX_FLAGS="-W -T -j4" \ /io make install make tests ctest --output-on-failure --timeout 100 ${MAKEFLAGS} -exit 0 uid=$1 gid=$2 if test -n "${uid}" -a -n "${gid}" then - sudo cp -r ~/.local/share/*/doc/html /io + sudo cp -r ~/.local/share/doc/*/html /io sudo chown -R ${uid}:${gid} /io/html fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09b4c9c..4cd5203 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,8 @@ name: Build -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: jobs: linux: runs-on: ubuntu-latest @@ -12,7 +15,6 @@ jobs: - name: Upload if: ${{ github.ref == 'refs/heads/master' }} run: | - exit 0 git clone --depth 1 https://${{ secrets.GH_TOKEN }}@github.com/openturns/openturns.github.io.git /tmp/io mkdir -p /tmp/io/otmixmod/master cp -r html/* /tmp/io/otmixmod/master diff --git a/CMakeLists.txt b/CMakeLists.txt index 101767f..6e746e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required (VERSION 3.13) -option ( BUILD_PYTHON "Build the python module for the library" ON ) -option ( BUILD_DOC "Build the documentation" ON ) -option ( BUILD_SHARED_LIBS "Build shared libraries" ON ) +option (BUILD_PYTHON "Build the python module for the library" ON) +option (USE_SPHINX "Use sphinx for documentation" ON) +option (BUILD_SHARED_LIBS "Build shared libraries" ON) # By default, build in Release mode. Must appear before project() command set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type") @@ -67,7 +67,8 @@ if (BUILD_PYTHON) endif () if (Python_FOUND) - #include (FindPythonModule) + include (FindPythonModule) + find_python_module (matplotlib) if (NOT TARGET Python::Module) include (TargetLinkLibrariesWithDynamicLookup) endif () @@ -75,11 +76,12 @@ if (BUILD_PYTHON) if (USE_SPHINX) find_program (SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder (sphinx-doc.org)") find_python_module (numpydoc) - if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND) - find_python_module (sphinx 1.1) + find_python_module (sphinx_gallery) + if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND AND SPHINX_GALLERY_FOUND AND MATPLOTLIB_FOUND) + find_python_module (sphinx) endif () if (NOT SPHINX_FOUND) - message (STATUS "Disabling documentation (need sphinx/pandoc/numpydoc)") + message (STATUS "Disabling documentation (need sphinx/pandoc/numpydoc/sphinx-gallery/matplotlib)") endif () endif () @@ -123,11 +125,11 @@ macro (ot_install_swig_file FILENAME) install (FILES ${FILENAME} DESTINATION ${OTMIXMOD_SWIG_INCLUDE_DIRS}) endmacro () -set ( INTERNAL_INCLUDE_DIRS "" CACHE INTERNAL "List of directories with header files needed for build" ) -macro ( ot_add_current_dir_to_include_dirs ) - set ( inc_dirs ${INTERNAL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) - set ( INTERNAL_INCLUDE_DIRS ${inc_dirs} CACHE INTERNAL "List of directories with header files needed for build" ) -endmacro ( ot_add_current_dir_to_include_dirs ) +set (INTERNAL_INCLUDE_DIRS "" CACHE INTERNAL "List of directories with header files needed for build") +macro (ot_add_current_dir_to_include_dirs) + set (inc_dirs ${INTERNAL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) + set (INTERNAL_INCLUDE_DIRS ${inc_dirs} CACHE INTERNAL "List of directories with header files needed for build") +endmacro () set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} ) @@ -162,9 +164,6 @@ if (Python_FOUND AND SWIG_FOUND) add_dependencies (installcheck pyinstallcheck) endif () -if (BUILD_DOC) - add_subdirectory (doc) -endif () # uninstall target configure_file ( diff --git a/cmake/FindPythonModule.cmake b/cmake/FindPythonModule.cmake new file mode 100644 index 0000000..aaa56f0 --- /dev/null +++ b/cmake/FindPythonModule.cmake @@ -0,0 +1,83 @@ +# - Macro to find a python module +# +# Usage: +# include (FindPythonModule) +# find_python_module (module [VERSION] [REQUIRED]) +# +# The following variables are defined: +# MODULE_FOUND - true if found +# MODULE_LOCATION - directory of the module, or it's library file if binary module +# MODULE_VERSION_STRING - module version, if available through __version__ +# +#============================================================================= +# Copyright 2005-2023 Airbus-EDF-IMACS-ONERA-Phimeca +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +macro (find_python_module module) + + string (TOUPPER ${module} module_upper) + if (NOT ${module_upper}_FOUND) + + # parse arguments + set (${module}_FIND_OPTIONAL TRUE) + if (${ARGC} EQUAL 2) + if (${ARGV1} MATCHES REQUIRED) + set (${module}_FIND_OPTIONAL FALSE) + else () + set (${module}_FIND_VERSION ${ARGV1}) + endif () + elseif (${ARGC} EQUAL 3) + if (${ARGV2} MATCHES REQUIRED) + set (${module}_FIND_OPTIONAL FALSE) + endif () + set (${module}_FIND_VERSION ${ARGV1}) + endif () + + # A module's location is usually a directory, but for binary modules it's a .so file. + execute_process (COMMAND "${Python_EXECUTABLE}" "-c" + "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_location + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${module}_status) + set (${module_upper}_LOCATION ${_${module}_location} + CACHE STRING "Location of Python module ${module}") + # retrieve version + execute_process (COMMAND "${Python_EXECUTABLE}" "-c" "import ${module}; print(${module}.__version__)" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_version + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + set (_${module_upper}_VERSION_MATCH TRUE) + if (NOT _${module}_status) + set (${module_upper}_VERSION_STRING ${_${module}_version}) + if (${module}_FIND_VERSION) + if (${module}_FIND_VERSION VERSION_GREATER ${module_upper}_VERSION_STRING) + set (_${module_upper}_VERSION_MATCH FALSE) + endif () + endif () + mark_as_advanced (${module_upper}_VERSION_STRING) + endif () + endif () + + # https://gitlab.kitware.com/cmake/cmake/-/issues/21505 + if (CMAKE_VERSION VERSION_EQUAL 3.19.1) + set (CMAKE_FIND_PACKAGE_NAME "${module}") + endif () + find_package_handle_standard_args (${module} REQUIRED_VARS ${module_upper}_LOCATION + ${module}_FIND_OPTIONAL + _${module_upper}_VERSION_MATCH + VERSION_VAR ${module_upper}_VERSION_STRING + ) + mark_as_advanced (${module_upper}_LOCATION) + endif (NOT ${module_upper}_FOUND) +endmacro (find_python_module) diff --git a/cmake/UseLATEX.cmake b/cmake/UseLATEX.cmake deleted file mode 100644 index 8905a8b..0000000 --- a/cmake/UseLATEX.cmake +++ /dev/null @@ -1,1393 +0,0 @@ -# File: UseLATEX.cmake -# CMAKE commands to actually use the LaTeX compiler -# Version: 1.10.5 -# Author: Kenneth Moreland -# -# Copyright 2004 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the -# U.S. Government. Redistribution and use in source and binary forms, with -# or without modification, are permitted provided that this Notice and any -# statement of authorship are reproduced on all copies. -# -# The following function is defined: -# -# ADD_LATEX_DOCUMENT( -# [BIBFILES ] -# [INPUTS ] -# [IMAGE_DIRS] -# [IMAGES] -# [CONFIGURE] -# [DEPENDS] -# [MULTIBIB_NEWCITES] -# [USE_INDEX] [USE_GLOSSARY] [USE_NOMENCL] -# [DEFAULT_PDF] [DEFAULT_SAFEPDF] [DEFAULT_PS] [NO_DEFAULT] -# [MANGLE_TARGET_NAMES]) -# Adds targets that compile . The latex output is placed -# in LATEX_OUTPUT_PATH or CMAKE_CURRENT_BINARY_DIR if the former is -# not set. The latex program is picky about where files are located, -# so all input files are copied from the source directory to the -# output directory. This includes the target tex file, any tex file -# listed with the INPUTS option, the bibliography files listed with -# the BIBFILES option, and any .cls, .bst, and .clo files found in -# the current source directory. Images found in the IMAGE_DIRS -# directories or listed by IMAGES are also copied to the output -# directory and coverted to an appropriate format if necessary. Any -# tex files also listed with the CONFIGURE option are also processed -# with the CMake CONFIGURE_FILE command (with the @ONLY flag). Any -# file listed in CONFIGURE but not the target tex file or listed with -# INPUTS has no effect. DEPENDS can be used to specify generated files -# that are needed to compile the latex target. -# -# The following targets are made: -# dvi: Makes .dvi -# pdf: Makes .pdf using pdflatex. -# safepdf: Makes .pdf using ps2pdf. If using the default -# program arguments, this will ensure all fonts are -# embedded and no lossy compression has been performed -# on images. -# ps: Makes .ps -# html: Makes .html -# auxclean: Deletes .aux and other auxiliary files. -# This is sometimes necessary if a LaTeX error occurs -# and writes a bad aux file. Unlike the regular clean -# target, it does not delete other input files, such as -# converted images, to save time on the rebuild. -# -# The dvi target is added to the ALL. That is, it will be the target -# built by default. If the DEFAULT_PDF argument is given, then the -# pdf target will be the default instead of dvi. Likewise, -# DEFAULT_SAFEPDF sets the default target to safepdf. If NO_DEFAULT -# is specified, then no target will be added to ALL, which is -# convenient when including LaTeX documentation with something else. -# -# If the argument MANGLE_TARGET_NAMES is given, then each of the -# target names above will be mangled with the name. This -# is to make the targets unique if ADD_LATEX_DOCUMENT is called for -# multiple documents. If the argument USE_INDEX is given, then -# commands to build an index are made. If the argument USE_GLOSSARY -# is given, then commands to build a glossary are made. If the -# argument MULTIBIB_NEWCITES is given, then additional bibtex calls -# are added to the build to support the extra auxiliary files created -# with the \newcite command in the multibib package. -# -# History: -# -# 1.10.5 Fix for Window's convert check (thanks to Martin Baute). -# -# 1.10.4 Copy font files to binary directory for packages that come with -# their own fonts. -# -# 1.10.3 Check for Windows version of convert being used instead of -# ImageMagick's version (thanks to Martin Baute). -# -# 1.10.2 Use htlatex as a fallback when latex2html is not available (thanks -# to Tomasz Grzegurzko). -# -# 1.10.1 Make convert program mandatory only if actually used (thanks to -# Julien Schueller). -# -# 1.10.0 Added NO_DEFAULT and DEFAULT_PS options. -# Fixed issue with cleaning files for LaTeX documents originating in -# a subdirectory. -# -# 1.9.6 Fixed problem with LATEX_SMALL_IMAGES. -# Strengthened check to make sure the output directory does not contain -# the source files. -# -# 1.9.5 Add support for image types not directly supported by either latex -# or pdflatex. (Thanks to Jorge Gerardo Pena Pastor for SVG support.) -# -# 1.9.4 Fix issues with filenames containing multiple periods. -# -# 1.9.3 Hide some variables that are now cached but should not show up in -# the ccmake list of variables. -# -# 1.9.2 Changed MACRO declarations to FUNCTION declarations. The better -# FUNCTION scoping will hopefully avoid some common but subtle bugs. -# This implicitly increases the minimum CMake version to 4.6 (although -# I honestly only test it with the latest 4.8 version). -# -# Since we are updating the minimum CMake version, I'm going to start -# using the builtin LIST commands that are now available. -# -# Favor using pdftops from the Poppler package to convert from pdf to -# eps. It does a much better job than ImageMagick or ghostscript. -# -# 1.9.1 Fixed typo that caused the LATEX_SMALL_IMAGES option to fail to -# activate. -# -# 1.9.0 Add support for the multibib package (thanks to Antonio LaTorre). -# -# 1.8.2 Fix corner case when an argument name was also a variable containing -# the text of an argument. In this case, the CMake IF was matching -# the argument text with the contents of the variable with the same -# argument name. -# -# 1.8.1 Fix problem where ps2pdf was not getting the appropriate arguments. -# -# 1.8.0 Add support for synctex. -# -# 1.7.7 Support calling xindy when making glossaries. -# -# Improved make clean support. -# -# 1.7.6 Add support for the nomencl package (thanks to Myles English). -# -# 1.7.5 Fix issue with bibfiles being copied two different ways, which causes -# Problems with dependencies (thanks to Edwin van Leeuwen). -# -# 1.7.4 Added the DEFAULT_SAFEPDF option (thanks to Raymond Wan). -# -# Added warnings when image directories are not found (and were -# probably not given relative to the source directory). -# -# 1.7.3 Fix some issues with interactions between makeglossaries and bibtex -# (thanks to Mark de Wever). -# -# 1.7.2 Use ps2pdf to convert eps to pdf to get around the problem with -# ImageMagick dropping the bounding box (thanks to Lukasz Lis). -# -# 1.7.1 Fixed some dependency issues. -# -# 1.7.0 Added DEPENDS options (thanks to Theodore Papadopoulo). -# -# 1.6.1 Ported the makeglossaries command to CMake and embedded the port -# into UseLATEX.cmake. -# -# 1.6.0 Allow the use of the makeglossaries command. Thanks to Oystein -# S. Haaland for the patch. -# -# 1.5.0 Allow any type of file in the INPUTS lists, not just tex file -# (suggested by Eric Noulard). As a consequence, the ability to -# specify tex files without the .tex extension is removed. The removed -# function is of dubious value anyway. -# -# When copying input files, skip over any file that exists in the -# binary directory but does not exist in the source directory with the -# assumption that these files were added by some other mechanism. I -# find this useful when creating large documents with multiple -# chapters that I want to build separately (for speed) as I work on -# them. I use the same boilerplate as the starting point for all -# and just copy it with different configurations. This was what the -# separate ADD_LATEX_DOCUMENT method was supposed to originally be for. -# Since its external use is pretty much deprecated, I removed that -# documentation. -# -# 1.4.1 Copy .sty files along with the other class and package files. -# -# 1.4.0 Added a MANGLE_TARGET_NAMES option that will mangle the target names. -# -# Fixed problem with copying bib files that became apparent with -# CMake 2.4. -# -# 1.3.0 Added a LATEX_OUTPUT_PATH variable that allows you or the user to -# specify where the built latex documents to go. This is especially -# handy if you want to do in-source builds. -# -# Removed the ADD_LATEX_IMAGES macro and absorbed the functionality -# into ADD_LATEX_DOCUMENT. The old interface was always kind of -# clunky anyway since you had to specify the image directory in both -# places. It also made supporting LATEX_OUTPUT_PATH problematic. -# -# Added support for jpeg files. -# -# 1.2.0 Changed the configuration options yet again. Removed the NO_CONFIGURE -# Replaced it with a CONFIGURE option that lists input files for which -# configure should be run. -# -# The pdf target no longer depends on the dvi target. This allows you -# to build latex documents that require pdflatex. Also added an option -# to make the pdf target the default one. -# -# 1.1.1 Added the NO_CONFIGURE option. The @ character can be used when -# specifying table column separators. If two or more are used, then -# will incorrectly substitute them. -# -# 1.1.0 Added ability include multiple bib files. Added ability to do copy -# sub-tex files for multipart tex files. -# -# 1.0.0 If both ps and pdf type images exist, just copy the one that -# matches the current render mode. Replaced a bunch of STRING -# commands with GET_FILENAME_COMPONENT commands that were made to do -# the desired function. -# -# 0.4.0 First version posted to CMake Wiki. -# - -############################################################################# -# Find the location of myself while originally executing. If you do this -# inside of a macro, it will recode where the macro was invoked. -############################################################################# -SET(LATEX_USE_LATEX_LOCATION ${CMAKE_CURRENT_LIST_FILE} - CACHE INTERNAL "Location of UseLATEX.cmake file." FORCE - ) - -############################################################################# -# Generic helper functions -############################################################################# - -FUNCTION(LATEX_LIST_CONTAINS var value) - SET(input_list ${ARGN}) - LIST(FIND input_list "${value}" index) - IF (index GREATER -1) - SET(${var} TRUE PARENT_SCOPE) - ELSE (index GREATER -1) - SET(${var} PARENT_SCOPE) - ENDIF (index GREATER -1) -ENDFUNCTION(LATEX_LIST_CONTAINS) - -# Parse function arguments. Variables containing the results are placed -# in the global scope for historical reasons. -FUNCTION(LATEX_PARSE_ARGUMENTS prefix arg_names option_names) - SET(DEFAULT_ARGS) - FOREACH(arg_name ${arg_names}) - SET(${prefix}_${arg_name} CACHE INTERNAL "${prefix} argument" FORCE) - ENDFOREACH(arg_name) - FOREACH(option ${option_names}) - SET(${prefix}_${option} CACHE INTERNAL "${prefix} option" FORCE) - ENDFOREACH(option) - - SET(current_arg_name DEFAULT_ARGS) - SET(current_arg_list) - FOREACH(arg ${ARGN}) - LATEX_LIST_CONTAINS(is_arg_name ${arg} ${arg_names}) - LATEX_LIST_CONTAINS(is_option ${arg} ${option_names}) - IF (is_arg_name) - SET(${prefix}_${current_arg_name} ${current_arg_list} - CACHE INTERNAL "${prefix} argument" FORCE) - SET(current_arg_name ${arg}) - SET(current_arg_list) - ELSEIF (is_option) - SET(${prefix}_${arg} TRUE CACHE INTERNAL "${prefix} option" FORCE) - ELSE (is_arg_name) - SET(current_arg_list ${current_arg_list} ${arg}) - ENDIF (is_arg_name) - ENDFOREACH(arg) - SET(${prefix}_${current_arg_name} ${current_arg_list} - CACHE INTERNAL "${prefix} argument" FORCE) -ENDFUNCTION(LATEX_PARSE_ARGUMENTS) - -# Match the contents of a file to a regular expression. -FUNCTION(LATEX_FILE_MATCH variable filename regexp default) - # The FILE STRINGS command would be a bit better, but I'm not totally sure - # the match will always be to a whole line, and I don't want to break things. - FILE(READ ${filename} file_contents) - STRING(REGEX MATCHALL "${regexp}" - match_result ${file_contents} - ) - IF (match_result) - SET(${variable} "${match_result}" PARENT_SCOPE) - ELSE (match_result) - SET(${variable} "${default}" PARENT_SCOPE) - ENDIF (match_result) -ENDFUNCTION(LATEX_FILE_MATCH) - -# A version of GET_FILENAME_COMPONENT that treats extensions after the last -# period rather than the first. To the best of my knowledge, all filenames -# typically used by LaTeX, including image files, have small extensions -# after the last dot. -FUNCTION(LATEX_GET_FILENAME_COMPONENT varname filename type) - SET(result) - IF ("${type}" STREQUAL "NAME_WE") - GET_FILENAME_COMPONENT(name ${filename} NAME) - STRING(REGEX REPLACE "\\.[^.]*\$" "" result "${name}") - ELSEIF ("${type}" STREQUAL "EXT") - GET_FILENAME_COMPONENT(name ${filename} NAME) - STRING(REGEX MATCH "\\.[^.]*\$" result "${name}") - ELSE ("${type}" STREQUAL "NAME_WE") - GET_FILENAME_COMPONENT(result ${filename} ${type}) - ENDIF ("${type}" STREQUAL "NAME_WE") - SET(${varname} "${result}" PARENT_SCOPE) -ENDFUNCTION(LATEX_GET_FILENAME_COMPONENT) - -############################################################################# -# Functions that perform processing during a LaTeX build. -############################################################################# -FUNCTION(LATEX_MAKEGLOSSARIES) - # This is really a bare bones port of the makeglossaries perl script into - # CMake scripting. - MESSAGE("**************************** In makeglossaries") - IF (NOT LATEX_TARGET) - MESSAGE(SEND_ERROR "Need to define LATEX_TARGET") - ENDIF (NOT LATEX_TARGET) - - SET(aux_file ${LATEX_TARGET}.aux) - - IF (NOT EXISTS ${aux_file}) - MESSAGE(SEND_ERROR "${aux_file} does not exist. Run latex on your target file.") - ENDIF (NOT EXISTS ${aux_file}) - - LATEX_FILE_MATCH(newglossary_lines ${aux_file} - "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" - "@newglossary{main}{glg}{gls}{glo}" - ) - - LATEX_FILE_MATCH(istfile_line ${aux_file} - "@istfilename[ \t]*{([^}]*)}" - "@istfilename{${LATEX_TARGET}.ist}" - ) - STRING(REGEX REPLACE "@istfilename[ \t]*{([^}]*)}" "\\1" - istfile ${istfile_line} - ) - - STRING(REGEX MATCH ".*\\.xdy" use_xindy "${istfile}") - IF (use_xindy) - MESSAGE("*************** Using xindy") - IF (NOT XINDY_COMPILER) - MESSAGE(SEND_ERROR "Need to define XINDY_COMPILER") - ENDIF (NOT XINDY_COMPILER) - ELSE (use_xindy) - MESSAGE("*************** Using makeindex") - IF (NOT MAKEINDEX_COMPILER) - MESSAGE(SEND_ERROR "Need to define MAKEINDEX_COMPILER") - ENDIF (NOT MAKEINDEX_COMPILER) - ENDIF (use_xindy) - - FOREACH(newglossary ${newglossary_lines}) - STRING(REGEX REPLACE - "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" - "\\1" glossary_name ${newglossary} - ) - STRING(REGEX REPLACE - "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" - "${LATEX_TARGET}.\\2" glossary_log ${newglossary} - ) - STRING(REGEX REPLACE - "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" - "${LATEX_TARGET}.\\3" glossary_out ${newglossary} - ) - STRING(REGEX REPLACE - "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" - "${LATEX_TARGET}.\\4" glossary_in ${newglossary} - ) - - IF (use_xindy) - LATEX_FILE_MATCH(xdylanguage_line ${aux_file} - "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}" - "@xdylanguage{${glossary_name}}{english}" - ) - STRING(REGEX REPLACE - "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}" - "\\1" - language - ${xdylanguage_line} - ) - # What crazy person makes a LaTeX index generater that uses different - # identifiers for language than babel (or at least does not support - # the old ones)? - IF (${language} STREQUAL "frenchb") - SET(language "french") - ELSEIF (${language} MATCHES "^n?germanb?$") - SET(language "german") - ELSEIF (${language} STREQUAL "magyar") - SET(language "hungarian") - ELSEIF (${language} STREQUAL "lsorbian") - SET(language "lower-sorbian") - ELSEIF (${language} STREQUAL "norsk") - SET(language "norwegian") - ELSEIF (${language} STREQUAL "portuges") - SET(language "portuguese") - ELSEIF (${language} STREQUAL "russianb") - SET(language "russian") - ELSEIF (${language} STREQUAL "slovene") - SET(language "slovenian") - ELSEIF (${language} STREQUAL "ukraineb") - SET(language "ukrainian") - ELSEIF (${language} STREQUAL "usorbian") - SET(language "upper-sorbian") - ENDIF (${language} STREQUAL "frenchb") - IF (language) - SET(language_flags "-L ${language}") - ELSE (language) - SET(language_flags "") - ENDIF (language) - - LATEX_FILE_MATCH(codepage_line ${aux_file} - "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}" - "@gls@codepage{${glossary_name}}{utf}" - ) - STRING(REGEX REPLACE - "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}" - "\\1" - codepage - ${codepage_line} - ) - IF (codepage) - SET(codepage_flags "-C ${codepage}") - ELSE (codepage) - # Ideally, we would check that the language is compatible with the - # default codepage, but I'm hoping that distributions will be smart - # enough to specify their own codepage. I know, it's asking a lot. - SET(codepage_flags "") - ENDIF (codepage) - - MESSAGE("${XINDY_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} ${language_flags} ${codepage_flags} -I xindy -M ${glossary_name} -t ${glossary_log} -o ${glossary_out} ${glossary_in}" - ) - EXEC_PROGRAM(${XINDY_COMPILER} - ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} - ${language_flags} - ${codepage_flags} - -I xindy - -M ${glossary_name} - -t ${glossary_log} - -o ${glossary_out} - ${glossary_in} - OUTPUT_VARIABLE xindy_output - ) - MESSAGE("${xindy_output}") - - # So, it is possible (perhaps common?) for aux files to specify a - # language and codepage that are incompatible with each other. Check - # for that condition, and if it happens run again with the default - # codepage. - IF ("${xindy_output}" MATCHES "^Cannot locate xindy module for language (.+) in codepage (.+)\\.$") - MESSAGE("*************** Retrying xindy with default codepage.") - EXEC_PROGRAM(${XINDY_COMPILER} - ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} - ${language_flags} - -I xindy - -M ${glossary_name} - -t ${glossary_log} - -o ${glossary_out} - ${glossary_in} - ) - ENDIF ("${xindy_output}" MATCHES "^Cannot locate xindy module for language (.+) in codepage (.+)\\.$") - - ELSE (use_xindy) - MESSAGE("${MAKEINDEX_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in}") - EXEC_PROGRAM(${MAKEINDEX_COMPILER} ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} - -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in} - ) - ENDIF (use_xindy) - - ENDFOREACH(newglossary) -ENDFUNCTION(LATEX_MAKEGLOSSARIES) - -FUNCTION(LATEX_MAKENOMENCLATURE) - MESSAGE("**************************** In makenomenclature") - IF (NOT LATEX_TARGET) - MESSAGE(SEND_ERROR "Need to define LATEX_TARGET") - ENDIF (NOT LATEX_TARGET) - - IF (NOT MAKEINDEX_COMPILER) - MESSAGE(SEND_ERROR "Need to define MAKEINDEX_COMPILER") - ENDIF (NOT MAKEINDEX_COMPILER) - - SET(nomencl_out ${LATEX_TARGET}.nls) - SET(nomencl_in ${LATEX_TARGET}.nlo) - - EXEC_PROGRAM(${MAKEINDEX_COMPILER} ARGS ${MAKENOMENCLATURE_COMPILER_FLAGS} - ${nomencl_in} -s "nomencl.ist" -o ${nomencl_out} - ) -ENDFUNCTION(LATEX_MAKENOMENCLATURE) - -FUNCTION(LATEX_CORRECT_SYNCTEX) - MESSAGE("**************************** In correct SyncTeX") - IF (NOT LATEX_TARGET) - MESSAGE(SEND_ERROR "Need to define LATEX_TARGET") - ENDIF (NOT LATEX_TARGET) - - IF (NOT GZIP) - MESSAGE(SEND_ERROR "Need to define GZIP") - ENDIF (NOT GZIP) - - IF (NOT LATEX_SOURCE_DIRECTORY) - MESSAGE(SEND_ERROR "Need to define LATEX_SOURCE_DIRECTORY") - ENDIF (NOT LATEX_SOURCE_DIRECTORY) - - IF (NOT LATEX_BINARY_DIRECTORY) - MESSAGE(SEND_ERROR "Need to define LATEX_BINARY_DIRECTORY") - ENDIF (NOT LATEX_BINARY_DIRECTORY) - - SET(synctex_file ${LATEX_BINARY_DIRECTORY}/${LATEX_TARGET}.synctex) - SET(synctex_file_gz ${synctex_file}.gz) - - IF (EXISTS ${synctex_file_gz}) - - MESSAGE("Making backup of synctex file.") - CONFIGURE_FILE(${synctex_file_gz} ${synctex_file}.bak.gz COPYONLY) - - MESSAGE("Uncompressing synctex file.") - EXEC_PROGRAM(${GZIP} - ARGS --decompress ${synctex_file_gz} - ) - - MESSAGE("Reading synctex file.") - FILE(READ ${synctex_file} synctex_data) - - MESSAGE("Replacing relative with absolute paths.") - STRING(REGEX REPLACE - "(Input:[0-9]+:)([^/\n][^\n]*)" - "\\1${LATEX_SOURCE_DIRECTORY}/\\2" - synctex_data - "${synctex_data}" - ) - - MESSAGE("Writing synctex file.") - FILE(WRITE ${synctex_file} "${synctex_data}") - - MESSAGE("Compressing synctex file.") - EXEC_PROGRAM(${GZIP} - ARGS ${synctex_file} - ) - - ELSE (EXISTS ${synctex_file_gz}) - - MESSAGE(SEND_ERROR "File ${synctex_file_gz} not found. Perhaps synctex is not supported by your LaTeX compiler.") - - ENDIF (EXISTS ${synctex_file_gz}) - -ENDFUNCTION(LATEX_CORRECT_SYNCTEX) - -############################################################################# -# Helper functions for establishing LaTeX build. -############################################################################# - -FUNCTION(LATEX_NEEDIT VAR NAME) - IF (NOT ${VAR}) - MESSAGE(SEND_ERROR "I need the ${NAME} command.") - ENDIF(NOT ${VAR}) -ENDFUNCTION(LATEX_NEEDIT) - -FUNCTION(LATEX_WANTIT VAR NAME) - IF (NOT ${VAR}) - MESSAGE(STATUS "I could not find the ${NAME} command.") - ENDIF(NOT ${VAR}) -ENDFUNCTION(LATEX_WANTIT) - -FUNCTION(LATEX_SETUP_VARIABLES) - SET(LATEX_OUTPUT_PATH "${LATEX_OUTPUT_PATH}" - CACHE PATH "If non empty, specifies the location to place LaTeX output." - ) - - FIND_PACKAGE(LATEX) - - FIND_PROGRAM(XINDY_COMPILER - NAME xindy - PATHS ${MIKTEX_BINARY_PATH} /usr/bin - ) - - FIND_PACKAGE(UnixCommands) - - FIND_PROGRAM(PDFTOPS_CONVERTER - NAMES pdftops - DOC "The pdf to ps converter program from the Poppler package." - ) - - MARK_AS_ADVANCED(CLEAR - LATEX_COMPILER - PDFLATEX_COMPILER - BIBTEX_COMPILER - MAKEINDEX_COMPILER - XINDY_COMPILER - DVIPS_CONVERTER - PS2PDF_CONVERTER - PDFTOPS_CONVERTER - LATEX2HTML_CONVERTER - ) - - LATEX_NEEDIT(LATEX_COMPILER latex) - LATEX_WANTIT(PDFLATEX_COMPILER pdflatex) - LATEX_NEEDIT(BIBTEX_COMPILER bibtex) - LATEX_NEEDIT(MAKEINDEX_COMPILER makeindex) - LATEX_WANTIT(DVIPS_CONVERTER dvips) - LATEX_WANTIT(PS2PDF_CONVERTER ps2pdf) - LATEX_WANTIT(PDFTOPS_CONVERTER pdftops) - # MiKTeX calls latex2html htlatex - IF (NOT ${LATEX2HTML_CONVERTER}) - FIND_PROGRAM(HTLATEX_CONVERTER - NAMES htlatex - PATHS ${MIKTEX_BINARY_PATH} - /usr/bin - ) - IF (HTLATEX_CONVERTER) - SET(USING_HTLATEX TRUE CACHE INTERNAL "True when using MiKTeX htlatex instead of latex2html" FORCE) - SET(LATEX2HTML_CONVERTER ${HTLATEX_CONVERTER} - CACHE FILEPATH "htlatex taking the place of latex2html" FORCE) - ELSE (HTLATEX_CONVERTER) - SET(USING_HTLATEX FALSE CACHE INTERNAL "True when using MiKTeX htlatex instead of latex2html" FORCE) - ENDIF (HTLATEX_CONVERTER) - ENDIF (NOT ${LATEX2HTML_CONVERTER}) - LATEX_WANTIT(LATEX2HTML_CONVERTER latex2html) - - SET(LATEX_COMPILER_FLAGS "-interaction=nonstopmode" - CACHE STRING "Flags passed to latex.") - SET(PDFLATEX_COMPILER_FLAGS ${LATEX_COMPILER_FLAGS} - CACHE STRING "Flags passed to pdflatex.") - SET(LATEX_SYNCTEX_FLAGS "-synctex=1" - CACHE STRING "latex/pdflatex flags used to create synctex file.") - SET(BIBTEX_COMPILER_FLAGS "" - CACHE STRING "Flags passed to bibtex.") - SET(MAKEINDEX_COMPILER_FLAGS "" - CACHE STRING "Flags passed to makeindex.") - SET(MAKEGLOSSARIES_COMPILER_FLAGS "" - CACHE STRING "Flags passed to makeglossaries.") - SET(MAKENOMENCLATURE_COMPILER_FLAGS "" - CACHE STRING "Flags passed to makenomenclature.") - SET(DVIPS_CONVERTER_FLAGS "-Ppdf -G0 -t letter" - CACHE STRING "Flags passed to dvips.") - SET(PS2PDF_CONVERTER_FLAGS "-dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode" - CACHE STRING "Flags passed to ps2pdf.") - SET(PDFTOPS_CONVERTER_FLAGS -r 600 - CACHE STRING "Flags passed to pdftops.") - SET(LATEX2HTML_CONVERTER_FLAGS "" - CACHE STRING "Flags passed to latex2html.") - MARK_AS_ADVANCED( - LATEX_COMPILER_FLAGS - PDFLATEX_COMPILER_FLAGS - LATEX_SYNCTEX_FLAGS - BIBTEX_COMPILER_FLAGS - MAKEINDEX_COMPILER_FLAGS - MAKEGLOSSARIES_COMPILER_FLAGS - MAKENOMENCLATURE_COMPILER_FLAGS - DVIPS_CONVERTER_FLAGS - PS2PDF_CONVERTER_FLAGS - PDFTOPS_CONVERTER_FLAGS - LATEX2HTML_CONVERTER_FLAGS - ) - SEPARATE_ARGUMENTS(LATEX_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(PDFLATEX_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(LATEX_SYNCTEX_FLAGS) - SEPARATE_ARGUMENTS(BIBTEX_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(MAKEINDEX_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(MAKEGLOSSARIES_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(MAKENOMENCLATURE_COMPILER_FLAGS) - SEPARATE_ARGUMENTS(DVIPS_CONVERTER_FLAGS) - SEPARATE_ARGUMENTS(PS2PDF_CONVERTER_FLAGS) - SEPARATE_ARGUMENTS(PDFTOPS_CONVERTER_FLAGS) - SEPARATE_ARGUMENTS(LATEX2HTML_CONVERTER_FLAGS) - - FIND_PROGRAM(IMAGEMAGICK_CONVERT convert - DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)." - ) - - OPTION(LATEX_USE_SYNCTEX - "If on, have LaTeX generate a synctex file, which WYSIWYG editors can use to correlate output files like dvi and pdf with the lines of LaTeX source that generates them. In addition to adding the LATEX_SYNCTEX_FLAGS to the command line, this option also adds build commands that \"corrects\" the resulting synctex file to point to the original LaTeX files rather than those generated by UseLATEX.cmake." - OFF - ) - - OPTION(LATEX_SMALL_IMAGES - "If on, the raster images will be converted to 1/6 the original size. This is because papers usually require 600 dpi images whereas most monitors only require at most 96 dpi. Thus, smaller images make smaller files for web distributation and can make it faster to read dvi files." - OFF) - IF (LATEX_SMALL_IMAGES) - SET(LATEX_RASTER_SCALE 16 PARENT_SCOPE) - SET(LATEX_OPPOSITE_RASTER_SCALE 100 PARENT_SCOPE) - ELSE (LATEX_SMALL_IMAGES) - SET(LATEX_RASTER_SCALE 100 PARENT_SCOPE) - SET(LATEX_OPPOSITE_RASTER_SCALE 16 PARENT_SCOPE) - ENDIF (LATEX_SMALL_IMAGES) - - # Just holds extensions for known image types. They should all be lower case. - # For historical reasons, these are all declared in the global scope. - SET(LATEX_DVI_VECTOR_IMAGE_EXTENSIONS .eps CACHE INTERNAL "") - SET(LATEX_DVI_RASTER_IMAGE_EXTENSIONS CACHE INTERNAL "") - SET(LATEX_DVI_IMAGE_EXTENSIONS - ${LATEX_DVI_VECTOR_IMAGE_EXTENSIONS} - ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) - - SET(LATEX_PDF_VECTOR_IMAGE_EXTENSIONS .pdf CACHE INTERNAL "") - SET(LATEX_PDF_RASTER_IMAGE_EXTENSIONS .png .jpeg .jpg CACHE INTERNAL "") - SET(LATEX_PDF_IMAGE_EXTENSIONS - ${LATEX_PDF_VECTOR_IMAGE_EXTENSIONS} - ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) - - SET(LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS .svg CACHE INTERNAL "") - SET(LATEX_OTHER_RASTER_IMAGE_EXTENSIONS .tif .tiff .gif CACHE INTERNAL "") - SET(LATEX_OTHER_IMAGE_EXTENSIONS - ${LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS} - ${LATEX_OTHER_RASTER_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) - - SET(LATEX_VECTOR_IMAGE_EXTENSIONS - ${LATEX_DVI_VECTOR_IMAGE_EXTENSIONS} - ${LATEX_PDF_VECTOR_IMAGE_EXTENSIONS} - ${LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) - SET(LATEX_RASTER_IMAGE_EXTENSIONS - ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS} - ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS} - ${LATEX_OTHER_RASTER_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) - SET(LATEX_IMAGE_EXTENSIONS - ${LATEX_DVI_IMAGE_EXTENSIONS} - ${LATEX_PDF_IMAGE_EXTENSIONS} - ${LATEX_OTHER_IMAGE_EXTENSIONS} - CACHE INTERNAL "" - ) -ENDFUNCTION(LATEX_SETUP_VARIABLES) - -FUNCTION(LATEX_GET_OUTPUT_PATH var) - SET(latex_output_path) - IF (LATEX_OUTPUT_PATH) - GET_FILENAME_COMPONENT( - LATEX_OUTPUT_PATH_FULL "${LATEX_OUTPUT_PATH}" ABSOLUTE - ) - IF ("${LATEX_OUTPUT_PATH_FULL}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - MESSAGE(SEND_ERROR "You cannot set LATEX_OUTPUT_PATH to the same directory that contains LaTeX input files.") - ELSE ("${LATEX_OUTPUT_PATH_FULL}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - SET(latex_output_path "${LATEX_OUTPUT_PATH_FULL}") - ENDIF ("${LATEX_OUTPUT_PATH_FULL}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - ELSE (LATEX_OUTPUT_PATH) - IF ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - MESSAGE(SEND_ERROR "LaTeX files must be built out of source or you must set LATEX_OUTPUT_PATH.") - ELSE ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - SET(latex_output_path "${CMAKE_CURRENT_BINARY_DIR}") - ENDIF ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - ENDIF (LATEX_OUTPUT_PATH) - SET(${var} ${latex_output_path} PARENT_SCOPE) -ENDFUNCTION(LATEX_GET_OUTPUT_PATH) - -FUNCTION(LATEX_ADD_CONVERT_COMMAND - output_path - input_path - output_extension - input_extension - flags - ) - SET (require_imagemagick_convert TRUE) - SET (convert_flags "") - IF (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf") - # ImageMagick has broken eps to pdf conversion - # use ps2pdf instead - IF (PS2PDF_CONVERTER) - SET (require_imagemagick_convert FALSE) - SET (converter ${PS2PDF_CONVERTER}) - SET (convert_flags -dEPSCrop ${PS2PDF_CONVERTER_FLAGS}) - ELSE (PS2PDF_CONVERTER) - MESSAGE(SEND_ERROR "Using postscript files with pdflatex requires ps2pdf for conversion.") - ENDIF (PS2PDF_CONVERTER) - ELSEIF (${input_extension} STREQUAL ".pdf" AND ${output_extension} STREQUAL ".eps") - # ImageMagick can also be sketchy on pdf to eps conversion. Not good with - # color spaces and tends to unnecessarily rasterize. - # use pdftops instead - IF (PDFTOPS_CONVERTER) - SET (require_imagemagick_convert FALSE) - SET(converter ${PDFTOPS_CONVERTER}) - SET(convert_flags -eps ${PDFTOPS_CONVERTER_FLAGS}) - ELSE (PDFTOPS_CONVERTER) - MESSAGE(STATUS "Consider getting pdftops from Poppler to convert PDF images to EPS images.") - SET (convert_flags ${flags}) - ENDIF (PDFTOPS_CONVERTER) - ELSE (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf") - SET (convert_flags ${flags}) - ENDIF (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf") - - IF (require_imagemagick_convert) - IF (IMAGEMAGICK_CONVERT) - STRING(TOLOWER ${IMAGEMAGICK_CONVERT} IMAGEMAGICK_CONVERT_LOWERCASE) - IF (${IMAGEMAGICK_CONVERT_LOWERCASE} MATCHES "system32[/\\\\]convert\\.exe") - MESSAGE(SEND_ERROR "IMAGEMAGICK_CONVERT set to Window's convert.exe for changing file systems rather than ImageMagick's convert for changing image formats. Please make sure ImageMagick is installed (available at http://www.imagemagick.org) and its convert program is used for IMAGEMAGICK_CONVERT. (It is helpful if ImageMagick's path is before the Windows system paths.)") - ELSE (${IMAGEMAGICK_CONVERT_LOWERCASE} MATCHES "system32[/\\\\]convert\\.exe") - SET (converter ${IMAGEMAGICK_CONVERT}) - ENDIF (${IMAGEMAGICK_CONVERT_LOWERCASE} MATCHES "system32[/\\\\]convert\\.exe") - ELSE (IMAGEMAGICK_CONVERT) - MESSAGE(SEND_ERROR "Could not find convert program. Please download ImageMagick from http://www.imagemagick.org and install.") - ENDIF (IMAGEMAGICK_CONVERT) - ENDIF (require_imagemagick_convert) - - ADD_CUSTOM_COMMAND(OUTPUT ${output_path} - COMMAND ${converter} - ARGS ${convert_flags} ${input_path} ${output_path} - DEPENDS ${input_path} - ) -ENDFUNCTION(LATEX_ADD_CONVERT_COMMAND) - -# Makes custom commands to convert a file to a particular type. -FUNCTION(LATEX_CONVERT_IMAGE - output_files_var - input_file - output_extension - convert_flags - output_extensions - other_files - ) - SET(output_file_list) - SET(input_dir ${CMAKE_CURRENT_SOURCE_DIR}) - LATEX_GET_OUTPUT_PATH(output_dir) - - LATEX_GET_FILENAME_COMPONENT(extension "${input_file}" EXT) - - # Check input filename for potential problems with LaTeX. - LATEX_GET_FILENAME_COMPONENT(name "${input_file}" NAME_WE) - IF (name MATCHES ".*\\..*") - STRING(REPLACE "." "-" suggested_name "${name}") - SET(suggested_name "${suggested_name}${extension}") - MESSAGE(WARNING "Some LaTeX distributions have problems with image file names with multiple extensions. Consider changing ${name}${extension} to something like ${suggested_name}.") - ENDIF (name MATCHES ".*\\..*") - - STRING(REGEX REPLACE "\\.[^.]*\$" ${output_extension} output_file - "${input_file}") - - LATEX_LIST_CONTAINS(is_type ${extension} ${output_extensions}) - IF (is_type) - IF (convert_flags) - LATEX_ADD_CONVERT_COMMAND(${output_dir}/${output_file} - ${input_dir}/${input_file} ${output_extension} ${extension} - "${convert_flags}") - SET(output_file_list ${output_file_list} ${output_dir}/${output_file}) - ELSE (convert_flags) - # As a shortcut, we can just copy the file. - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${input_file} - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${input_dir}/${input_file} ${output_dir}/${input_file} - DEPENDS ${input_dir}/${input_file} - ) - SET(output_file_list ${output_file_list} ${output_dir}/${input_file}) - ENDIF (convert_flags) - ELSE (is_type) - SET(do_convert TRUE) - # Check to see if there is another input file of the appropriate type. - FOREACH(valid_extension ${output_extensions}) - STRING(REGEX REPLACE "\\.[^.]*\$" ${output_extension} try_file - "${input_file}") - LATEX_LIST_CONTAINS(has_native_file "${try_file}" ${other_files}) - IF (has_native_file) - SET(do_convert FALSE) - ENDIF (has_native_file) - ENDFOREACH(valid_extension) - - # If we still need to convert, do it. - IF (do_convert) - LATEX_ADD_CONVERT_COMMAND(${output_dir}/${output_file} - ${input_dir}/${input_file} ${output_extension} ${extension} - "${convert_flags}") - SET(output_file_list ${output_file_list} ${output_dir}/${output_file}) - ENDIF (do_convert) - ENDIF (is_type) - - SET(${output_files_var} ${output_file_list} PARENT_SCOPE) -ENDFUNCTION(LATEX_CONVERT_IMAGE) - -# Adds custom commands to process the given files for dvi and pdf builds. -# Adds the output files to the given variables (does not replace). -FUNCTION(LATEX_PROCESS_IMAGES dvi_outputs_var pdf_outputs_var) - LATEX_GET_OUTPUT_PATH(output_dir) - SET(dvi_outputs) - SET(pdf_outputs) - FOREACH(file ${ARGN}) - IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - LATEX_GET_FILENAME_COMPONENT(extension "${file}" EXT) - SET(convert_flags) - - # Check to see if we need to downsample the image. - LATEX_LIST_CONTAINS(is_raster "${extension}" - ${LATEX_RASTER_IMAGE_EXTENSIONS}) - IF (LATEX_SMALL_IMAGES) - IF (is_raster) - SET(convert_flags -resize ${LATEX_RASTER_SCALE}%) - ENDIF (is_raster) - ENDIF (LATEX_SMALL_IMAGES) - - # Make sure the output directory exists. - LATEX_GET_FILENAME_COMPONENT(path "${output_dir}/${file}" PATH) - MAKE_DIRECTORY("${path}") - - # Do conversions for dvi. - LATEX_CONVERT_IMAGE(output_files "${file}" .eps "${convert_flags}" - "${LATEX_DVI_IMAGE_EXTENSIONS}" "${ARGN}") - SET(dvi_outputs ${dvi_outputs} ${output_files}) - - # Do conversions for pdf. - IF (is_raster) - LATEX_CONVERT_IMAGE(output_files "${file}" .png "${convert_flags}" - "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}") - SET(pdf_outputs ${pdf_outputs} ${output_files}) - ELSE (is_raster) - LATEX_CONVERT_IMAGE(output_files "${file}" .pdf "${convert_flags}" - "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}") - SET(pdf_outputs ${pdf_outputs} ${output_files}) - ENDIF (is_raster) - ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - MESSAGE(WARNING "Could not find file ${CMAKE_CURRENT_SOURCE_DIR}/${file}. Are you sure you gave relative paths to IMAGES?") - ENDIF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - ENDFOREACH(file) - - SET(${dvi_outputs_var} ${dvi_outputs} PARENT_SCOPE) - SET(${pdf_outputs_var} ${pdf_outputs} PARENT_SCOPE) -ENDFUNCTION(LATEX_PROCESS_IMAGES) - -FUNCTION(ADD_LATEX_IMAGES) - MESSAGE(SEND_ERROR "The ADD_LATEX_IMAGES function is deprecated. Image directories are specified with LATEX_ADD_DOCUMENT.") -ENDFUNCTION(ADD_LATEX_IMAGES) - -FUNCTION(LATEX_COPY_GLOBBED_FILES pattern dest) - FILE(GLOB file_list ${pattern}) - FOREACH(in_file ${file_list}) - LATEX_GET_FILENAME_COMPONENT(out_file ${in_file} NAME) - CONFIGURE_FILE(${in_file} ${dest}/${out_file} COPYONLY) - ENDFOREACH(in_file) -ENDFUNCTION(LATEX_COPY_GLOBBED_FILES) - -FUNCTION(LATEX_COPY_INPUT_FILE file) - LATEX_GET_OUTPUT_PATH(output_dir) - - IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - LATEX_GET_FILENAME_COMPONENT(path ${file} PATH) - FILE(MAKE_DIRECTORY ${output_dir}/${path}) - - LATEX_LIST_CONTAINS(use_config ${file} ${LATEX_CONFIGURE}) - IF (use_config) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${output_dir}/${file} - @ONLY - ) - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${file} - COMMAND ${CMAKE_COMMAND} - ARGS ${CMAKE_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} - ) - ELSE (use_config) - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${file} - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${output_dir}/${file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} - ) - ENDIF (use_config) - ELSE (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - IF (EXISTS ${output_dir}/${file}) - # Special case: output exists but input does not. Assume that it was - # created elsewhere and skip the input file copy. - ELSE (EXISTS ${output_dir}/${file}) - MESSAGE("Could not find input file ${CMAKE_CURRENT_SOURCE_DIR}/${file}") - ENDIF (EXISTS ${output_dir}/${file}) - ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) -ENDFUNCTION(LATEX_COPY_INPUT_FILE) - -############################################################################# -# Commands provided by the UseLATEX.cmake "package" -############################################################################# - -FUNCTION(LATEX_USAGE command message) - MESSAGE(SEND_ERROR - "${message}\nUsage: ${command}(\n [BIBFILES ...]\n [INPUTS ...]\n [IMAGE_DIRS ...]\n [IMAGES \n [CONFIGURE ...]\n [DEPENDS ...]\n [MULTIBIB_NEWCITES] \n [USE_INDEX] [USE_GLOSSARY] [USE_NOMENCL]\n [DEFAULT_PDF] [DEFAULT_SAFEPDF] [DEFAULT_PS] [NO_DEFAULT]\n [MANGLE_TARGET_NAMES])" - ) -ENDFUNCTION(LATEX_USAGE command message) - -# Parses arguments to ADD_LATEX_DOCUMENT and ADD_LATEX_TARGETS and sets the -# variables LATEX_TARGET, LATEX_IMAGE_DIR, LATEX_BIBFILES, LATEX_DEPENDS, and -# LATEX_INPUTS. -FUNCTION(PARSE_ADD_LATEX_ARGUMENTS command) - LATEX_PARSE_ARGUMENTS( - LATEX - "BIBFILES;MULTIBIB_NEWCITES;INPUTS;IMAGE_DIRS;IMAGES;CONFIGURE;DEPENDS" - "USE_INDEX;USE_GLOSSARY;USE_GLOSSARIES;USE_NOMENCL;DEFAULT_PDF;DEFAULT_SAFEPDF;DEFAULT_PS;NO_DEFAULT;MANGLE_TARGET_NAMES" - ${ARGN} - ) - - # The first argument is the target latex file. - IF (LATEX_DEFAULT_ARGS) - LIST(GET LATEX_DEFAULT_ARGS 0 latex_main_input) - LIST(REMOVE_AT LATEX_DEFAULT_ARGS 0) - LATEX_GET_FILENAME_COMPONENT(latex_target ${latex_main_input} NAME_WE) - SET(LATEX_MAIN_INPUT ${latex_main_input} CACHE INTERNAL "" FORCE) - SET(LATEX_TARGET ${latex_target} CACHE INTERNAL "" FORCE) - ELSE (LATEX_DEFAULT_ARGS) - LATEX_USAGE(${command} "No tex file target given to ${command}.") - ENDIF (LATEX_DEFAULT_ARGS) - - IF (LATEX_DEFAULT_ARGS) - LATEX_USAGE(${command} "Invalid or depricated arguments: ${LATEX_DEFAULT_ARGS}") - ENDIF (LATEX_DEFAULT_ARGS) - - # Backward compatibility between 1.6.0 and 1.6.1. - IF (LATEX_USE_GLOSSARIES) - SET(LATEX_USE_GLOSSARY TRUE CACHE INTERNAL "" FORCE) - ENDIF (LATEX_USE_GLOSSARIES) -ENDFUNCTION(PARSE_ADD_LATEX_ARGUMENTS) - -FUNCTION(ADD_LATEX_TARGETS_INTERNAL) - IF (LATEX_USE_SYNCTEX) - SET(synctex_flags ${LATEX_SYNCTEX_FLAGS}) - ELSE (LATEX_USE_SYNCTEX) - SET(synctex_flags) - ENDIF (LATEX_USE_SYNCTEX) - - # The commands to run LaTeX. They are repeated multiple times. - SET(latex_build_command - ${LATEX_COMPILER} ${LATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT} - ) - SET(pdflatex_build_command - ${PDFLATEX_COMPILER} ${PDFLATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT} - ) - - # Set up target names. - IF (LATEX_MANGLE_TARGET_NAMES) - SET(dvi_target ${LATEX_TARGET}_dvi) - SET(pdf_target ${LATEX_TARGET}_pdf) - SET(ps_target ${LATEX_TARGET}_ps) - SET(safepdf_target ${LATEX_TARGET}_safepdf) - SET(html_target ${LATEX_TARGET}_html) - SET(auxclean_target ${LATEX_TARGET}_auxclean) - ELSE (LATEX_MANGLE_TARGET_NAMES) - SET(dvi_target dvi) - SET(pdf_target pdf) - SET(ps_target ps) - SET(safepdf_target safepdf) - SET(html_target html) - SET(auxclean_target auxclean) - ENDIF (LATEX_MANGLE_TARGET_NAMES) - - # Probably not all of these will be generated, but they could be. - # Note that the aux file is added later. - SET(auxiliary_clean_files - ${output_dir}/${LATEX_TARGET}.aux - ${output_dir}/${LATEX_TARGET}.bbl - ${output_dir}/${LATEX_TARGET}.blg - ${output_dir}/${LATEX_TARGET}-blx.bib - ${output_dir}/${LATEX_TARGET}.glg - ${output_dir}/${LATEX_TARGET}.glo - ${output_dir}/${LATEX_TARGET}.gls - ${output_dir}/${LATEX_TARGET}.idx - ${output_dir}/${LATEX_TARGET}.ilg - ${output_dir}/${LATEX_TARGET}.ind - ${output_dir}/${LATEX_TARGET}.ist - ${output_dir}/${LATEX_TARGET}.log - ${output_dir}/${LATEX_TARGET}.out - ${output_dir}/${LATEX_TARGET}.toc - ${output_dir}/${LATEX_TARGET}.lof - ${output_dir}/${LATEX_TARGET}.xdy - ${output_dir}/${LATEX_TARGET}.synctex.gz - ${output_dir}/${LATEX_TARGET}.synctex.bak.gz - ${output_dir}/${LATEX_TARGET}.dvi - ${output_dir}/${LATEX_TARGET}.ps - ${output_dir}/${LATEX_TARGET}.pdf - ) - - SET(image_list ${LATEX_IMAGES}) - - # For each directory in LATEX_IMAGE_DIRS, glob all the image files and - # place them in LATEX_IMAGES. - FOREACH(dir ${LATEX_IMAGE_DIRS}) - IF (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}) - MESSAGE(WARNING "Image directory ${CMAKE_CURRENT_SOURCE_DIR}/${dir} does not exist. Are you sure you gave relative directories to IMAGE_DIRS?") - ENDIF (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}) - FOREACH(extension ${LATEX_IMAGE_EXTENSIONS}) - FILE(GLOB files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*${extension}) - FOREACH(file ${files}) - LATEX_GET_FILENAME_COMPONENT(filename ${file} NAME) - SET(image_list ${image_list} ${dir}/${filename}) - ENDFOREACH(file) - ENDFOREACH(extension) - ENDFOREACH(dir) - - LATEX_PROCESS_IMAGES(dvi_images pdf_images ${image_list}) - - SET(make_dvi_command - ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command}) - SET(make_pdf_command - ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command} - ) - - SET(make_dvi_depends ${LATEX_DEPENDS} ${dvi_images}) - SET(make_pdf_depends ${LATEX_DEPENDS} ${pdf_images}) - FOREACH(input ${LATEX_MAIN_INPUT} ${LATEX_INPUTS}) - SET(make_dvi_depends ${make_dvi_depends} ${output_dir}/${input}) - SET(make_pdf_depends ${make_pdf_depends} ${output_dir}/${input}) - IF (${input} MATCHES "\\.tex$") - # Dependent .tex files might have their own .aux files created. Make - # sure these get cleaned as well. This might replicate the cleaning - # of the main .aux file, which is OK. - STRING(REGEX REPLACE "\\.tex$" "" input_we ${input}) - SET(auxiliary_clean_files ${auxiliary_clean_files} - ${output_dir}/${input_we}.aux - ${output_dir}/${input}.aux - ) - ENDIF (${input} MATCHES "\\.tex$") - ENDFOREACH(input) - - IF (LATEX_USE_GLOSSARY) - FOREACH(dummy 0 1) # Repeat these commands twice. - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=makeglossaries - -D LATEX_TARGET=${LATEX_TARGET} - -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} - -D XINDY_COMPILER=${XINDY_COMPILER} - -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS} - -P ${LATEX_USE_LATEX_LOCATION} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command} - ) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=makeglossaries - -D LATEX_TARGET=${LATEX_TARGET} - -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} - -D XINDY_COMPILER=${XINDY_COMPILER} - -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS} - -P ${LATEX_USE_LATEX_LOCATION} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command} - ) - ENDFOREACH(dummy) - ENDIF (LATEX_USE_GLOSSARY) - - IF (LATEX_USE_NOMENCL) - FOREACH(dummy 0 1) # Repeat these commands twice. - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=makenomenclature - -D LATEX_TARGET=${LATEX_TARGET} - -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} - -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS} - -P ${LATEX_USE_LATEX_LOCATION} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command} - ) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=makenomenclature - -D LATEX_TARGET=${LATEX_TARGET} - -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} - -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS} - -P ${LATEX_USE_LATEX_LOCATION} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command} - ) - ENDFOREACH(dummy) - ENDIF (LATEX_USE_NOMENCL) - - IF (LATEX_BIBFILES) - IF (LATEX_MULTIBIB_NEWCITES) - FOREACH (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES}) - LATEX_GET_FILENAME_COMPONENT(multibib_target ${multibib_auxfile} NAME_WE) - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${multibib_target}) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${multibib_target}) - SET(auxiliary_clean_files ${auxiliary_clean_files} - ${output_dir}/${multibib_target}.aux) - ENDFOREACH (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES}) - ELSE (LATEX_MULTIBIB_NEWCITES) - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${LATEX_TARGET}) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${LATEX_TARGET}) - ENDIF (LATEX_MULTIBIB_NEWCITES) - - FOREACH (bibfile ${LATEX_BIBFILES}) - SET(make_dvi_depends ${make_dvi_depends} ${output_dir}/${bibfile}) - SET(make_pdf_depends ${make_pdf_depends} ${output_dir}/${bibfile}) - ENDFOREACH (bibfile ${LATEX_BIBFILES}) - ELSE (LATEX_BIBFILES) - IF (LATEX_MULTIBIB_NEWCITES) - MESSAGE(WARNING "MULTIBIB_NEWCITES has no effect without BIBFILES option.") - ENDIF (LATEX_MULTIBIB_NEWCITES) - ENDIF (LATEX_BIBFILES) - - IF (LATEX_USE_INDEX) - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${LATEX_TARGET}.idx) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${LATEX_TARGET}.idx) - ENDIF (LATEX_USE_INDEX) - - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${latex_build_command}) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${pdflatex_build_command}) - - IF (LATEX_USE_SYNCTEX) - IF (NOT GZIP) - MESSAGE(SEND_ERROR "UseLATEX.cmake: USE_SYNTEX option requires gzip program. Set GZIP variable.") - ENDIF (NOT GZIP) - SET(make_dvi_command ${make_dvi_command} - COMMAND ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=correct_synctex - -D LATEX_TARGET=${LATEX_TARGET} - -D GZIP=${GZIP} - -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}" - -D "LATEX_BINARY_DIRECTORY=${output_dir}" - -P ${LATEX_USE_LATEX_LOCATION} - ) - SET(make_pdf_command ${make_pdf_command} - COMMAND ${CMAKE_COMMAND} - -D LATEX_BUILD_COMMAND=correct_synctex - -D LATEX_TARGET=${LATEX_TARGET} - -D GZIP=${GZIP} - -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}" - -D "LATEX_BINARY_DIRECTORY=${output_dir}" - -P ${LATEX_USE_LATEX_LOCATION} - ) - ENDIF (LATEX_USE_SYNCTEX) - - # Add commands and targets for building dvi outputs. - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.dvi - COMMAND ${make_dvi_command} - DEPENDS ${make_dvi_depends} - ) - IF (LATEX_NO_DEFAULT OR LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF OR DEFAULT_PS) - ADD_CUSTOM_TARGET(${dvi_target} - DEPENDS ${output_dir}/${LATEX_TARGET}.dvi) - ELSE (LATEX_NO_DEFAULT OR LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF OR DEFAULT_PS) - ADD_CUSTOM_TARGET(${dvi_target} ALL - DEPENDS ${output_dir}/${LATEX_TARGET}.dvi) - ENDIF (LATEX_NO_DEFAULT OR LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF OR DEFAULT_PS) - - # Add commands and targets for building pdf outputs (with pdflatex). - IF (PDFLATEX_COMPILER) - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.pdf - COMMAND ${make_pdf_command} - DEPENDS ${make_pdf_depends} - ) - IF (LATEX_DEFAULT_PDF) - ADD_CUSTOM_TARGET(${pdf_target} ALL - DEPENDS ${output_dir}/${LATEX_TARGET}.pdf) - ELSE (LATEX_DEFAULT_PDF) - ADD_CUSTOM_TARGET(${pdf_target} - DEPENDS ${output_dir}/${LATEX_TARGET}.pdf) - ENDIF (LATEX_DEFAULT_PDF) - ENDIF (PDFLATEX_COMPILER) - - IF (DVIPS_CONVERTER) - ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.ps - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${DVIPS_CONVERTER} ${DVIPS_CONVERTER_FLAGS} -o ${LATEX_TARGET}.ps ${LATEX_TARGET}.dvi - DEPENDS ${output_dir}/${LATEX_TARGET}.dvi) - IF (LATEX_DEFAULT_PS) - ADD_CUSTOM_TARGET(${ps_target} ALL - DEPENDS ${output_dir}/${LATEX_TARGET}.ps) - ELSE (LATEX_DEFAULT_PS) - ADD_CUSTOM_TARGET(${ps_target} - DEPENDS ${output_dir}/${LATEX_TARGET}.ps) - ENDIF (LATEX_DEFAULT_PS) - IF (PS2PDF_CONVERTER) - # Since both the pdf and safepdf targets have the same output, we - # cannot properly do the dependencies for both. When selecting safepdf, - # simply force a recompile every time. - IF (LATEX_DEFAULT_SAFEPDF) - ADD_CUSTOM_TARGET(${safepdf_target} ALL - ${CMAKE_COMMAND} -E chdir ${output_dir} - ${PS2PDF_CONVERTER} ${PS2PDF_CONVERTER_FLAGS} ${LATEX_TARGET}.ps ${LATEX_TARGET}.pdf - ) - ELSE (LATEX_DEFAULT_SAFEPDF) - ADD_CUSTOM_TARGET(${safepdf_target} - ${CMAKE_COMMAND} -E chdir ${output_dir} - ${PS2PDF_CONVERTER} ${PS2PDF_CONVERTER_FLAGS} ${LATEX_TARGET}.ps ${LATEX_TARGET}.pdf - ) - ENDIF (LATEX_DEFAULT_SAFEPDF) - ADD_DEPENDENCIES(${safepdf_target} ${ps_target}) - ENDIF (PS2PDF_CONVERTER) - ENDIF (DVIPS_CONVERTER) - - IF (LATEX2HTML_CONVERTER) - IF (USING_HTLATEX) - # htlatex places the output in a different location - SET (HTML_OUTPUT "${output_dir}/${LATEX_TARGET}.html") - ELSE (USING_HTLATEX) - SET (HTML_OUTPUT "${output_dir}/${LATEX_TARGET}/${LATEX_TARGET}.html") - ENDIF (USING_HTLATEX) - ADD_CUSTOM_COMMAND(OUTPUT ${HTML_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} - ${LATEX2HTML_CONVERTER} ${LATEX2HTML_CONVERTER_FLAGS} ${LATEX_MAIN_INPUT} - DEPENDS ${output_dir}/${LATEX_TARGET}.tex - ) - ADD_CUSTOM_TARGET(${html_target} - DEPENDS ${HTML_OUTPUT} - ) - ADD_DEPENDENCIES(${html_target} ${dvi_target}) - ENDIF (LATEX2HTML_CONVERTER) - - SET_DIRECTORY_PROPERTIES(. - ADDITIONAL_MAKE_CLEAN_FILES "${auxiliary_clean_files}" - ) - - ADD_CUSTOM_TARGET(${auxclean_target} - COMMENT "Cleaning auxiliary LaTeX files." - COMMAND ${CMAKE_COMMAND} -E remove ${auxiliary_clean_files} - ) -ENDFUNCTION(ADD_LATEX_TARGETS_INTERNAL) - -FUNCTION(ADD_LATEX_TARGETS) - LATEX_GET_OUTPUT_PATH(output_dir) - PARSE_ADD_LATEX_ARGUMENTS(ADD_LATEX_TARGETS ${ARGV}) - - ADD_LATEX_TARGETS_INTERNAL() -ENDFUNCTION(ADD_LATEX_TARGETS) - -FUNCTION(ADD_LATEX_DOCUMENT) - LATEX_GET_OUTPUT_PATH(output_dir) - IF (output_dir) - PARSE_ADD_LATEX_ARGUMENTS(ADD_LATEX_DOCUMENT ${ARGV}) - - LATEX_COPY_INPUT_FILE(${LATEX_MAIN_INPUT}) - - FOREACH (bib_file ${LATEX_BIBFILES}) - LATEX_COPY_INPUT_FILE(${bib_file}) - ENDFOREACH (bib_file) - - FOREACH (input ${LATEX_INPUTS}) - LATEX_COPY_INPUT_FILE(${input}) - ENDFOREACH(input) - - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.cls ${output_dir}) - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.bst ${output_dir}) - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.clo ${output_dir}) - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.sty ${output_dir}) - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.ist ${output_dir}) - LATEX_COPY_GLOBBED_FILES(${CMAKE_CURRENT_SOURCE_DIR}/*.fd ${output_dir}) - - ADD_LATEX_TARGETS_INTERNAL() - ENDIF (output_dir) -ENDFUNCTION(ADD_LATEX_DOCUMENT) - -############################################################################# -# Actually do stuff -############################################################################# - -IF (LATEX_BUILD_COMMAND) - SET(command_handled) - - IF ("${LATEX_BUILD_COMMAND}" STREQUAL makeglossaries) - LATEX_MAKEGLOSSARIES() - SET(command_handled TRUE) - ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL makeglossaries) - - IF ("${LATEX_BUILD_COMMAND}" STREQUAL makenomenclature) - LATEX_MAKENOMENCLATURE() - SET(command_handled TRUE) - ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL makenomenclature) - - IF ("${LATEX_BUILD_COMMAND}" STREQUAL correct_synctex) - LATEX_CORRECT_SYNCTEX() - SET(command_handled TRUE) - ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL correct_synctex) - - IF (NOT command_handled) - MESSAGE(SEND_ERROR "Unknown command: ${LATEX_BUILD_COMMAND}") - ENDIF (NOT command_handled) - -ELSE (LATEX_BUILD_COMMAND) - # Must be part of the actual configure (included from CMakeLists.txt). - LATEX_SETUP_VARIABLES() -ENDIF (LATEX_BUILD_COMMAND) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt deleted file mode 100644 index 73b6d80..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ - -find_package ( LATEX ) -set ( IMAGEMAGICK_CONVERT convert ) -set ( LATEX2HTML_CONVERTER latex2html ) -include ( UseLATEX ) - -# latex part -if ( PDFLATEX_COMPILER AND BIBTEX_COMPILER ) - - if ( ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} ) - # in-source build - set ( LATEX_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build ) -# execute_process ( -# COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/src/logoOpenTURNS.jpg ${CMAKE_CURRENT_SOURCE_DIR}/logoOpenTURNS.jpg -# ) - else () - # out-of-source build - set ( LATEX_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) - endif () - add_latex_document ( otmixmod_Documentation.tex - INPUTS GenericInformation.tex.in otmixmod_summary.tex otmixmod_UserManual.tex Math_Notations.sty otmixmod_ExamplesGuide.tex otmixmod_title.tex otmixmod_Documentation.sty otmixmod_ReferenceGuide.tex otmixmod_UseCasesGuide.tex script_2DMixture.py - IMAGES logootmixmod.png testMixMod.png - DEFAULT_PDF - MANGLE_TARGET_NAMES - ) - - configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/GenericInformation.tex.in - ${LATEX_OUTPUT_PATH}/GenericInformation.tex - @ONLY - ) - -# execute_process ( -# COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/latex2html/latex2html.sty ${LATEX_OUTPUT_PATH}/latex2html.sty -# COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/src/Math_Notations.sty ${LATEX_OUTPUT_PATH}/Math_Notations.sty -# COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/src/GenericInformation.tex ${LATEX_OUTPUT_PATH}/GenericInformation.tex -# ) -install ( FILES ${LATEX_OUTPUT_PATH}/otmixmod_Documentation.pdf DESTINATION ${OTMIXMOD_DATA_PATH}/doc/otmixmod/pdf ) - -endif () diff --git a/doc/GenericInformation.tex.in b/doc/GenericInformation.tex.in deleted file mode 100644 index fb9b4eb..0000000 --- a/doc/GenericInformation.tex.in +++ /dev/null @@ -1,7 +0,0 @@ -\small{\strut\\[2em]\bf Documentation built from package @PACKAGE@-@VERSION@}\\ -\vspace*{1cm} - - -{\bf \Large \today }\\[2cm] - -\includegraphics[height=10cm]{logootmixmod.png} diff --git a/doc/MixtureIsoPDF.pdf b/doc/MixtureIsoPDF.pdf deleted file mode 100644 index ea0b977..0000000 Binary files a/doc/MixtureIsoPDF.pdf and /dev/null differ diff --git a/doc/logootmixmod.png b/doc/logootmixmod.png deleted file mode 100644 index c75ad88..0000000 Binary files a/doc/logootmixmod.png and /dev/null differ diff --git a/doc/otmixmod_Documentation.pdf b/doc/otmixmod_Documentation.pdf deleted file mode 100644 index 578488f..0000000 Binary files a/doc/otmixmod_Documentation.pdf and /dev/null differ diff --git a/doc/otmixmod_Documentation.sty b/doc/otmixmod_Documentation.sty deleted file mode 100644 index 08223e8..0000000 --- a/doc/otmixmod_Documentation.sty +++ /dev/null @@ -1,179 +0,0 @@ -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{otmixmodDocumentation} - -\RequirePackage[latin1]{inputenc} -\RequirePackage[T1]{fontenc} -\RequirePackage{color} -\RequirePackage{graphics} -\RequirePackage{amsmath} -\RequirePackage{amsfonts} -\RequirePackage{amssymb} -\RequirePackage{framed} -\RequirePackage{fancyhdr} -\RequirePackage{graphicx} -\RequirePackage{ifpdf} - -% For listings for python scripts -\RequirePackage{listings} - -% For mathematics notations -\RequirePackage{Math_Notations} - -% For index -\RequirePackage{makeidx} -\RequirePackage{index} - -% For graphics -% \RequirePackage{mdwtab} -\RequirePackage{hhline} - - -% For hyper references -\RequirePackage[pdftex, bookmarks, colorlinks=true, urlcolor=green, linkcolor=red, filecolor=blue, citecolor=magenta]{hyperref} - -\ifpdf - \RequirePackage{longtable} -\else -\fi -\setlength{\textwidth}{18.5cm} -\setlength{\textheight}{23cm} -\setlength{\hoffset}{-1.04cm} -\setlength{\voffset}{-1.54cm} -\setlength{\oddsidemargin}{0cm} -\setlength{\evensidemargin}{0cm} -\setlength{\topmargin}{0cm} -\setlength{\headheight}{1cm} -\setlength{\headsep}{0.5cm} -\setlength{\marginparsep}{0cm} -\setlength{\marginparwidth}{0cm} -\setlength{\footskip}{1cm} -\setlength{\parindent}{0cm} - -\newcommand{\filename}{?} -\newcommand{\filetitle}{?} -\newcommand{\entreprise}{EDF-EADS-Phimeca} -\pagestyle{fancy} -\fancyhf{} \rhead{\bfseries \thepage} \lhead{\bfseries \nouppercase otmixmod -- Documentation} -\rfoot{\bfseries \copyright 2009-2013 \entreprise} \lfoot{} - -% Links between files -\newcommand{\otrefext}[2]{ - { - \!\!\!\![\href{#1.pdf}{\underline{#2}}]\!\!\!\! - } -} -\newcommand{\otref}[2] -{ - { - \!\!\!\![\hyperlink{#1}{\underline{#2}}]\!\!\!\! - } -} - - - -% Head for Use Cases files at third level -\newcommand{\HeaderIIILevel}{ - { - \subsubsection{\filetitle} \hypertarget{\filename}{} \label{\filename} - } % protection -} % Header - -% Head for Use Cases files at second level -\newcommand{\HeaderIILevel}{ - { - \subsection{\filetitle} \hypertarget{\filename}{} \label{\filename} - } % protection -} % Header - -% Head for Use Cases files at not numbered second level -\newcommand{\HeaderNNIILevel}{ - { - \subsection*{ - \filetitle - } \hypertarget{\filename}{} \label{\filename} - \addcontentsline{toc}{subsection}{\filetitle} - } % protection -} % Header - -% To create space after python script -\newcommand{\espace}{{\strut\\}} - -% To describe requirements of each Use Case -\newcommand{\requirements}[2]{{ - \noindent% - \begin{tabular}{||p{2.3cm}||p{12.7cm}||} - \ifpdf - \hhline{|t:=:t:=:t|} - \else - \hline - \fi - Requirements\vfill & - \parbox{12cm}{{#1}} - \\ - \ifpdf - \hhline{|:=::=:|} - \else - \hline - \fi - Results\vfill & - \parbox{12cm}{{#2}} - \\ - \ifpdf - \hhline{|b:=:b:=:b|} - \else - \hline - \fi - \end{tabular} - }} - -\newcommand{\longrequirements}[2]{{ - \noindent% - \ifpdf - \begin{longtable}{||p{2.3cm}||p{12.7cm}||} - \hhline{|t:=:t:=:t|} - Requirements\vfill & - \parbox{12cm}{{#1}} - \\ - \hhline{|:=::=:|} - Results\vfill & - \parbox{12cm}{{#2}} - \\ - \hhline{|b:=:b:=:b|} - \end{longtable} - \else - \requirements{{#1}, {#2}} - \fi - }} - -\newcommand{\Block}[1]{ - { -\begin{framed} - #1\strut -\end{framed} - } % protection -} % Block - -% Description mathématique -\newcommand{\MathematicalDescription}[2]{ - { - \Block{ - \textbf{\large Mathematical description}\\[1em] - #1\strut\\[1em] - \textbf{\textit{\large Other notations}}\\[1em] - #2\strut - } % Block - } % protection -} % MathematicalDescription - -% Méthodologie OpenTURNS -\newcommand{\Methodology}[2]{ - { - \Block{ - \textbf{\large Link with OpenTURNS methodology}\\[1em] - #1\strut\\[1em] - \textbf{\textit{\large References and theoretical basics}}\\[1em] - #2\strut - } % Block - } % protection -} % Syntax - diff --git a/doc/otmixmod_Documentation.tex b/doc/otmixmod_Documentation.tex deleted file mode 100644 index e5dcebf..0000000 --- a/doc/otmixmod_Documentation.tex +++ /dev/null @@ -1,35 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". - -\documentclass[11pt]{article} - -\usepackage{otmixmod_Documentation} -\usepackage{Math_Notations} - -\makeindex - -\begin{document} - -\thispagestyle{empty} - -\input{otmixmod_title.tex} - -\newpage -\input{otmixmod_summary.tex} -\tableofcontents -\newpage -\input{otmixmod_ReferenceGuide.tex} -\newpage -\input{otmixmod_UseCasesGuide.tex} -\newpage -\input{otmixmod_UserManual.tex} -\newpage -\input{otmixmod_ExamplesGuide.tex} - -\printindex -\end{document} diff --git a/doc/otmixmod_ExamplesGuide.tex b/doc/otmixmod_ExamplesGuide.tex deleted file mode 100644 index 6ff4246..0000000 --- a/doc/otmixmod_ExamplesGuide.tex +++ /dev/null @@ -1,52 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Examples Guide} - -This section presents some full-length examples of studies using the module. - -\subsection{Test case presentation} - -In this test case, we create a sample from a mixture and we try to estimate the mixture parameters from the sample. It is not a really an example of a study but it shows how to use this module. - -The optimal number of clusters is not supposed to be known, and will be estimated as well. - -We are in dimension 2, and the reference mixture is defined from 3 normal distributions: -\begin{equation*} - f(x) = \alpha_1 f_1(x) + \alpha_2 f_2(x) + \alpha_3 f_3(x) -\end{equation*} -with -\begin{itemize} - \item $f_1=N(\mu_1,\sigma_1,R_1)$ with $\mu_1=(-2.2,-2.2)$, $\sigma_1=(1.2,1.2)$, $R_1=\begin{pmatrix}1 & -0.2 \\ -0.2 & 1\end{pmatrix}$ and $\alpha_1 = 0.5$, - \item $f_2=N(\mu_2,\sigma_2,R_2)$ with $\mu_2=(2,2)$, $\sigma_2=(0.8, 0.8)$, $R_2=\begin{pmatrix}1 & 0.1 \\ 0.1 & 1\end{pmatrix}$ and $\alpha_2 = 0.25$, - \item $f_3=N(\mu_3,\sigma_3,R_3)$ with $\mu_3=(-5,5)$, $\sigma_3=(1.4,1.4)$, $R_3=\begin{pmatrix}1 & 0. \\ 0. & 1\end{pmatrix}$ and $\alpha_3 = 0.25$. -\end{itemize} - - - -Then we print the parameters of the mixture (more precisely the distributions of the collection to build this mixture) and we can see that it is similar. We obtain the following distributions : -\begin{itemize} - \item $\hat{f}_1=N(\mu_1,\sigma_1,R_1)$ with $\mu_1=(-2.215,-2.197)$, $\sigma_1=(1.168,1.163)$, $R_1=\begin{pmatrix}1 & -0.137 \\ -0.137 & 1\end{pmatrix}$ and $\alpha_1 = 0.498$, - \item $\hat{f}_2=N(\mu_2,\sigma_2,R_2)$ with $\mu_2=(1.958,2.009)$, $\sigma_2=(1.175,1.156)$, $R_2=\begin{pmatrix}1 & 0.136 \\ 0.136 & 1\end{pmatrix}$ and $\alpha_2 = 0.255$, - \item $\hat{f}_3=N(\mu_3,\sigma_3,R_3)$ with $\mu_3=(-5.020,5.005)$, $\sigma_3=(1.107,1.221)$, $R_3=\begin{pmatrix}1 & 0.096 \\ 0.096 & 1\end{pmatrix}$ and $\alpha_3 = 0.246$, -\end{itemize} - - - -The drawing obtained in this example (with 2000 points) is on figure \ref{fig:showMixmodResult}. - - - - -\subsection{Python script} - -\lstinputlisting[language=Python]{script_2DMixture.py} diff --git a/doc/otmixmod_ReferenceGuide.tex b/doc/otmixmod_ReferenceGuide.tex deleted file mode 100644 index 2647e53..0000000 --- a/doc/otmixmod_ReferenceGuide.tex +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Reference Guide} - -The Mixmod (MIXture MODelling) library and executable provide efficient algorithms for density estimation, clustering or discriminant analysis problems. - -%High Performance Model-Based Cluster and Discriminant Analysis - - -\subsection{Mixtures} - -The probability density function of a mixture is a weighted sum of densities: -\begin{align*} -f(x) & = \sum_i \alpha_i p_i(x) & \sum_i \alpha_i & = 1 \quad \text{with~} 0 \leq \alpha_i \leq 1 -\end{align*} - - - -\subsection{References}\label{ref} - -MIXMOD estimates the mixture parameters through maximum likelihood via the EM (Expectation Maximization, Dempster et al. 1977), and the SEM (Stochastic EM, Celeux and Diebolt 1985) algorithm or through classification maximum likelihood via the CEM algorithm (Clustering EM , Celeux and Govaert 1992). - - -\begin{itemize} - \item[1] MIXMOD, www.mixmod.org/ -\end{itemize} - diff --git a/doc/otmixmod_UseCasesGuide.tex b/doc/otmixmod_UseCasesGuide.tex deleted file mode 100644 index 78ba063..0000000 --- a/doc/otmixmod_UseCasesGuide.tex +++ /dev/null @@ -1,247 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Use Cases Guide} - -This section presents the main functionalities of the module $otmixmod$ in their context. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Which python modules to import ?} - -In order to use the functionalities described in this documentation, it is necessary to import : -\begin{itemize} - \item the $openturns$ python module which gives access to the Open TURNS functionalities, - \item the $otmixmod$ module which links the $openturns$ functionalities and MIXMOD . -\end{itemize} - -Python script for this use case : - -\begin{lstlisting} -# Load OpenTURNS to manipulate distributions -from openturns import * -# Load the link between OT and MIXMOD -from otmixmod import * -\end{lstlisting} - -\subsection{Creation of a Factory} \label{FactoryCreation} - -In $otmixmod$, it is possible to create a factory for the mixture distribution. The parameters are: -\begin{itemize} - \item the number of atoms (mandatory argument), - \item the covariance model (optional argument), $CovarianceModel$. -\end{itemize} - -We will apply it to a $NumericalSample$ to get the mixture. - -\subsubsection{UC : Creation of a Covariance Model (optional)} - -A Covariance Model is the covariance model assumed for the several atoms of a mixture. \\ - -\requirements{ - \begin{description} - \item[$\bullet$] none - \end{description} -} -{ - \begin{description} - \item[$\bullet$] a CovarianceModel variable : {\itshape myCovarianceModel}, - \item[type:] a CovarianceModel - \end{description} -} -\espace - -Many covariance models are implemented in MIXMOD. The covariance models that are available are listed in tab \ref{tab:listCovarianceModels} (cf. MIDMOD documentation for their meaning). - - -\begin{table} -\centering - \begin{tabular}{|l|l|}\hline -Model & Categories \\\hline -Gaussian\_p\_L\_I & Spherical\\ -Gaussian\_p\_Lk\_I & \\ \hline -Gaussian\_p\_L\_B & Diagonal\\ -Gaussian\_p\_Lk\_B & \\ -Gaussian\_p\_L\_Bk & \\ -Gaussian\_p\_Lk\_Bk & \\\hline -Gaussian\_p\_L\_C & General \\ -Gaussian\_p\_Lk\_C & \\ -Gaussian\_p\_L\_D\_Ak\_D & \\ -Gaussian\_p\_Lk D\_Ak\_D & \\ -Gaussian\_p\_L\_Dk\_A\_Dk & \\ -Gaussian\_p\_Lk\_Dk\_A\_Dk & \\ -Gaussian\_p\_L\_Ck & \\ -Gaussian\_p\_Lk\_Ck & \\\hline -Gaussian\_pk\_L\_I & Spherical\\ -Gaussian\_pk\_Lk\_I & \\ \hline -Gaussian\_pk\_L\_B & Diagonal\\ -Gaussian\_pk\_Lk\_B & \\ -Gaussian\_pk\_L\_Bk & \\ -Gaussian\_pk\_Lk\_Bk & \\\hline -Gaussian\_pk\_L\_C & General \\ -Gaussian\_pk\_Lk\_C & \\ -Gaussian\_pk\_L\_D\_Ak\_D & \\ -Gaussian\_pk\_Lk D\_Ak\_D & \\ -Gaussian\_pk\_L\_Dk\_A\_Dk & \\ -Gaussian\_pk\_Lk\_Dk\_A\_Dk & \\ -Gaussian\_pk\_L\_Ck & \\ -Gaussian\_pk\_Lk\_Ck & \\\hline -\end{tabular} -\caption{The 28 Gaussian Models (Covariance Structure) \label{tab:listCovarianceModels}} -\end{table} - -\espace -Python script for this use case: - -\begin{lstlisting} - # Create a CovarianceModel -myCovModel = Gaussian_pk_Lk_C() -\end{lstlisting} - - -\subsection{Creation of a Factory} %\label{FactoryCreation} - -The mixture factory is built from the number of atoms and the covariance model. - -\requirements{ - \begin{description} - \item[$\bullet$] the atoms number : {\itshape atomsNumber}, - \item[type:] UnsignedInteger - \item[$\bullet$] a CovarianceModel variable, optional: {\itshape myCovarianceModel} (default value $Gaussian\_pk\_Lk\_C$) - \item[type:] CovarianceModel - \end{description} -} -{ - \begin{description} - \item[$\bullet$] a Mixture factory: {\itshape myMixtureFactory}, - \item[type:] MixtureFactory - \end{description} -} - -\espace -Python script for this use case: - -\begin{lstlisting} -atomsNumber = 3 -factory = MixtureFactory(atomsNumber, myCovModel) -\end{lstlisting} - -\subsection{Estimation of the Mixture parameters} - -It is now possible to estimate the mixture parameters from a numerical sample. - -\requirements{ - \begin{description} - \item[$\bullet$] a Mixture factory : {\itshape myMixtureFactory}, - \item[type:] MixtureFactory - \item[$\bullet$] a numerical sample : {\itshape mySample}, - \item[type:] NumericalSample - \end{description} -} -{ - \begin{description} - \item[$\bullet$] a Mixture distribution : {\itshape myEstimatedMixture}, - \item[type:] Distribution - \end{description} -} -\espace - -\espace -Python script for this use case: - -\begin{lstlisting} -# Estimate the mixture parameters -# We estimate all the parameters of the Mixture distribution from sample -estimatedDistribution = factory.build(sample) - -# Display the resulted distribution with its parameters -print "Estimated distribution=", estimatedDistribution - -# If the sample has a dimension 2, we draw the estimated pdf and the sample -if sample.getDimension() == 2 : - g = estimatedDistribution.drawPDF() - c = Cloud(sample) - c.setColor("red") - c.setPointStyle("bullet") - ctmp = g.getDrawable(0) - g.setDrawable(Drawable(c), 0) - g.addDrawable(ctmp) - g.draw("testMixtureEstimation") - -\end{lstlisting} -The estimated distribution can be manipulated as a classical mixture distribution. So, in the case of a 1D- or 2D-sample it is possible to draw the estimated pdf and the sample on the same graph, cf. figure \ref{fig:showMixmodResult}. - -\begin{figure}[h] - \centering - \includegraphics[scale=0.4]{testMixMod.png} - % testMixMod.png: 640x480 pixel, 72dpi, 22.58x16.94 cm, bb=0 0 640 480 - \caption{Estimated mixture and Numerical Sample} - \label{fig:showMixmodResult} -\end{figure} - -\subsection{Estimation of the Mixture parameters and classification} - -It is now possible to estimate the mixture parameters from a numerical sample and to classify its points. - -\requirements{ - \begin{description} - \item[$\bullet$] a Mixture factory : {\itshape myMixtureFactory}, - \item[type:] MixtureFactory - \item[$\bullet$] a numerical sample : {\itshape mySample}, - \item[type:] NumericalSample - \end{description} -} -{ - \begin{description} - \item[$\bullet$] a Mixture distribution : {\itshape myEstimatedMixture}, - \item[type:] Distribution - \item[$\bullet$] an Indices : {\itshape labels}, - \item[type:] Indices - \item[$\bullet$] a NumericalPoint : {\itshape BICLogLikelihood}, - \item[type:] NumericalPoint - \end{description} -} -\espace - -\espace -Python script for this use case: - -\begin{lstlisting} -# Estimate the mixture parameters -# We estimate all the parameters of the Mixture distribution from a sample, -# the labels of the points in the sample and the corresponding BIC Log Likelihood - -bestLogLikelihood = -1e100 -bestNbClusters = 0 -bestLabels = Indices(0) -for nbClusters in range(1, 11): - factory = MixtureFactory(nbClusters) - labels = Indices(0) - logLikelihood = NumericalPoint(0) - estimatedDistribution = factory.build(sample, labels, logLikelihood) - # Only the second component (i.e with index 1) is usefull for selection purpose - if logLikelihood[1] > bestLogLikelihood: - bestLogLikelihood = logLikelihood[1] - bestNbClusters = nbClusters - bestLabels = labels -print "best nb clusters=", bestNbClusters, "BIC log-likelihood=", bestLogLikelihood - -# Classify the points -partition = list(NumericalSample(0, sample.getDimension()) for i in range(bestNbClusters)) -for i in range(sample.getSize()): - partition[labels[i]].add(sample[i]) -# Print the partition -for i in range(bestNbClusters): - print "cluster", i, "=", partition[i] -\end{lstlisting} -The partitioning can be used to build local meta-models for example, in a mixture of experts approach. \ No newline at end of file diff --git a/doc/otmixmod_UserManual.tex b/doc/otmixmod_UserManual.tex deleted file mode 100644 index 4784021..0000000 --- a/doc/otmixmod_UserManual.tex +++ /dev/null @@ -1,119 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{User Manual} - -This section gives an exhaustive presentation of the objects and functions provided by the $otmixmod$ module, in the alphabetic order. - -\subsection{CovarianceModel} - -\subsubsection{CovarianceModelImplementation} - - -\begin{description} -\item[Usage :] \strut - \begin{description} - \item CovarianceModelImplementation () - \end{description} -\item[Arguments :] none -\item[Value :] a CovarianceModelImplementation is the implementation of a CovarianceModel and is one to the following classes: -Gaussian\_p\_L\_I, Gaussian\_p\_Lk\_I, Gaussian\_p\_L\_B, Gaussian\_p\_Lk\_B, -Gaussian\_p\_L\_Bk, Gaussian\_p\_Lk\_Bk, Gaussian\_p\_L\_C, Gaussian\_p\_Lk\_C, Gaussian\_p\_L\_D\_Ak\_D, Gaussian\_p\_Lk D\_Ak\_D, Gaussian\_p\_L\_Dk\_A\_Dk, Gaussian\_p\_Lk\_Dk\_A\_Dk, Gaussian\_p\_L\_Ck, Gaussian\_p\_Lk\_Ck, Gaussian\_pk\_L\_I, Gaussian\_pk\_Lk\_I, Gaussian\_pk\_L\_B, -Gaussian\_pk\_Lk\_B, Gaussian\_pk\_L\_Bk, Gaussian\_pk\_Lk\_Bk, Gaussian\_pk\_L\_C, Gaussian\_pk\_Lk\_C, -Gaussian\_pk\_L\_D\_Ak\_D, Gaussian\_pk\_Lk D\_Ak\_D, Gaussian\_pk\_L\_Dk\_A\_Dk, Gaussian\_pk\_Lk\_Dk\_A\_Dk, Gaussian\_pk\_L\_Ck, Gaussian\_pk\_Lk\_Ck. - -\item[Some methods :] \strut - \begin{description} -\item $convertToMixmod$ - \begin{description} - \item[Usage :] $convertToMixmod()$ - \item[Arguments :] none - \item[Value :] a String that is the mixmod name of the covariance model. - \end{description} - - - \end{description} - -\end{description} - - - - - -\subsection{MixtureFactory} - - -\begin{description} -\item[Usage :] \strut - \begin{description} - \item $MixtureFactory(atomsNumber)$ - \item $MixtureFactory(atomsNumber, covarianceModel)$ - \end{description} -\item[Arguments :] \strut - \begin{description} - \item $atomsNumber$: a UnsignedInteger, the number of atoms to consider in the muxture. - \item $covarianceModel$: a CovarianceModel, the covariance model assumed for the several atoms of a mixture. - \end{description} -\item[Some methods :] \strut - - \begin{description} - - \item $build$ - \begin{description} - \item[Usage :] $build(sample)$ - \item[Usage :] $build(sample, labels, BICLogLikelihood)$ - \item[Arguments :] \strut - \begin{description} - \item $sample$ : a NumericalSample of dimension $n \ge 1$ - \item $labels$ : an Indices that will be filled by the method. - \item $BICLogLikelihood$ : a NumericalPoint that will be filled by 3 values: the log-likelihood of the estimated model, the corrected log-likelihood taking the number of parameters into account, and the entropy. - \end{description} - \item[Value :] a Mixture. - \end{description} - - - \item $getAtomsNumber$ - \begin{description} - \item[Usage :] $getAtomsNumber()$ - \item[Arguments :] none - \item[Value :] an UnsignedInteger, which is the number of atoms in the mixture factory. - \end{description} - - \item $getCovarianceModel$ - \begin{description} - \item[Usage :] $getCovarianceModel()$ - \item[Arguments :] none - \item[Value :] a CovarianceModel, which is the covariance model assumed for the several atoms of a mixture. - \end{description} - - - \item $setAtomsNumber$ - \begin{description} - \item[Usage :] $setAtomsNumber(myAtomNumber)$ - \item[Arguments :] \strut - \begin{description} - \item $myAtomNumber$ : an UnsignedInteger, which is the number of atoms to set in the mixture factory. - \end{description} - \item[Value :] none - \end{description} - - \item $setCovarianceModel$ - \begin{description} - \item[Usage :] $getCovarianceModel(myCovarianceModel)$ - \item[Arguments :] \strut - \begin{description} - \item $myCovarianceModel$ : a CovarianceModel, which is the covariance model assumed for the several atoms of a mixture. - \end{description} - \item[Value :] none - \end{description} - - - \end{description} - -\end{description} \ No newline at end of file diff --git a/doc/otmixmod_summary.tex b/doc/otmixmod_summary.tex deleted file mode 100644 index 52cb314..0000000 --- a/doc/otmixmod_summary.tex +++ /dev/null @@ -1,24 +0,0 @@ -% Copyright (c) 2010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". -\vspace{0.5in} -\begin{center} -\vspace{0.3in} -\emph{\fontshape{sc} Abstract} -\vspace{0.5in} -\end{center} - -The purpose of this document is to present the OpenTURNS-Mixmod module, which enables to build mixtures of multidimensional Normal distributions from a multidimensional sample. This construction is done with a control over the number of atoms in the mixture and over the covariance structure of these atoms. Some capabilities to perform classification are also provided. - -This document is organised according to the Open TURNS documentation : -\begin{itemize} -\item a \itshape{Reference Guide} which gives some theoretical basis on bayseian networks, -\item a \itshape{Use cases Guide} which details scripts in python (the Textual Interface langage of Open TURNS) and helps the User to learn as quickly as possible the manipulation of the $otmixmod$ module, -\item the \itshape{User Manual} which details the $otmixmod$ objects and give the list of their methods, -\item the \itshape{Examples Guide} which provides at the moment only one example performed with the $otmixmod$ module. -\end{itemize} - diff --git a/doc/otmixmod_title.tex b/doc/otmixmod_title.tex deleted file mode 100644 index bdd7d13..0000000 --- a/doc/otmixmod_title.tex +++ /dev/null @@ -1,14 +0,0 @@ -% Copyright (c) 20010-2011 EADS. -% Permission is granted to copy, distribute and/or modify this document -% under the terms of the GNU Free Documentation License, Version 1.2 -% or any later version published by the Free Software Foundation; -% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -% Texts. A copy of the license is included in the section entitled "GNU -% Free Documentation License". -\vspace*{2cm} - -\begin{center} - {\huge \bf Documentation of the OpenTURNS-Mixmod module} - \input{GenericInformation.tex} -\end{center} - diff --git a/doc/script_2DMixture.py b/doc/script_2DMixture.py deleted file mode 100644 index 2b44ed7..0000000 --- a/doc/script_2DMixture.py +++ /dev/null @@ -1,91 +0,0 @@ -from __future__ import print_function -from openturns import * -from otmixmod import * -from openturns.viewer import View - -draw = True - -##################################################################### -# Create a multidimensional sample from a mixture of Normal -dim = 2 -size = 20000 -coll = [] -R = CorrelationMatrix(dim) - - -# First atom -for i in range(dim-1): - R[i,i+1] = -0.2 -mean = Point(dim, -2.2) -sigma = Point(dim, 1.2) -d = Normal(mean, sigma, R) -coll.append(d) - - -# Second atom -R = CorrelationMatrix(dim) -for i in range(dim-1): - R[i,i+1] = 0.1 -mean = Point(dim, 2.0) -sigma = Point(dim, 0.8) -d = Normal(mean, sigma, R) -coll.append(d) - - -# Third atom -mean = Point( (-5.0, 5.0) ) -sigma = Point(dim, 1.4) -R = CorrelationMatrix(dim) -d = Normal(mean, sigma, R) -coll.append(d) - -weights = [0.5, 0.25, 0.25] - -# Reference mixture -mixture = Mixture(coll, weights) - -# Creation of the numerical Sample from which we will estimate -# the parameters of the mixture. -sample = mixture.getSample(size) - - -##################################################################### -# Creation of the mixture factory -myAtomsNumber = 3 -myCovModel = 'Gaussian_pk_L_Dk_A_Dk' - -bestLL = -1e100 -bestMixture = Mixture() -bestNbClusters = 0 -stop = False -nbClusters = 1 -while not stop: - factory = MixtureFactory(nbClusters, myCovModel) - # Estimation of the parameters of the mixture - estimatedDistribution, labels, logLikelihood = factory.build(sample) - stop = logLikelihood[1] <= bestLL - if not stop: - bestLL = logLikelihood[1] - bestNbClusters = nbClusters - bestMixture = estimatedDistribution - nbClusters += 1 -print("best number of atoms=", bestNbClusters) -myAtomsNumber = bestNbClusters -estimatedDistribution = bestMixture -# Some printings to show the result -print("Covariance Model used=", myCovModel) - -print("") -print("Estimated distribution:", estimatedDistribution) - -# Some drawings -if draw and (sample.getDimension() == 2): - g = estimatedDistribution.drawPDF() - c = Cloud(sample) - c.setColor("red") - c.setPointStyle("bullet") - ctmp = g.getDrawable(0) - g.setDrawable(Drawable(c), 0) - g.add(ctmp) - View(g).save('testMixMod.png') - diff --git a/doc/testMixMod.png b/doc/testMixMod.png deleted file mode 100644 index ee8215a..0000000 Binary files a/doc/testMixMod.png and /dev/null differ diff --git a/python/doc/_static/custom.css b/python/doc/_static/custom.css new file mode 100644 index 0000000..bc6f2e6 --- /dev/null +++ b/python/doc/_static/custom.css @@ -0,0 +1,14 @@ +.toggle .header { + display: block; + clear: both; + cursor: pointer; +} + + +.toggle .header:after { + content: " ▼"; +} + +.toggle .header.open:after { + content: " ▲"; +} diff --git a/python/doc/_templates/class.rst_t b/python/doc/_templates/class.rst_t new file mode 100644 index 0000000..0630f29 --- /dev/null +++ b/python/doc/_templates/class.rst_t @@ -0,0 +1,12 @@ +{{ objname }} +{{ underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + + {% block methods %} + .. automethod:: __init__ + {% endblock %} + + diff --git a/python/doc/_templates/page.html b/python/doc/_templates/page.html new file mode 100644 index 0000000..29a1589 --- /dev/null +++ b/python/doc/_templates/page.html @@ -0,0 +1,16 @@ +{% extends "!page.html" %} + +{% set css_files = css_files + ["_static/custom.css"] %} + +{% block footer %} + +{% endblock %} diff --git a/python/doc/conf.py.in b/python/doc/conf.py.in new file mode 100644 index 0000000..382a779 --- /dev/null +++ b/python/doc/conf.py.in @@ -0,0 +1,289 @@ +# -*- coding: utf-8 -*- +# +# otmixmod documentation build configuration file, created by +# sphinx-quickstart on Fri Jun 19 15:57:39 2015. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os +import subprocess + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('sphinxext')) +sys.path.insert(0, '@OTMIXMOD_PYTHON_BUILD_MODULE_PATH@') +sys.path.insert(0, '@OPENTURNS_PYTHON_MODULE_PATH@') + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Create table of contents entries for domain objects +toc_object_entries = False + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc'] + +extensions.append('sphinx.ext.autodoc') + +autodoc_default_options = {'members': None, 'inherited-members': None, 'exclude-members': 'thisown'} + +extensions.append('sphinx.ext.autosummary') +autosummary_generate = True + +extensions.append('numpydoc') +numpydoc_show_class_members = True +numpydoc_class_members_toctree = False + +extensions.append('sphinx.ext.doctest') + +extensions.append('sphinx.ext.todo') +todo_include_todos = True + +extensions.append('sphinx.ext.coverage') + +extensions.append('sphinx.ext.intersphinx') +# try to download inventory else fallback to local inventory +inventory = (None, 'openturns-objects.inv') +intersphinx_mapping = {'openturns': ('http://openturns.github.io/openturns/latest', inventory)} + +extensions.append('sphinx.ext.imgmath') +imgmath_latex_preamble = r'\usepackage{{{0}math_notations}}'.format( + os.path.dirname(__file__) + os.sep) +imgmath_use_preview = True +if subprocess.run(['dvisvgm', '-V'], shell=True, capture_output=True).returncode == 0: + imgmath_image_format = 'svg' +# embed image files inside html +imgmath_embed = True + +extensions.append('matplotlib.sphinxext.plot_directive') + +extensions.append('sphinx_gallery.gen_gallery') +sphinx_gallery_conf = { + 'examples_dirs': ['examples'], # path to example scripts + 'gallery_dirs': ['auto_examples'], # path to where to save gallery gen. output + 'show_signature': False, +} + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'otmixmod' +copyright = u'2005-2020 Airbus-EDF-IMACS-ONERA-Phimeca' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@' +# The full version, including alpha/beta/rc tags. +release = '@PACKAGE_VERSION@' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build', 'themes', 'sphinxext'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'classic' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'otmixmoddoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + 'papersize': 'a4paper', + # The font size ('10pt', '11pt' or '12pt'). + 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + 'preamble': r'\usepackage{math_notations}', +} + +latex_additional_files = ['math_notations.sty'] + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'otmixmod.tex', u'otmixmod Documentation', + u'Airbus-EDF-IMACS-Phimeca', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'otmixmod', u'otmixmod Documentation', + [u'Airbus-EDF-IMACS-Phimeca'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'otmixmod', u'otmixmod Documentation', + u'Airbus-EDF-IMACS-Phimeca', 'otmixmod', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' diff --git a/python/doc/examples/README.txt b/python/doc/examples/README.txt new file mode 100644 index 0000000..bac945d --- /dev/null +++ b/python/doc/examples/README.txt @@ -0,0 +1,2 @@ +Examples +======== diff --git a/python/doc/examples/plot_example1.py b/python/doc/examples/plot_example1.py new file mode 100755 index 0000000..869712f --- /dev/null +++ b/python/doc/examples/plot_example1.py @@ -0,0 +1,115 @@ +""" +Example 1: Axial stressed beam +============================== +""" + +# %% +# In this test case, we create a sample from a mixture and we try to estimate the mixture parameters from the sample. +# It is not a really an example of a study but it shows how to use this module. +# The optimal number of clusters is not supposed to be known, and will be estimated as well. +# We are in dimension 2, and the reference mixture is defined from 3 normal distributions: +# +# .. math:: +# +# f(x) = \alpha_1 f_1(x) + \alpha_2 f_2(x) + \alpha_3 f_3(x) +# +# with: +# +# - :math:`f_1=N(\mu_1,\sigma_1,R_1)` with :math:`\mu_1=(-2.2,-2.2)`, :math:`\sigma_1=(1.2,1.2)`, :math:`R_1=-0.2` and :math:`\alpha_1 = 0.5`, +# - :math:`f_2=N(\mu_2,\sigma_2,R_2)` with :math:`\mu_2=(2,2)`, :math:`\sigma_2=(0.8, 0.8)`, :math:`R_2=0.1` and :math:`\alpha_2 = 0.25`, +# - :math:`f_3=N(\mu_3,\sigma_3,R_3)` with :math:`\mu_3=(-5,5)`, :math:`\sigma_3=(1.4,1.4)`, :math:`R_3=0` and :math:`\alpha_3 = 0.25`. +# + +# %% +import openturns as ot +import openturns.viewer as otv +import otmixmod + +# %% +# Create a multidimensional sample from a mixture of Normal +dim = 2 +size = 20000 +coll = [] +R = ot.CorrelationMatrix(dim) + +# %% +# First atom +for i in range(dim - 1): + R[i, i + 1] = -0.2 +mean = ot.Point(dim, -2.2) +sigma = ot.Point(dim, 1.2) +d = ot.Normal(mean, sigma, R) +coll.append(d) + +# %% +# Second atom +R = ot.CorrelationMatrix(dim) +for i in range(dim - 1): + R[i, i + 1] = 0.1 +mean = ot.Point(dim, 2.0) +sigma = ot.Point(dim, 0.8) +d = ot.Normal(mean, sigma, R) +coll.append(d) + +# %% +# Third atom +mean = [-5.0, 5.0] +sigma = [1.4] * 2 +R = ot.CorrelationMatrix(dim) +d = ot.Normal(mean, sigma, R) +coll.append(d) + +weights = [0.5, 0.25, 0.25] + +# %% +# Reference mixture +mixture = ot.Mixture(coll, weights) + +# %% +# Creation of the numerical Sample from which we will estimate +# the parameters of the mixture. +sample = mixture.getSample(size) + + +# %% +# Creation of the mixture factory +myAtomsNumber = 3 +myCovModel = 'Gaussian_pk_L_Dk_A_Dk' + +bestLL = -1e100 +bestMixture = ot.Mixture() +bestNbClusters = 0 +stop = False +nbClusters = 1 +while not stop: + factory = otmixmod.MixtureFactory(nbClusters, myCovModel) + # Estimation of the parameters of the mixture + estimatedDistribution, labels, logLikelihood = factory.build(sample) + stop = logLikelihood[1] <= bestLL + if not stop: + bestLL = logLikelihood[1] + bestNbClusters = nbClusters + bestMixture = estimatedDistribution + nbClusters += 1 +print("best number of atoms=", bestNbClusters) +myAtomsNumber = bestNbClusters +estimatedDistribution = bestMixture +# Some printings to show the result +print("Covariance Model used=", myCovModel) + +print("") +print("Estimated distribution:", estimatedDistribution) + +# %% +# Some drawings +if sample.getDimension() == 2: + g = estimatedDistribution.drawPDF() + c = ot.Cloud(sample) + c.setColor("red") + c.setPointStyle("bullet") + ctmp = g.getDrawable(0) + g.setDrawable(c, 0) + g.add(ctmp) + view = otv.View(g) + +otv.View.ShowAll() diff --git a/python/doc/index.rst b/python/doc/index.rst new file mode 100644 index 0000000..f26a89f --- /dev/null +++ b/python/doc/index.rst @@ -0,0 +1,30 @@ +otmixmod documentation +======================== + +The Mixmod (MIXture MODelling) library (https://github.com/mixmod) and executable provide efficient algorithms for density estimation, clustering or discriminant analysis problems. + +The probability density function of a mixture is a weighted sum of densities: + +.. math:: + + \begin{align*} + f(x) & = \sum_i \alpha_i p_i(x) & \sum_i \alpha_i & = 1 \quad \text{with~} 0 \leq \alpha_i \leq 1 + \end{align*} + +MIXMOD estimates the mixture parameters through maximum likelihood via the EM (Expectation Maximization, Dempster et al. 1977), and the SEM (Stochastic EM, Celeux and Diebolt 1985) algorithm or through classification maximum likelihood via the CEM algorithm (Clustering EM , Celeux and Govaert 1992). + +User documentation +------------------ + +.. toctree:: + :maxdepth: 2 + + user_manual/user_manual + ../auto_examples/index.rst + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` + diff --git a/doc/Math_Notations.sty b/python/doc/math_notations.sty similarity index 62% rename from doc/Math_Notations.sty rename to python/doc/math_notations.sty index 1f1d6c9..0e5f18c 100644 --- a/doc/Math_Notations.sty +++ b/python/doc/math_notations.sty @@ -1,10 +1,13 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{Math_Notations} +\ProvidesPackage{math_notations} + +\usepackage{amsmath} +\usepackage{amssymb} % For matrixes and vectors \newcommand{\vect}[1]{{\underline{#1}}} \newcommand{\mat}[1]{{\underline{\underline{#1}}}} -\newcommand{\Tr}[1]{{{#1}^t}} +\newcommand{\Tr}[1]{{#1}^{\text{\upshape\textsf T}}} % Bold letters \newcommand{\bdA}{{\boldsymbol{A}}} @@ -61,35 +64,46 @@ \newcommand{\bdz}{{\boldsymbol{z}}} % special caracters -\newcommand{\ca}{{\mathcal A}} -\newcommand{\cb}{{\mathcal B}} -\newcommand{\cc}{{\mathcal C}} -\newcommand{\cd}{{\mathcal D}} -\newcommand{\ce}{{\mathcal E}} -\newcommand{\cf}{{\mathcal F}} -\newcommand{\cg}{{\mathcal G}} -\newcommand{\ch}{{\mathcal H}} -\newcommand{\ck}{{\mathcal K}} -\newcommand{\cl}{{\mathcal L}} -\newcommand{\cn}{{\mathcal N}} -\newcommand{\cm}{{\mathcal M}} -\newcommand{\cp}{{\mathcal P}} -\newcommand{\cs}{{\mathcal S}} -\newcommand{\cu}{{\mathcal U}} -\newcommand{\cw}{{\mathcal W}} -\newcommand{\cx}{{\mathcal X}} -\newcommand{\C}{{\mathbb C}} -\newcommand{\E}{{\mathbb E}} -\newcommand{\N}{{\mathbb N}} -\renewcommand{\P}{{\mathbb P}} -\newcommand{\Q}{{\mathbb Q}} -\newcommand{\R}{{\mathbb R}} -\newcommand{\Z}{{\mathbb Z}} -\newcommand{\D}{{\mathrm{d}}} +\newcommand{\cA}{{\mathcal A}} +\newcommand{\cB}{{\mathcal B}} +\newcommand{\cC}{{\mathcal C}} +\newcommand{\cD}{{\mathcal D}} +\newcommand{\cE}{{\mathcal E}} +\newcommand{\cF}{{\mathcal F}} +\newcommand{\cG}{{\mathcal G}} +\newcommand{\cH}{{\mathcal H}} +\newcommand{\cI}{{\mathcal I}} +\newcommand{\cJ}{{\mathcal J}} +\newcommand{\cK}{{\mathcal K}} +\newcommand{\cL}{{\mathcal L}} +\newcommand{\cM}{{\mathcal M}} +\newcommand{\cN}{{\mathcal N}} +\newcommand{\cO}{{\mathcal P}} +\newcommand{\cP}{{\mathcal P}} +\newcommand{\cQ}{{\mathcal Q}} +\newcommand{\cR}{{\mathcal R}} +\newcommand{\cS}{{\mathcal S}} +\newcommand{\cT}{{\mathcal T}} +\newcommand{\cU}{{\mathcal U}} +\newcommand{\cV}{{\mathcal V}} +\newcommand{\cW}{{\mathcal W}} +\newcommand{\cX}{{\mathcal X}} +\newcommand{\cY}{{\mathcal Y}} +\newcommand{\cZ}{{\mathcal Z}} +\newcommand{\Cset}{{\mathbb C}} +\newcommand{\Eset}{{\mathbb E}} +\newcommand{\Nset}{{\mathbb N}} +\newcommand{\Pset}{{\mathbb P}} +\newcommand{\Qset}{{\mathbb Q}} +\newcommand{\Rset}{{\mathbb R}} +\newcommand{\Zset}{{\mathbb Z}} +\newcommand{\Diff}{{\mathrm{d}}} % short commands \newcommand{\un}[1]{\underline{#1}} \newcommand{\dpl}[1]{\displaystyle{#1}} +\newcommand{\uw}{\underline{w}} +\newcommand{\uW}{\underline{W}} \newcommand{\ux}{\underline{x}} \newcommand{\uX}{\underline{X}} \newcommand{\uy}{\underline{y}} @@ -99,10 +113,16 @@ \newcommand{\muX}{\underline{\mu}_{\:X}} \newcommand{\Var}[1]{{\rm Var}\left[ #1 \right]} \newcommand{\Cov}[1]{{\rm Cov}\left[ #1 \right]} -\newcommand{\Esp}[1]{{\mathbb E}\left[ #1 \right]} -\newcommand{\Prob}[1]{{\mathbb P}\left( #1 \right)} +\newcommand{\Expect}[1]{{\mathbb E}\left[ #1 \right]} +\newcommand{\Prob}[1]{{\mathbb P}\left[ #1 \right]} \newcommand{\pdf}{f_{\un{X}}(\un{x})} \newcommand{\ech}{\left\{ x_1, \, \dots\,, x_N \right\}} \newcommand{\matcov} {\mathbf C} \newcommand{\matcor} {\mathbf R} -\newcommand{\fcar}[2] {{\mathbf 1}_{#1}(#2)} \ No newline at end of file +\newcommand{\fcar}[2] {{\mathbf 1}_{#1}(#2)} +\newcommand{\supp}[1] {{\rm supp}\left(#1\right)} +\newcommand{\di}[1] {{\rm d}#1} +\newcommand{\norm}[1] {\left\|#1\right\|} + +\DeclareMathOperator*{\argmin}{argmin} +\DeclareMathOperator*{\argmax}{argmax} \ No newline at end of file diff --git a/python/doc/openturns-objects.inv b/python/doc/openturns-objects.inv new file mode 100644 index 0000000..c9af9b4 Binary files /dev/null and b/python/doc/openturns-objects.inv differ diff --git a/python/doc/user_manual/user_manual.rst b/python/doc/user_manual/user_manual.rst new file mode 100644 index 0000000..e12a115 --- /dev/null +++ b/python/doc/user_manual/user_manual.rst @@ -0,0 +1,10 @@ +API Reference +============= + +.. currentmodule:: otmixmod + +.. autosummary:: + :toctree: _generated/ + :template: class.rst_t + + MixtureFactory diff --git a/python/src/CMakeLists.txt b/python/src/CMakeLists.txt index dfe6364..14cef5f 100644 --- a/python/src/CMakeLists.txt +++ b/python/src/CMakeLists.txt @@ -86,9 +86,105 @@ install ( FILES __init__.py DESTINATION ${OTMIXMOD_PYTHON_MODULE_PATH}/${PACKAGE_NAME} ) + +if (SPHINX_FOUND) + + # create a build site-package from which sphinx can import + set (OTMIXMOD_PYTHON_BUILD_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR}/site-packages) + execute_process (COMMAND ${CMAKE_COMMAND} -E make_directory ${OTMIXMOD_PYTHON_BUILD_MODULE_PATH}/otmixmod) + foreach (module ${OTMIXMOD_PYTHON_MODULES}) + execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/${module}.py ${OTMIXMOD_PYTHON_BUILD_MODULE_PATH}/otmixmod/${module}.py) + # FIXME: get_target_property (suffix ${SWIG_MODULE_${module}_REAL_NAME} SUFFIX) + execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/_${module}.so ${OTMIXMOD_PYTHON_BUILD_MODULE_PATH}/otmixmod/_${module}.so) + endforeach () + foreach (file __init__.py) + execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${OTMIXMOD_PYTHON_BUILD_MODULE_PATH}/otmixmod/${file}) + endforeach () + + # sphinx configuration + set (doc_formats) + list (APPEND doc_formats html) + list (APPEND doc_formats htmlhelp) + list (APPEND doc_formats latex) + list (APPEND doc_formats doctest) + list (APPEND doc_formats qthelp) + list (APPEND doc_formats devhelp) + + set (SPHINX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx_build) + set (SPHINX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../doc) + + file (MAKE_DIRECTORY ${SPHINX_BINARY_DIR}/_static) # currently empty + + configure_file (${SPHINX_SOURCE_DIR}/conf.py.in ${SPHINX_BINARY_DIR}/conf.py @ONLY) + + # get sphinx sources + file (GLOB_RECURSE sphinx_sources + ${SPHINX_SOURCE_DIR}/*.rst + ${SPHINX_SOURCE_DIR}/*.rst_t + ${SPHINX_SOURCE_DIR}/*.css_t + ${SPHINX_SOURCE_DIR}/*.conf + ${SPHINX_SOURCE_DIR}/*.py + ${SPHINX_SOURCE_DIR}/*.png + ${SPHINX_SOURCE_DIR}/*.html + ${SPHINX_SOURCE_DIR}/*.css + ${SPHINX_SOURCE_DIR}/*.jpg + ${SPHINX_SOURCE_DIR}/*.ico + ${SPHINX_SOURCE_DIR}/*.sty + ${SPHINX_SOURCE_DIR}/*.txt + ${SPHINX_SOURCE_DIR}/*.in + ${SPHINX_SOURCE_DIR}/*.inv + ) + + # copy sphinx sources + set (sphinx_clones) + foreach (file ${sphinx_sources}) + if (EXISTS ${file}) + file ( RELATIVE_PATH rel_file ${SPHINX_SOURCE_DIR} ${file} ) + get_filename_component (rel_path ${rel_file} PATH) + file (MAKE_DIRECTORY ${SPHINX_BINARY_DIR}/${rel_path}) + set (sphinx_clone ${SPHINX_BINARY_DIR}/${rel_file}) + add_custom_command (OUTPUT ${sphinx_clone} + COMMAND ${CMAKE_COMMAND} -E copy ${file} ${sphinx_clone} + DEPENDS ${file} + ) + list (APPEND sphinx_clones ${sphinx_clone}) + endif () + endforeach () + + set (SPHINX_FLAGS "-W -T" CACHE STRING "sphinx flags") + separate_arguments (SPHINX_FLAGS) + + # generate sphinx rule for each format + foreach (format ${doc_formats}) + add_custom_target ( sphinx_${format} + COMMAND ${SPHINX_EXECUTABLE} + -b ${format} + -d ${SPHINX_BINARY_DIR}/.doctrees + ${SPHINX_FLAGS} + ${SPHINX_BINARY_DIR} + ${SPHINX_BINARY_DIR}/${format} + DEPENDS ${sphinx_clones} + ) + foreach (MODULENAME ${OTMIXMOD_PYTHON_MODULES}) + set (module_target ${MODULENAME}_python) + add_dependencies (sphinx_${format} ${module_target}) + endforeach () + endforeach () + + # build html by default + set_target_properties (sphinx_html PROPERTIES EXCLUDE_FROM_ALL OFF) + + add_custom_command (OUTPUT ${SPHINX_BINARY_DIR}/latex/OpenTURNS.pdf + WORKING_DIRECTORY ${SPHINX_BINARY_DIR}/latex + COMMAND make all-pdf + ) + add_custom_target (sphinx_pdf DEPENDS ${SPHINX_BINARY_DIR}/latex/OpenTURNS.pdf) + add_dependencies (sphinx_pdf sphinx_latex) + + install (DIRECTORY ${SPHINX_BINARY_DIR}/html DESTINATION ${OTMIXMOD_DOC_PATH}) +endif () + # wheel files configure_file (METADATA.in METADATA @ONLY) -configure_file (WHEEL.in WHEEL @ONLY) -install (DIRECTORY DESTINATION ${OTMIXMOD_PYTHON_MODULE_PATH}/${PACKAGE_NAME}-${PACKAGE_VERSION}.dist-info) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/METADATA ${CMAKE_CURRENT_BINARY_DIR}/WHEEL - DESTINATION ${OTMIXMOD_PYTHON_MODULE_PATH}/${PACKAGE_NAME}-${PACKAGE_VERSION}.dist-info) +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/METADATA + DESTINATION ${OTMIXMOD_PYTHON_MODULE_PATH}/${PACKAGE_NAME}-${PACKAGE_VERSION}.dist-info) diff --git a/python/src/MixtureFactory_doc.i.in b/python/src/MixtureFactory_doc.i.in index 73a0f69..a7b9f86 100644 --- a/python/src/MixtureFactory_doc.i.in +++ b/python/src/MixtureFactory_doc.i.in @@ -1,15 +1,66 @@ %feature("docstring") OTMIXMOD::MixtureFactory -"Mixture inference." +"Mixture inference. + +Parameters +---------- +atomsNumber : int + The number of atoms +covarianceModel : str, optional + The covariance model. + Default is 'Gaussian_pk_Lk_C' + + Other possible values include: + + - Gaussian_p_L_I + - Gaussian_p_Lk_I + - Gaussian_p_L_B + - Gaussian_p_Lk_B + - Gaussian_p_L_Bk + - Gaussian_p_Lk_Bk + - Gaussian_p_L_C + - Gaussian_p_Lk_C + - Gaussian_p_L_D_Ak_D + - Gaussian_p_Lk D_Ak_D + - Gaussian_p_L_Dk_A_Dk + - Gaussian_p_Lk_Dk_A_Dk + - Gaussian_p_L_Ck + - Gaussian_p_Lk_Ck + - Gaussian_pk_L_I + - Gaussian_pk_Lk_I + - Gaussian_pk_L_B + - Gaussian_pk_Lk_B + - Gaussian_pk_L_Bk + - Gaussian_pk_Lk_Bk + - Gaussian_pk_L_C + - Gaussian_pk_Lk_C + - Gaussian_pk_L_D_Ak_D + - Gaussian_pk_Lk D_Ak_D + - Gaussian_pk_L_Dk_A_Dk + - Gaussian_pk_Lk_Dk_A_Dk + - Gaussian_pk_L_Ck + - Gaussian_pk_Lk_Ck +" // ---------------------------------------------------------------------------- %feature("docstring") OTMIXMOD::MixtureFactory::buildAsMixture -"Mixture inference." +"Mixture inference. + +Parameters +---------- +sample : :class:`openturns.Sample` + Sample + +Returns +------- +mixture : :class:`openturns.Mixture` + Inferred distribution +" // ---------------------------------------------------------------------------- %feature("docstring") OTMIXMOD::MixtureFactory::setSeed -"Mixmod RNG seed accessor +"Mixmod RNG seed accessor. Parameters ---------- @@ -17,4 +68,26 @@ seed : int Seed used to initialize the Mixmod RNG seed before the learning step. A negative seed will randomly initialize the RNG. The default value is 0. -" \ No newline at end of file +" + +// ---------------------------------------------------------------------------- + +%feature("docstring") OTMIXMOD::MixtureFactory::setAtomsNumber +"Atoms number accessor. + +Parameters +---------- +atomsNumber : int + The number of atoms +" + +// ---------------------------------------------------------------------------- + +%feature("docstring") OTMIXMOD::MixtureFactory::getAtomsNumber +"Atoms number accessor. + +Returns +------- +atomsNumber : int + The number of atoms +" diff --git a/python/src/WHEEL.in b/python/src/WHEEL.in deleted file mode 100644 index 823cbf7..0000000 --- a/python/src/WHEEL.in +++ /dev/null @@ -1,4 +0,0 @@ -Wheel-Version: 1.0 -Generator: custom -Root-Is-Purelib: false -Tag: @WHEEL_TAG@ diff --git a/utils/lint.sh b/utils/lint.sh index 3e769cc..84451c2 100755 --- a/utils/lint.sh +++ b/utils/lint.sh @@ -2,4 +2,4 @@ # pip install flake8 -PATH=~/.local/bin/:$PATH flake8 python/ --ignore=W503 --max-line-length=120 +PATH=~/.local/bin/:$PATH flake8 python/ --ignore=W503 --max-line-length=150