Skip to content

Commit

Permalink
Merge app4triqs/notriqsinto unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentzell committed Jul 26, 2023
2 parents fe729f2 + 58ad320 commit 08313d0
Show file tree
Hide file tree
Showing 25 changed files with 831 additions and 510 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: NonAssignment
Expand Down
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Checks: '-*,modernize-*,cppcoreguidelines-*,-modernize-use-trailing-return-type, -cppcoreguidelines-special-member-functions, -cppcoreguidelines-macro-usage, -cppcoreguidelines-no-malloc,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-avoid-magic-numbers'
HeaderFilterRegex: 'itertools|-f77'
Checks: '-*,modernize-*,cppcoreguidelines-*,bugprone-*,-modernize-use-trailing-return-type,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-macro-usage,-cppcoreguidelines-no-malloc,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-non-private-member-variables-in-classes, -bugprone-easily-swappable-parameters'
HeaderFilterRegex: 'itertools'
30 changes: 16 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,33 @@ jobs:
fail-fast: false
matrix:
include:
- {os: ubuntu-20.04, cc: gcc-10, cxx: g++-10}
- {os: ubuntu-20.04, cc: clang-13, cxx: clang++-13}
- {os: macos-11, cc: gcc-11, cxx: g++-11}
- {os: macos-11, cc: /usr/local/opt/llvm/bin/clang, cxx: /usr/local/opt/llvm/bin/clang++}
- {os: ubuntu-22.04, cc: gcc-12, cxx: g++-12}
- {os: ubuntu-22.04, cc: clang-15, cxx: clang++-15}
- {os: macos-12, cc: gcc-12, cxx: g++-12}
- {os: macos-12, cc: /usr/local/opt/llvm/bin/clang, cxx: /usr/local/opt/llvm/bin/clang++}

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install ubuntu dependencies
if: matrix.os == 'ubuntu-20.04'
if: matrix.os == 'ubuntu-22.04'
run: >
sudo apt-get update &&
sudo apt-get install lsb-release wget software-properties-common &&
wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && sudo chmod +x /tmp/llvm.sh && sudo /tmp/llvm.sh 13 &&
wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && sudo chmod +x /tmp/llvm.sh && sudo /tmp/llvm.sh 15 &&
sudo apt-get install
clang-13
g++-10
clang-15
g++-12
gfortran
hdf5-tools
libblas-dev
libclang-13-dev
libc++-13-dev
libc++abi-13-dev
libclang-15-dev
libc++-15-dev
libc++abi-15-dev
libomp-15-dev
libfftw3-dev
libgfortran5
libgmp-dev
libhdf5-dev
Expand All @@ -46,7 +48,7 @@ jobs:
openmpi-bin
openmpi-common
openmpi-doc
python3-clang-13
python3-clang-15
python3-dev
python3-mako
python3-mpi4py
Expand All @@ -57,9 +59,9 @@ jobs:
python3-nbsphinx
- name: Install homebrew dependencies
if: matrix.os == 'macos-11'
if: matrix.os == 'macos-12'
run: |
brew install gcc@11 llvm hdf5 open-mpi openblas
brew install gcc@12 llvm hdf5 open-mpi openblas
pip3 install mako numpy scipy mpi4py
pip3 install -r requirements.txt
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
compile_commands.json
doc/_autosummary
doc/cpp2rst_generated
doc/html
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
#
# Authors: Philipp Dumitrescu, Olivier Parcollet, Dylan Simon, Nils Wentzell

cmake_minimum_required(VERSION 3.12.4 FATAL_ERROR)
cmake_policy(VERSION 3.12.4)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
cmake_policy(VERSION 3.20)

# ############
# Define Project
project(itertools VERSION 1.1.0 LANGUAGES C CXX)
project(itertools VERSION 1.2.0 LANGUAGES C CXX)
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)

# Get the git hash & print status
Expand Down Expand Up @@ -55,7 +52,7 @@ endif()

# Documentation
option(Build_Documentation "Build documentation" OFF)
if(NOT IS_SUBPROJECT AND (Build_Documentation AND NOT PythonSupport))
if(Build_Documentation AND NOT PythonSupport)
message(FATAL_ERROR "Build_Documentation=ON requires PythonSupport to be enabled")
endif()

Expand Down Expand Up @@ -89,6 +86,7 @@ target_compile_options(${PROJECT_NAME}_warnings
INTERFACE
-Wall
-Wextra
-Wfloat-conversion
-Wpedantic
-Wno-sign-compare
$<$<CXX_COMPILER_ID:GNU>:-Wno-comma-subscript>
Expand All @@ -99,11 +97,13 @@ target_compile_options(${PROJECT_NAME}_warnings
$<$<CXX_COMPILER_ID:Clang>:-Wshadow>
$<$<CXX_COMPILER_ID:Clang>:-Wno-gcc-compat>
$<$<CXX_COMPILER_ID:Clang>:-Wno-c++20-extensions>
$<$<CXX_COMPILER_ID:Clang>:-Wno-c++20-compat>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-deprecated-comma-subscript>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-unknown-warning-option>
$<$<CXX_COMPILER_ID:AppleClang>:-Wshadow>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-gcc-compat>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-c++20-extensions>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-c++20-compat>
)

# ---------------------------------
Expand Down
9 changes: 0 additions & 9 deletions ChangeLog.md

This file was deleted.

1 change: 1 addition & 0 deletions ChangeLog.md
5 changes: 2 additions & 3 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG APPNAME=itertools
COPY requirements.txt /src/$APPNAME/requirements.txt
RUN pip3 install -r /src/$APPNAME/requirements.txt

RUN useradd -u 993 -m build
RUN useradd -u 990 -m build

ENV SRC=/src \
BUILD=/home/build \
Expand All @@ -17,9 +17,8 @@ COPY --chown=build . $SRC/$APPNAME
WORKDIR $BUILD/$APPNAME
RUN chown build .
USER build
ARG BUILD_DOC=0
ARG BUILD_ID
ARG CMAKE_ARGS
RUN cmake $SRC/$APPNAME -DCMAKE_INSTALL_PREFIX=$INSTALL -DBuild_Documentation=$BUILD_DOC -DCLANG_OPT="$CXXFLAGS" -DMATHJAX_PATH="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2" $CMAKE_ARGS && make -j2 || make -j1 VERBOSE=1
RUN cmake $SRC/$APPNAME -DCMAKE_INSTALL_PREFIX=$INSTALL -DCLANG_OPT="$CXXFLAGS" $CMAKE_ARGS && make -j4 || make -j1 VERBOSE=1
USER root
RUN make install
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[![build](https://github.com/TRIQS/itertools/workflows/build/badge.svg?branch=unstable)](https://github.com/TRIQS/itertools/actions?query=workflow%3Abuild)

# itertools
Expand Down
6 changes: 2 additions & 4 deletions c++/itertools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ file(GLOB_RECURSE headers *.hpp)
add_library(${PROJECT_NAME}_c INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME}_c ALIAS ${PROJECT_NAME}_c)

# Set C++ Standard
target_compile_features(${PROJECT_NAME}_c INTERFACE cxx_std_23)

# Configure target and compilation
target_compile_features(${PROJECT_NAME}_c INTERFACE cxx_std_23)
target_include_directories(${PROJECT_NAME}_c INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/c++>)
target_include_directories(${PROJECT_NAME}_c SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
target_compile_definitions(${PROJECT_NAME}_c INTERFACE
Expand Down Expand Up @@ -49,7 +47,7 @@ if(ANALYZE_SOURCES)
--verbose
--force
--quiet
${headers}
${sources}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)
Expand Down
37 changes: 37 additions & 0 deletions c++/itertools/itertools.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cmath>
#include "./itertools.hpp"

namespace itertools {

toto &toto::operator+=(toto const &b) {
this->i += b.i;
return *this;
}

toto toto::operator+(toto const &b) const {
auto res = *this;
res += b;
return res;
}

bool toto::operator==(toto const &b) const { return (this->i == b.i); }

void h5_write(h5::group grp, std::string subgroup_name, toto const &m) {
grp = subgroup_name.empty() ? grp : grp.create_group(subgroup_name);
h5_write(grp, "i", m.i);
h5_write_attribute(grp, "Format", toto::hdf5_format());
}

void h5_read(h5::group grp, std::string subgroup_name, toto &m) {
grp = subgroup_name.empty() ? grp : grp.open_group(subgroup_name);
int i;
h5_read(grp, "i", i);
m = toto(i);
}

int chain(int i, int j) {
int n_digits_j = j > 0 ? (int)log10(j) + 1 : 1;
return i * int(pow(10, n_digits_j)) + j;
}

} // namespace itertools
4 changes: 2 additions & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ endif()
add_custom_target(${PROJECT_NAME}_docs_sphinx ALL)
add_custom_command(
TARGET ${PROJECT_NAME}_docs_sphinx
COMMAND PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SPHINXBUILD_EXECUTABLE} -c . -j8 -b html ${CMAKE_CURRENT_SOURCE_DIR} html
COMMAND ${SPHINXBUILD_EXECUTABLE} -c . -j auto -b html ${CMAKE_CURRENT_SOURCE_DIR} html
)

option(Sphinx_Only "When building the documentation, skip the Python Modules and the generation of C++ Api and example outputs" OFF)
Expand All @@ -69,6 +69,6 @@ endif()
# ---------------------------------
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DESTINATION share/doc/${PROJECT_NAME}
FILES_MATCHING
REGEX "\\.(html|pdf|png|gif|jpg|svg|js|xsl|css|py|txt|inv|bib|ttf|woff2|eot)$"
REGEX "\\.(html|pdf|png|gif|jpg|svg|ico|js|xsl|css|py|txt|inv|bib|ttf|woff2|eot)$"
PATTERN "_*"
)
29 changes: 29 additions & 0 deletions doc/_templates/autosummary_class_template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ fullname | escape | underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:toctree:
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
:toctree:
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
68 changes: 68 additions & 0 deletions doc/_templates/autosummary_module_template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
:toctree:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: autosummary_class_template.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: autosummary_module_template.rst
:recursive:

{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

Loading

0 comments on commit 08313d0

Please sign in to comment.