From 5e5ef6400e755d0f644079d7805b3a0a8776cf04 Mon Sep 17 00:00:00 2001 From: Martin Stiaszny Date: Tue, 26 Mar 2019 16:36:12 -0700 Subject: [PATCH 1/7] Move stuff to include/ --- {albatross => include/albatross}/Common | 6 +++--- {albatross => include/albatross}/Core | 0 {albatross => include/albatross}/CovarianceFunctions | 0 {albatross => include/albatross}/Dataset | 0 {albatross => include/albatross}/Distribution | 0 {albatross => include/albatross}/Evaluation | 0 {albatross => include/albatross}/GP | 0 {albatross => include/albatross}/Ransac | 0 {albatross => include/albatross}/Tune | 0 {albatross => include/albatross}/cereal/eigen.h | 0 {albatross => include/albatross}/cereal/traits.h | 0 {albatross => include/albatross}/core/dataset.h | 0 {albatross => include/albatross}/core/declarations.h | 0 {albatross => include/albatross}/core/distribution.h | 0 {albatross => include/albatross}/core/fit_model.h | 0 {albatross => include/albatross}/core/indexing.h | 0 {albatross => include/albatross}/core/keys.h | 0 {albatross => include/albatross}/core/model.h | 0 .../albatross}/core/parameter_handling_mixin.h | 0 {albatross => include/albatross}/core/parameter_macros.h | 0 {albatross => include/albatross}/core/prediction.h | 0 {albatross => include/albatross}/core/priors.h | 0 {albatross => include/albatross}/core/serialize.h | 0 {albatross => include/albatross}/core/traits.h | 0 .../albatross}/covariance_functions/call_trace.h | 0 .../albatross}/covariance_functions/covariance_function.h | 0 .../albatross}/covariance_functions/distance_metrics.h | 0 .../albatross}/covariance_functions/noise.h | 0 .../albatross}/covariance_functions/polynomials.h | 0 .../albatross}/covariance_functions/radial.h | 0 .../albatross}/covariance_functions/scaling_function.h | 0 .../albatross}/covariance_functions/traits.h | 0 .../albatross}/eigen/serializable_diagonal_matrix.h | 0 {albatross => include/albatross}/eigen/serializable_ldlt.h | 0 .../albatross}/evaluation/cross_validation.h | 0 .../albatross}/evaluation/cross_validation_utils.h | 0 {albatross => include/albatross}/evaluation/evaluate.h | 0 {albatross => include/albatross}/evaluation/folds.h | 0 {albatross => include/albatross}/evaluation/likelihood.h | 0 {albatross => include/albatross}/evaluation/traits.h | 0 {albatross => include/albatross}/models/gp.h | 0 {albatross => include/albatross}/models/least_squares.h | 0 {albatross => include/albatross}/models/ransac.h | 0 {albatross => include/albatross/utils}/csv_utils.h | 0 {albatross => include/albatross/utils}/eigen_utils.h | 0 {albatross => include/albatross/utils}/map_utils.h | 0 {albatross => include/albatross/utils}/random_utils.h | 0 {albatross => include/albatross/utils}/tune.h | 0 {albatross => include/albatross/utils}/tuning_metrics.h | 0 49 files changed, 3 insertions(+), 3 deletions(-) rename {albatross => include/albatross}/Common (89%) rename {albatross => include/albatross}/Core (100%) rename {albatross => include/albatross}/CovarianceFunctions (100%) rename {albatross => include/albatross}/Dataset (100%) rename {albatross => include/albatross}/Distribution (100%) rename {albatross => include/albatross}/Evaluation (100%) rename {albatross => include/albatross}/GP (100%) rename {albatross => include/albatross}/Ransac (100%) rename {albatross => include/albatross}/Tune (100%) rename {albatross => include/albatross}/cereal/eigen.h (100%) rename {albatross => include/albatross}/cereal/traits.h (100%) rename {albatross => include/albatross}/core/dataset.h (100%) rename {albatross => include/albatross}/core/declarations.h (100%) rename {albatross => include/albatross}/core/distribution.h (100%) rename {albatross => include/albatross}/core/fit_model.h (100%) rename {albatross => include/albatross}/core/indexing.h (100%) rename {albatross => include/albatross}/core/keys.h (100%) rename {albatross => include/albatross}/core/model.h (100%) rename {albatross => include/albatross}/core/parameter_handling_mixin.h (100%) rename {albatross => include/albatross}/core/parameter_macros.h (100%) rename {albatross => include/albatross}/core/prediction.h (100%) rename {albatross => include/albatross}/core/priors.h (100%) rename {albatross => include/albatross}/core/serialize.h (100%) rename {albatross => include/albatross}/core/traits.h (100%) rename {albatross => include/albatross}/covariance_functions/call_trace.h (100%) rename {albatross => include/albatross}/covariance_functions/covariance_function.h (100%) rename {albatross => include/albatross}/covariance_functions/distance_metrics.h (100%) rename {albatross => include/albatross}/covariance_functions/noise.h (100%) rename {albatross => include/albatross}/covariance_functions/polynomials.h (100%) rename {albatross => include/albatross}/covariance_functions/radial.h (100%) rename {albatross => include/albatross}/covariance_functions/scaling_function.h (100%) rename {albatross => include/albatross}/covariance_functions/traits.h (100%) rename {albatross => include/albatross}/eigen/serializable_diagonal_matrix.h (100%) rename {albatross => include/albatross}/eigen/serializable_ldlt.h (100%) rename {albatross => include/albatross}/evaluation/cross_validation.h (100%) rename {albatross => include/albatross}/evaluation/cross_validation_utils.h (100%) rename {albatross => include/albatross}/evaluation/evaluate.h (100%) rename {albatross => include/albatross}/evaluation/folds.h (100%) rename {albatross => include/albatross}/evaluation/likelihood.h (100%) rename {albatross => include/albatross}/evaluation/traits.h (100%) rename {albatross => include/albatross}/models/gp.h (100%) rename {albatross => include/albatross}/models/least_squares.h (100%) rename {albatross => include/albatross}/models/ransac.h (100%) rename {albatross => include/albatross/utils}/csv_utils.h (100%) rename {albatross => include/albatross/utils}/eigen_utils.h (100%) rename {albatross => include/albatross/utils}/map_utils.h (100%) rename {albatross => include/albatross/utils}/random_utils.h (100%) rename {albatross => include/albatross/utils}/tune.h (100%) rename {albatross => include/albatross/utils}/tuning_metrics.h (100%) diff --git a/albatross/Common b/include/albatross/Common similarity index 89% rename from albatross/Common rename to include/albatross/Common index 0f704a31..35cb18b6 100644 --- a/albatross/Common +++ b/include/albatross/Common @@ -34,8 +34,8 @@ #include #include -#include "map_utils.h" -#include "random_utils.h" -#include "cereal/eigen.h" +#include +#include +#include #endif diff --git a/albatross/Core b/include/albatross/Core similarity index 100% rename from albatross/Core rename to include/albatross/Core diff --git a/albatross/CovarianceFunctions b/include/albatross/CovarianceFunctions similarity index 100% rename from albatross/CovarianceFunctions rename to include/albatross/CovarianceFunctions diff --git a/albatross/Dataset b/include/albatross/Dataset similarity index 100% rename from albatross/Dataset rename to include/albatross/Dataset diff --git a/albatross/Distribution b/include/albatross/Distribution similarity index 100% rename from albatross/Distribution rename to include/albatross/Distribution diff --git a/albatross/Evaluation b/include/albatross/Evaluation similarity index 100% rename from albatross/Evaluation rename to include/albatross/Evaluation diff --git a/albatross/GP b/include/albatross/GP similarity index 100% rename from albatross/GP rename to include/albatross/GP diff --git a/albatross/Ransac b/include/albatross/Ransac similarity index 100% rename from albatross/Ransac rename to include/albatross/Ransac diff --git a/albatross/Tune b/include/albatross/Tune similarity index 100% rename from albatross/Tune rename to include/albatross/Tune diff --git a/albatross/cereal/eigen.h b/include/albatross/cereal/eigen.h similarity index 100% rename from albatross/cereal/eigen.h rename to include/albatross/cereal/eigen.h diff --git a/albatross/cereal/traits.h b/include/albatross/cereal/traits.h similarity index 100% rename from albatross/cereal/traits.h rename to include/albatross/cereal/traits.h diff --git a/albatross/core/dataset.h b/include/albatross/core/dataset.h similarity index 100% rename from albatross/core/dataset.h rename to include/albatross/core/dataset.h diff --git a/albatross/core/declarations.h b/include/albatross/core/declarations.h similarity index 100% rename from albatross/core/declarations.h rename to include/albatross/core/declarations.h diff --git a/albatross/core/distribution.h b/include/albatross/core/distribution.h similarity index 100% rename from albatross/core/distribution.h rename to include/albatross/core/distribution.h diff --git a/albatross/core/fit_model.h b/include/albatross/core/fit_model.h similarity index 100% rename from albatross/core/fit_model.h rename to include/albatross/core/fit_model.h diff --git a/albatross/core/indexing.h b/include/albatross/core/indexing.h similarity index 100% rename from albatross/core/indexing.h rename to include/albatross/core/indexing.h diff --git a/albatross/core/keys.h b/include/albatross/core/keys.h similarity index 100% rename from albatross/core/keys.h rename to include/albatross/core/keys.h diff --git a/albatross/core/model.h b/include/albatross/core/model.h similarity index 100% rename from albatross/core/model.h rename to include/albatross/core/model.h diff --git a/albatross/core/parameter_handling_mixin.h b/include/albatross/core/parameter_handling_mixin.h similarity index 100% rename from albatross/core/parameter_handling_mixin.h rename to include/albatross/core/parameter_handling_mixin.h diff --git a/albatross/core/parameter_macros.h b/include/albatross/core/parameter_macros.h similarity index 100% rename from albatross/core/parameter_macros.h rename to include/albatross/core/parameter_macros.h diff --git a/albatross/core/prediction.h b/include/albatross/core/prediction.h similarity index 100% rename from albatross/core/prediction.h rename to include/albatross/core/prediction.h diff --git a/albatross/core/priors.h b/include/albatross/core/priors.h similarity index 100% rename from albatross/core/priors.h rename to include/albatross/core/priors.h diff --git a/albatross/core/serialize.h b/include/albatross/core/serialize.h similarity index 100% rename from albatross/core/serialize.h rename to include/albatross/core/serialize.h diff --git a/albatross/core/traits.h b/include/albatross/core/traits.h similarity index 100% rename from albatross/core/traits.h rename to include/albatross/core/traits.h diff --git a/albatross/covariance_functions/call_trace.h b/include/albatross/covariance_functions/call_trace.h similarity index 100% rename from albatross/covariance_functions/call_trace.h rename to include/albatross/covariance_functions/call_trace.h diff --git a/albatross/covariance_functions/covariance_function.h b/include/albatross/covariance_functions/covariance_function.h similarity index 100% rename from albatross/covariance_functions/covariance_function.h rename to include/albatross/covariance_functions/covariance_function.h diff --git a/albatross/covariance_functions/distance_metrics.h b/include/albatross/covariance_functions/distance_metrics.h similarity index 100% rename from albatross/covariance_functions/distance_metrics.h rename to include/albatross/covariance_functions/distance_metrics.h diff --git a/albatross/covariance_functions/noise.h b/include/albatross/covariance_functions/noise.h similarity index 100% rename from albatross/covariance_functions/noise.h rename to include/albatross/covariance_functions/noise.h diff --git a/albatross/covariance_functions/polynomials.h b/include/albatross/covariance_functions/polynomials.h similarity index 100% rename from albatross/covariance_functions/polynomials.h rename to include/albatross/covariance_functions/polynomials.h diff --git a/albatross/covariance_functions/radial.h b/include/albatross/covariance_functions/radial.h similarity index 100% rename from albatross/covariance_functions/radial.h rename to include/albatross/covariance_functions/radial.h diff --git a/albatross/covariance_functions/scaling_function.h b/include/albatross/covariance_functions/scaling_function.h similarity index 100% rename from albatross/covariance_functions/scaling_function.h rename to include/albatross/covariance_functions/scaling_function.h diff --git a/albatross/covariance_functions/traits.h b/include/albatross/covariance_functions/traits.h similarity index 100% rename from albatross/covariance_functions/traits.h rename to include/albatross/covariance_functions/traits.h diff --git a/albatross/eigen/serializable_diagonal_matrix.h b/include/albatross/eigen/serializable_diagonal_matrix.h similarity index 100% rename from albatross/eigen/serializable_diagonal_matrix.h rename to include/albatross/eigen/serializable_diagonal_matrix.h diff --git a/albatross/eigen/serializable_ldlt.h b/include/albatross/eigen/serializable_ldlt.h similarity index 100% rename from albatross/eigen/serializable_ldlt.h rename to include/albatross/eigen/serializable_ldlt.h diff --git a/albatross/evaluation/cross_validation.h b/include/albatross/evaluation/cross_validation.h similarity index 100% rename from albatross/evaluation/cross_validation.h rename to include/albatross/evaluation/cross_validation.h diff --git a/albatross/evaluation/cross_validation_utils.h b/include/albatross/evaluation/cross_validation_utils.h similarity index 100% rename from albatross/evaluation/cross_validation_utils.h rename to include/albatross/evaluation/cross_validation_utils.h diff --git a/albatross/evaluation/evaluate.h b/include/albatross/evaluation/evaluate.h similarity index 100% rename from albatross/evaluation/evaluate.h rename to include/albatross/evaluation/evaluate.h diff --git a/albatross/evaluation/folds.h b/include/albatross/evaluation/folds.h similarity index 100% rename from albatross/evaluation/folds.h rename to include/albatross/evaluation/folds.h diff --git a/albatross/evaluation/likelihood.h b/include/albatross/evaluation/likelihood.h similarity index 100% rename from albatross/evaluation/likelihood.h rename to include/albatross/evaluation/likelihood.h diff --git a/albatross/evaluation/traits.h b/include/albatross/evaluation/traits.h similarity index 100% rename from albatross/evaluation/traits.h rename to include/albatross/evaluation/traits.h diff --git a/albatross/models/gp.h b/include/albatross/models/gp.h similarity index 100% rename from albatross/models/gp.h rename to include/albatross/models/gp.h diff --git a/albatross/models/least_squares.h b/include/albatross/models/least_squares.h similarity index 100% rename from albatross/models/least_squares.h rename to include/albatross/models/least_squares.h diff --git a/albatross/models/ransac.h b/include/albatross/models/ransac.h similarity index 100% rename from albatross/models/ransac.h rename to include/albatross/models/ransac.h diff --git a/albatross/csv_utils.h b/include/albatross/utils/csv_utils.h similarity index 100% rename from albatross/csv_utils.h rename to include/albatross/utils/csv_utils.h diff --git a/albatross/eigen_utils.h b/include/albatross/utils/eigen_utils.h similarity index 100% rename from albatross/eigen_utils.h rename to include/albatross/utils/eigen_utils.h diff --git a/albatross/map_utils.h b/include/albatross/utils/map_utils.h similarity index 100% rename from albatross/map_utils.h rename to include/albatross/utils/map_utils.h diff --git a/albatross/random_utils.h b/include/albatross/utils/random_utils.h similarity index 100% rename from albatross/random_utils.h rename to include/albatross/utils/random_utils.h diff --git a/albatross/tune.h b/include/albatross/utils/tune.h similarity index 100% rename from albatross/tune.h rename to include/albatross/utils/tune.h diff --git a/albatross/tuning_metrics.h b/include/albatross/utils/tuning_metrics.h similarity index 100% rename from albatross/tuning_metrics.h rename to include/albatross/utils/tuning_metrics.h From fad454e415952f7913b5c1d485e63967ec3ee83d Mon Sep 17 00:00:00 2001 From: Martin Stiaszny Date: Tue, 26 Mar 2019 17:34:05 -0700 Subject: [PATCH 2/7] Albatross include clean-up. --- CMakeLists.txt | 69 ++------- cmake/ClangTools.cmake | 72 +++++----- examples/CMakeLists.txt | 136 +++++++----------- examples/call_trace_example.cc | 7 +- examples/example_utils.h | 7 +- examples/inspection.cc | 5 +- examples/sinc_example.cc | 10 +- examples/sinc_example_utils.h | 2 +- .../temperature_example.cc | 5 +- .../temperature_example_utils.h | 7 +- include/albatross/Common | 2 + include/albatross/CovarianceFunctions | 28 ++-- include/albatross/Tune | 10 +- include/albatross/cereal/traits.h | 2 +- include/albatross/core/declarations.h | 2 +- include/albatross/core/fit_model.h | 2 +- include/albatross/core/model.h | 2 +- .../albatross/core/parameter_handling_mixin.h | 5 +- include/albatross/core/parameter_macros.h | 14 +- include/albatross/core/prediction.h | 2 +- .../covariance_functions/call_trace.h | 2 +- .../albatross/covariance_functions/traits.h | 4 +- .../eigen/serializable_diagonal_matrix.h | 2 +- include/albatross/eigen/serializable_ldlt.h | 8 +- include/albatross/evaluation/folds.h | 2 +- include/albatross/evaluation/traits.h | 2 +- include/albatross/models/ransac.h | 15 +- include/albatross/utils/csv_utils.h | 7 +- include/albatross/utils/random_utils.h | 6 +- tests/CMakeLists.txt | 102 ++++++------- tests/mock_model.h | 2 +- tests/test_call_trace.cc | 4 +- tests/test_core_dataset.cc | 2 +- tests/test_core_distribution.cc | 2 +- tests/test_core_distribution.h | 5 +- tests/test_covariance_function.cc | 2 +- tests/test_covariance_functions.cc | 4 +- tests/test_cross_validation.cc | 3 +- tests/test_csv_utils.cc | 8 +- tests/test_distance_metrics.cc | 3 +- tests/test_eigen_utils.cc | 3 +- tests/test_indexing.cc | 3 +- tests/test_map_utils.cc | 3 +- tests/test_model_adapter.cc | 2 +- tests/test_models.h | 7 +- tests/test_prediction.cc | 3 +- tests/test_radial.cc | 3 +- tests/test_random_utils.cc | 3 +- tests/test_ransac.cc | 4 +- tests/test_scaling_function.cc | 3 +- tests/test_serializable_ldlt.cc | 5 +- tests/test_serialize.cc | 6 +- tests/test_serialize.h | 2 +- tests/test_traits_cereal.cc | 2 +- tests/test_traits_core.cc | 3 +- tests/test_traits_covariance_functions.cc | 3 +- tests/test_traits_evaluation.cc | 3 +- tests/test_tune.cc | 5 +- tests/test_tuning_metrics.cc | 5 +- tests/test_utils.h | 7 +- 60 files changed, 262 insertions(+), 387 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23a72731..768e10a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,8 @@ cmake_minimum_required(VERSION 2.8.7) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include(ClangTools) -# Enable Clang auto-formatting, defaults to on. option(ENABLE_AUTOFORMAT "Enable automatic formatting and replacement with clang-format." ON) -# Enable Clang auto-linting, defaults to off. option(ENABLE_AUTOLINT "Enable automatic linting and warning with clang-tidy. " OFF) -# Enable static stack analyzer, defaults to off. option(ENABLE_STACK_ANALYSIS "Enable stack analysis. Requires gcc." OFF) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -17,68 +14,22 @@ endif() add_subdirectory(third_party/googletest) -include_directories(SYSTEM ${gtest_SOURCE_DIR} ${gtest_SOURCE_DIR}/include) -include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/eigen/") -include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/cereal/include") -include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/") +add_library(albatross INTERFACE) +target_include_directories(albatross INTERFACE + "${PROJECT_SOURCE_DIR}/include" + ) +target_include_directories(albatross SYSTEM INTERFACE + "${PROJECT_SOURCE_DIR}/third_party/eigen/" + "${PROJECT_SOURCE_DIR}/third_party/cereal/include" + "${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/" + ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -fexceptions -frtti") set(CMAKE_CXX_FLAGS "-std=c++14 -Wshadow -Wswitch-default -Wswitch-enum -Wundef -Wpointer-arith -Wcast-align -Wformat=2 -Wredundant-decls ${CMAKE_CXX_FLAGS}") set("LOG_LEVEL=8") -include_directories("${PROJECT_SOURCE_DIR}/albatross") include(${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake) -set(albatross_HEADERS - albatross/cereal/eigen.h - albatross/cereal/traits.h - albatross/core/dataset.h - albatross/core/declarations.h - albatross/core/distribution.h - albatross/core/fit_model.h - albatross/core/indexing.h - albatross/core/keys.h - albatross/core/model.h - albatross/core/parameter_handling_mixin.h - albatross/core/parameter_macros.h - albatross/core/prediction.h - albatross/core/priors.h - albatross/core/serialize.h - albatross/core/traits.h - albatross/covariance_functions/call_trace.h - albatross/covariance_functions/covariance_function.h - albatross/covariance_functions/distance_metrics.h - albatross/covariance_functions/noise.h - albatross/covariance_functions/polynomials.h - albatross/covariance_functions/radial.h - albatross/covariance_functions/scaling_function.h - albatross/covariance_functions/traits.h - albatross/csv_utils.h - albatross/eigen/serializable_diagonal_matrix.h - albatross/eigen/serializable_ldlt.h - albatross/eigen_utils.h - albatross/evaluation/cross_validation.h - albatross/evaluation/cross_validation_utils.h - albatross/evaluation/evaluate.h - albatross/evaluation/folds.h - albatross/map_utils.h - albatross/models/gp.h - albatross/models/least_squares.h - albatross/models/ransac.h - albatross/random_utils.h - albatross/tune.h - albatross/tuning_metrics.h - examples/example_utils.h - examples/sinc_example_utils.h - examples/temperature_example/temperature_example_utils.h - tests/mock_model.h - tests/test_core_distribution.h - tests/test_models.h - tests/test_serialize.h - tests/test_utils.h -) - -add_custom_target(albatross DEPENDS ${albatross_HEADERS} COMMENT "albatross dependencies") - add_subdirectory(tests) add_subdirectory(examples) diff --git a/cmake/ClangTools.cmake b/cmake/ClangTools.cmake index 1080ead3..ffd5d419 100644 --- a/cmake/ClangTools.cmake +++ b/cmake/ClangTools.cmake @@ -11,7 +11,7 @@ # Do not use clang tooling when cross compiling. if(CMAKE_CROSSCOMPILING) - return() + return() endif(CMAKE_CROSSCOMPILING) ################################################################################ @@ -21,27 +21,23 @@ endif(CMAKE_CROSSCOMPILING) # Check for Clang format set(CLANG_FORMAT_PATH "NOTSET" CACHE STRING "Absolute path to the clang-format executable") if("${CLANG_FORMAT_PATH}" STREQUAL "NOTSET") - find_program(CLANG_FORMAT NAMES - clang-format39 clang-format-3.9 - clang-format38 clang-format-3.8 - clang-format37 clang-format-3.7 - clang-format36 clang-format-3.6 - clang-format35 clang-format-3.5 - clang-format34 clang-format-3.4 - clang-format) - message(STATUS "Using clang format: ${CLANG_FORMAT}") - if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND") - message(WARNING "Could not find 'clang-format' please set CLANG_FORMAT_PATH:STRING") - else() - set(CLANG_FORMAT_PATH ${CLANG_FORMAT}) - message(STATUS "Found: ${CLANG_FORMAT_PATH}") - endif() + find_program(CLANG_FORMAT NAMES + clang-format-6.0 + clang-format-4.0 + ) + message(STATUS "Using clang format: ${CLANG_FORMAT}") + if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND") + message(WARNING "Could not find 'clang-format' please set CLANG_FORMAT_PATH:STRING") + else() + set(CLANG_FORMAT_PATH ${CLANG_FORMAT}) + message(STATUS "Found: ${CLANG_FORMAT_PATH}") + endif() else() - if(NOT EXISTS ${CLANG_FORMAT_PATH}) - message(WARNING "Could not find 'clang-format': ${CLANG_FORMAT_PATH}") - else() - message(STATUS "Found: ${CLANG_FORMAT_PATH}") - endif() + if(NOT EXISTS ${CLANG_FORMAT_PATH}) + message(WARNING "Could not find 'clang-format': ${CLANG_FORMAT_PATH}") + else() + message(STATUS "Found: ${CLANG_FORMAT_PATH}") + endif() endif() ################################################################################ @@ -50,24 +46,24 @@ endif() if (EXISTS ${CLANG_FORMAT_PATH}) - # Format all files .cc files (and their headers) in project - add_custom_target(clang-format-all - COMMAND git ls-files -- '../*.cc' '../*.h' - | sed 's/^...//' | sed 's\#\^\#${CMAKE_SOURCE_DIR}/\#' - | xargs "${CLANG_FORMAT_PATH}" -i - ) - # In-place format *.cc files that differ from master, and are not listed as - # being DELETED. - add_custom_target(clang-format-diff - COMMAND git diff --diff-filter=ACMRTUXB --name-only master -- '../*.cc' '../*.h' - | sed 's\#\^\#${CMAKE_SOURCE_DIR}/\#' - | xargs "${CLANG_FORMAT_PATH}" -i - ) + # Format all files .cc files (and their headers) in project + add_custom_target(clang-format-all + COMMAND git ls-files -- '../*.cc' '../*.h' + | sed 's/^...//' | sed 's\#^\#${CMAKE_SOURCE_DIR}/\#' + | xargs "${CLANG_FORMAT_PATH}" -i + ) + # In-place format *.cc files that differ from master, and are not listed as + # being DELETED. + add_custom_target(clang-format-diff + COMMAND git diff --diff-filter=ACMRTUXB --name-only master -- '../*.cc' '../*.h' + | sed 's\#^\#${CMAKE_SOURCE_DIR}/\#' + | xargs "${CLANG_FORMAT_PATH}" -i + ) endif() if (EXISTS ${CPPCHECK_PATH}) - add_custom_target(cppcheck-all - COMMAND git ls-files -- '../*.cc' '../*.h' - | ${CPPCHECK_PATH} --enable=all --std=c++14 -I../include -isystem../third_party/eigen -q --file-list=- - ) + add_custom_target(cppcheck-all + COMMAND git ls-files -- '../*.cc' '../*.h' + | ${CPPCHECK_PATH} --enable=all --std=c++14 -I../include -isystem../third_party/eigen -q --file-list=- + ) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 840947b0..3e91308c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,96 +1,60 @@ -include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/") - -set(example_HEADERS - example_utils.h - sinc_example_utils.h - CACHE INTERNAL "" -) - add_executable(sinc_example - EXCLUDE_FROM_ALL - sinc_example.cc -) - -add_dependencies(sinc_example - albatross -) - -target_link_libraries(sinc_example m gflags pthread nlopt) + sinc_example.cc + ) +target_link_libraries(sinc_example + albatross + gflags + pthread + nlopt + ) +add_custom_target(run_sinc_example + DEPENDS sinc_example + COMMAND sinc_example -input ${PROJECT_SOURCE_DIR}/examples/sinc_input.csv -output ./sinc_predictions.csv -tune + COMMENT "Running sinc_example" + ) -add_custom_target( - run_sinc_example ALL - DEPENDS ${example_HEADERS} - COMMAND sinc_example -input ${PROJECT_SOURCE_DIR}/examples/sinc_input.csv -output ./sinc_predictions.csv -tune - COMMENT "Running sinc_example" -) - -add_dependencies(run_sinc_example - sinc_example -) add_executable(inspection_example - EXCLUDE_FROM_ALL - inspection.cc -) - -add_dependencies(inspection_example - albatross -) - -target_link_libraries(inspection_example m gflags pthread) - -add_custom_target( - run_inspection_example ALL - DEPENDS ${example_HEADERS} - COMMAND inspection_example -input ${PROJECT_SOURCE_DIR}/examples/inspection_input.csv - COMMENT "Running inspection_example" -) - -add_dependencies(run_inspection_example - inspection_example -) + inspection.cc + ) +target_link_libraries(inspection_example + albatross + gflags + pthread + ) +add_custom_target(run_inspection_example + DEPENDS inspection_example + COMMAND inspection_example -input ${PROJECT_SOURCE_DIR}/examples/inspection_input.csv + COMMENT "Running inspection_example" + ) add_executable(temperature_example - EXCLUDE_FROM_ALL - temperature_example/temperature_example.cc -) - -add_dependencies(temperature_example - albatross -) - -target_link_libraries(temperature_example m gflags pthread nlopt) - -add_custom_target( - run_temperature_example ALL - DEPENDS ${example_HEADERS} - COMMAND temperature_example -input ${PROJECT_SOURCE_DIR}/examples/temperature_example/gsod.csv -predict ${PROJECT_SOURCE_DIR}/examples/temperature_example/prediction_locations.csv -output ./test_temperature_predictions.csv -thin 5 - COMMENT "Running temperature_example" -) + temperature_example/temperature_example.cc + ) +target_link_libraries(temperature_example + albatross + gflags + pthread + nlopt + ) +add_custom_target(run_temperature_example + DEPENDS temperature_example + COMMAND temperature_example -input ${PROJECT_SOURCE_DIR}/examples/temperature_example/gsod.csv -predict ${PROJECT_SOURCE_DIR}/examples/temperature_example/prediction_locations.csv -output ./test_temperature_predictions.csv -thin 5 + COMMENT "Running temperature_example" + ) -add_dependencies(run_temperature_example - temperature_example -) add_executable(call_trace_example - EXCLUDE_FROM_ALL - call_trace_example.cc -) - -add_dependencies(call_trace_example - albatross -) - -target_link_libraries(call_trace_example m gflags pthread) - -add_custom_target( - run_call_trace_example ALL - DEPENDS ${example_HEADERS} - COMMAND call_trace_example - COMMENT "Running call_trace_example" -) - -add_dependencies(run_call_trace_example - call_trace_example -) \ No newline at end of file + call_trace_example.cc + ) +target_link_libraries(call_trace_example + albatross + gflags + pthread + ) +add_custom_target(run_call_trace_example + DEPENDS call_trace_example + COMMAND call_trace_example + COMMENT "Running call_trace_example" + ) diff --git a/examples/call_trace_example.cc b/examples/call_trace_example.cc index 67df6c33..d402dfc7 100644 --- a/examples/call_trace_example.cc +++ b/examples/call_trace_example.cc @@ -10,7 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "CovarianceFunctions" +#include namespace albatross { @@ -18,8 +18,7 @@ class LinearScalar : public ScalingFunction { public: std::string get_name() const override { return "linear_scalar"; } - double _call_impl((const double &x) const { - return 1. + 3. * x; } + double _call_impl(const double &x) const { return 1. + 3. * x; } }; auto complicated_covariance_function() { @@ -30,7 +29,7 @@ auto complicated_covariance_function() { return (constant + squared_exp) * linear_scalar; } -} +} // namespace albatross int main() { diff --git a/examples/example_utils.h b/examples/example_utils.h index 326cb279..c8ef10c0 100644 --- a/examples/example_utils.h +++ b/examples/example_utils.h @@ -13,13 +13,12 @@ #ifndef ALBATROSS_EXAMPLE_UTILS_H #define ALBATROSS_EXAMPLE_UTILS_H -#include "csv.h" +#include +#include +#include #include #include -#include "Core" -#include "csv_utils.h" - #define EXAMPLE_SLOPE_VALUE sqrt(2.) #define EXAMPLE_CONSTANT_VALUE 3.14159 diff --git a/examples/inspection.cc b/examples/inspection.cc index 87268b8d..c18cb54a 100644 --- a/examples/inspection.cc +++ b/examples/inspection.cc @@ -10,12 +10,11 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "gflags/gflags.h" +#include +#include #include "example_utils.h" -#include "GP" - DEFINE_string(input, "", "path to csv containing input data."); DEFINE_string(n, "10", "number of training points to use."); diff --git a/examples/sinc_example.cc b/examples/sinc_example.cc index bae8acba..fadc72f7 100644 --- a/examples/sinc_example.cc +++ b/examples/sinc_example.cc @@ -10,24 +10,22 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "gflags/gflags.h" - -#include "csv.h" +#include +#include #include +#include #include #include "sinc_example_utils.h" -#include "Tune" - DEFINE_string(input, "", "path to csv containing input data."); DEFINE_string(output, "", "path where predictions will be written in csv."); DEFINE_string(n, "10", "number of training points to use."); DEFINE_bool(tune, false, "a flag indication parameters should be tuned first."); +using albatross::get_tuner; using albatross::ParameterStore; using albatross::RegressionDataset; -using albatross::get_tuner; template albatross::ParameterStore tune_model(ModelType &model, diff --git a/examples/sinc_example_utils.h b/examples/sinc_example_utils.h index fd8bac5f..190f9f52 100644 --- a/examples/sinc_example_utils.h +++ b/examples/sinc_example_utils.h @@ -13,8 +13,8 @@ #ifndef ALBATROSS_SINC_EXAMPLE_UTILS_H #define ALBATROSS_SINC_EXAMPLE_UTILS_H -#include "GP" #include "example_utils.h" +#include namespace albatross { diff --git a/examples/temperature_example/temperature_example.cc b/examples/temperature_example/temperature_example.cc index 8dc74630..7c3ff85c 100644 --- a/examples/temperature_example/temperature_example.cc +++ b/examples/temperature_example/temperature_example.cc @@ -10,12 +10,11 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "gflags/gflags.h" +#include +#include #include "temperature_example_utils.h" -#include "Tune" - DEFINE_string(input, "", "path to csv containing input data."); DEFINE_string(predict, "", "path to csv containing prediction locations."); DEFINE_string(output, "", "path where predictions will be written in csv."); diff --git a/examples/temperature_example/temperature_example_utils.h b/examples/temperature_example/temperature_example_utils.h index 72f6467a..002ff192 100644 --- a/examples/temperature_example/temperature_example_utils.h +++ b/examples/temperature_example/temperature_example_utils.h @@ -13,12 +13,11 @@ #ifndef ALBATROSS_TEMPERATURE_EXAMPLE_UTILS_H #define ALBATROSS_TEMPERATURE_EXAMPLE_UTILS_H -#include "csv.h" +#include +#include +#include #include -#include "GP" -#include "csv_utils.h" - namespace albatross { /* diff --git a/include/albatross/Common b/include/albatross/Common index 35cb18b6..64837e1a 100644 --- a/include/albatross/Common +++ b/include/albatross/Common @@ -33,8 +33,10 @@ #include #include #include +#include #include +#include #include #include diff --git a/include/albatross/CovarianceFunctions b/include/albatross/CovarianceFunctions index 0688b710..b2cbfbfa 100644 --- a/include/albatross/CovarianceFunctions +++ b/include/albatross/CovarianceFunctions @@ -13,21 +13,21 @@ #ifndef ALBATROSS_COVARIANCE_FUNCTIONS_H #define ALBATROSS_COVARIANCE_FUNCTIONS_H -#include "Common" +#include -#include "core/declarations.h" -#include "core/traits.h" -#include "core/priors.h" -#include "core/parameter_handling_mixin.h" -#include "core/parameter_macros.h" +#include +#include +#include +#include +#include -#include "covariance_functions/traits.h" -#include "covariance_functions/covariance_function.h" -#include "covariance_functions/call_trace.h" -#include "covariance_functions/distance_metrics.h" -#include "covariance_functions/noise.h" -#include "covariance_functions/polynomials.h" -#include "covariance_functions/radial.h" -#include "covariance_functions/scaling_function.h" +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/include/albatross/Tune b/include/albatross/Tune index c396dda2..db8a0f09 100644 --- a/include/albatross/Tune +++ b/include/albatross/Tune @@ -13,11 +13,11 @@ #ifndef ALBATROSS_TUNE_INCLUDE_H #define ALBATROSS_TUNE_INCLUDE_H -#include "Core" -#include "Evaluation" +#include -#include "nlopt.hpp" -#include "tuning_metrics.h" -#include "tune.h" +#include +#include +#include +#include #endif diff --git a/include/albatross/cereal/traits.h b/include/albatross/cereal/traits.h index 7c79f6c5..e2198176 100644 --- a/include/albatross/cereal/traits.h +++ b/include/albatross/cereal/traits.h @@ -66,6 +66,6 @@ template class valid_in_out_serializer { public: static constexpr bool value = decltype(test(0))::value; }; -} +} // namespace albatross #endif diff --git a/include/albatross/core/declarations.h b/include/albatross/core/declarations.h index fbc0d55a..b4bbd374 100644 --- a/include/albatross/core/declarations.h +++ b/include/albatross/core/declarations.h @@ -94,6 +94,6 @@ template class CrossValidation; * RANSAC */ template class Ransac; -} +} // namespace albatross #endif diff --git a/include/albatross/core/fit_model.h b/include/albatross/core/fit_model.h index d8317ad1..78463491 100644 --- a/include/albatross/core/fit_model.h +++ b/include/albatross/core/fit_model.h @@ -52,5 +52,5 @@ template class FitModel { ModelType model_; Fit fit_; }; -} +} // namespace albatross #endif diff --git a/include/albatross/core/model.h b/include/albatross/core/model.h index 18442851..a444f942 100644 --- a/include/albatross/core/model.h +++ b/include/albatross/core/model.h @@ -143,5 +143,5 @@ template class ModelBase : public ParameterHandlingMixin { std::size_t min_inliers, std::size_t random_sample_size, std::size_t max_iterations) const; }; -} +} // namespace albatross #endif diff --git a/include/albatross/core/parameter_handling_mixin.h b/include/albatross/core/parameter_handling_mixin.h index 8a0c6184..1d472e49 100644 --- a/include/albatross/core/parameter_handling_mixin.h +++ b/include/albatross/core/parameter_handling_mixin.h @@ -120,8 +120,9 @@ inline std::string pretty_param_details(const ParameterStore ¶ms) { << " prior: " << std::setw(15) << prior_name << " bounds: [" << (pair.second.has_prior() ? pair.second.prior->lower_bound() : -INFINITY) - << ", " << (pair.second.has_prior() ? pair.second.prior->upper_bound() - : INFINITY) + << ", " + << (pair.second.has_prior() ? pair.second.prior->upper_bound() + : INFINITY) << "]" << std::endl; } return ss.str(); diff --git a/include/albatross/core/parameter_macros.h b/include/albatross/core/parameter_macros.h index 086ef53c..feedae75 100644 --- a/include/albatross/core/parameter_macros.h +++ b/include/albatross/core/parameter_macros.h @@ -96,37 +96,37 @@ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_1(_cond, _action, __VA_ARGS__) + _build_if_1(_cond, _action, __VA_ARGS__) #define _build_if_3(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_2(_cond, _action, __VA_ARGS__) + _build_if_2(_cond, _action, __VA_ARGS__) #define _build_if_4(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_3(_cond, _action, __VA_ARGS__) + _build_if_3(_cond, _action, __VA_ARGS__) #define _build_if_5(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_4(_cond, _action, __VA_ARGS__) + _build_if_4(_cond, _action, __VA_ARGS__) #define _build_if_6(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_5(_cond, _action, __VA_ARGS__) + _build_if_5(_cond, _action, __VA_ARGS__) #define _build_if_7(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_6(_cond, _action, __VA_ARGS__) + _build_if_6(_cond, _action, __VA_ARGS__) #define _build_if_8(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_7(_cond, _action, __VA_ARGS__) + _build_if_7(_cond, _action, __VA_ARGS__) #define BUILD_IF(cond, action, ...) \ _GET_NTH_ARG("ignored", ##__VA_ARGS__, _build_if_8, _build_if_7, \ diff --git a/include/albatross/core/prediction.h b/include/albatross/core/prediction.h index cb121bf2..868740c4 100644 --- a/include/albatross/core/prediction.h +++ b/include/albatross/core/prediction.h @@ -168,5 +168,5 @@ class Prediction { const FitType fit_; const std::vector features_; }; -} +} // namespace albatross #endif diff --git a/include/albatross/covariance_functions/call_trace.h b/include/albatross/covariance_functions/call_trace.h index 264cfbf6..81cd14eb 100644 --- a/include/albatross/covariance_functions/call_trace.h +++ b/include/albatross/covariance_functions/call_trace.h @@ -228,5 +228,5 @@ template inline CallTrace CovarianceFunction::call_trace() const { return CallTrace(this->derived()); }; -} +} // namespace albatross #endif diff --git a/include/albatross/covariance_functions/traits.h b/include/albatross/covariance_functions/traits.h index 65502494..725df302 100644 --- a/include/albatross/covariance_functions/traits.h +++ b/include/albatross/covariance_functions/traits.h @@ -115,7 +115,7 @@ struct BaseWithPublicCallImpl { template struct MultiInheritCallImpl : public U, public BaseWithPublicCallImpl {}; -} +} // namespace detail template class has_any_call_impl { template @@ -129,6 +129,6 @@ template class has_any_call_impl { public: static constexpr bool value = decltype(test(0))::value; }; -} +} // namespace albatross #endif diff --git a/include/albatross/eigen/serializable_diagonal_matrix.h b/include/albatross/eigen/serializable_diagonal_matrix.h index 5ad7c24b..2ed98c4e 100644 --- a/include/albatross/eigen/serializable_diagonal_matrix.h +++ b/include/albatross/eigen/serializable_diagonal_matrix.h @@ -44,6 +44,6 @@ class SerializableDiagonalMatrix } }; -} // namesapce Eigen +} // namespace Eigen #endif diff --git a/include/albatross/eigen/serializable_ldlt.h b/include/albatross/eigen/serializable_ldlt.h index 5bc0a89e..948857ff 100644 --- a/include/albatross/eigen/serializable_ldlt.h +++ b/include/albatross/eigen/serializable_ldlt.h @@ -13,12 +13,6 @@ #ifndef ALBATROSS_EIGEN_SERIALIZABLE_LDLT_H #define ALBATROSS_EIGEN_SERIALIZABLE_LDLT_H -#include "Eigen/Cholesky" -#include "Eigen/Dense" -#include "cereal/cereal.hpp" -#include "core/indexing.h" -#include - namespace Eigen { template @@ -175,6 +169,6 @@ class SerializableLDLT : public LDLT { } }; -} // namesapce Eigen +} // namespace Eigen #endif diff --git a/include/albatross/evaluation/folds.h b/include/albatross/evaluation/folds.h index e72414e5..3c83d576 100644 --- a/include/albatross/evaluation/folds.h +++ b/include/albatross/evaluation/folds.h @@ -180,6 +180,6 @@ dataset_size_from_folds(const std::vector> &folds) { return n + 1; } -} +} // namespace albatross #endif /* ALBATROSS_EVALUATION_FOLDS_H */ diff --git a/include/albatross/evaluation/traits.h b/include/albatross/evaluation/traits.h index 70aace75..1a90378c 100644 --- a/include/albatross/evaluation/traits.h +++ b/include/albatross/evaluation/traits.h @@ -47,6 +47,6 @@ using has_valid_cv_marginal = template using has_valid_cv_joint = has_valid_cross_validated_predictions; -} +} // namespace albatross #endif /* ALBATROSS_EVALUATION_TRAITS_H */ diff --git a/include/albatross/models/ransac.h b/include/albatross/models/ransac.h index 2a331d12..a80234ff 100644 --- a/include/albatross/models/ransac.h +++ b/include/albatross/models/ransac.h @@ -136,13 +136,14 @@ ransac(const RegressionDataset &dataset, return model.fit(subset(dataset, inds)); }; - typename RansacFunctions::InlierMetric inlier_metric = [&]( - const std::vector &inds, const FitType &fit) { - const auto pred = fit.predict(subset(dataset.features, inds)); - const auto target = subset(dataset.targets, inds); - const MetricPredictType prediction = pred.template get(); - return metric(prediction, target); - }; + typename RansacFunctions::InlierMetric inlier_metric = + [&](const std::vector &inds, const FitType &fit) { + const auto pred = fit.predict(subset(dataset.features, inds)); + const auto target = subset(dataset.targets, inds); + const MetricPredictType prediction = + pred.template get(); + return metric(prediction, target); + }; typename RansacFunctions::ModelMetric model_metric = [&](const std::vector &inds) { diff --git a/include/albatross/utils/csv_utils.h b/include/albatross/utils/csv_utils.h index acb9ead1..aac00b48 100644 --- a/include/albatross/utils/csv_utils.h +++ b/include/albatross/utils/csv_utils.h @@ -13,11 +13,8 @@ #ifndef ALBATROSS_CSV_UTILS_H #define ALBATROSS_CSV_UTILS_H -#include "core/model.h" #include -#include - -#include "cereal/external/rapidxml/rapidxml.hpp" +#include /* * This contains some tools which facilitate writing datasets and @@ -262,6 +259,6 @@ inline void write_to_csv(std::ostream &stream, } } } -} +} // namespace albatross #endif diff --git a/include/albatross/utils/random_utils.h b/include/albatross/utils/random_utils.h index 68daceda..eebe86fa 100644 --- a/include/albatross/utils/random_utils.h +++ b/include/albatross/utils/random_utils.h @@ -13,10 +13,6 @@ #ifndef ALBATROSS_RANDOM_UTILS_H #define ALBATROSS_RANDOM_UTILS_H -#include "core/indexing.h" -#include -#include - namespace albatross { /* * Samples integers between low and high (inclusive) with replacement. @@ -60,6 +56,6 @@ randint_without_replacement(std::size_t n, std::size_t low, std::size_t high, } return std::vector(samples.begin(), samples.end()); } -} +} // namespace albatross #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6623c1f9..2123548f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,51 +1,55 @@ - -add_definitions(-DCSV_IO_NO_THREAD) - add_executable(albatross_unit_tests -EXCLUDE_FROM_ALL - test_call_trace.cc - test_core_dataset.cc - test_core_distribution.cc - test_core_model.cc - test_covariance_function.cc - test_covariance_functions.cc - test_cross_validation.cc - test_csv_utils.cc - test_distance_metrics.cc - test_eigen_utils.cc - test_evaluate.cc - test_indexing.cc - test_map_utils.cc - test_model_adapter.cc - test_models.cc - test_parameter_handling_mixin.cc - test_prediction.cc - test_radial.cc - test_random_utils.cc - test_ransac.cc - test_scaling_function.cc - test_serializable_ldlt.cc - test_serialize.cc - test_traits_cereal.cc - test_traits_core.cc - test_traits_covariance_functions.cc - test_traits_evaluation.cc - test_tune.cc - test_tuning_metrics.cc -) - -add_dependencies(albatross_unit_tests - albatross -) - -target_link_libraries(albatross_unit_tests m gtest gtest_main pthread gflags nlopt) - -add_custom_target( -run_albatross_unit_tests ALL -COMMAND albatross_unit_tests -COMMENT "Running unit tests" -) - + EXCLUDE_FROM_ALL + test_call_trace.cc + test_core_dataset.cc + test_core_distribution.cc + test_core_model.cc + test_covariance_function.cc + test_covariance_functions.cc + test_cross_validation.cc + test_csv_utils.cc + test_distance_metrics.cc + test_eigen_utils.cc + test_evaluate.cc + test_indexing.cc + test_map_utils.cc + test_model_adapter.cc + test_models.cc + test_parameter_handling_mixin.cc + test_prediction.cc + test_radial.cc + test_random_utils.cc + test_ransac.cc + test_scaling_function.cc + test_serializable_ldlt.cc + test_serialize.cc + test_traits_cereal.cc + test_traits_core.cc + test_traits_covariance_functions.cc + test_traits_evaluation.cc + test_tune.cc + test_tuning_metrics.cc + ) +target_include_directories(albatross_unit_tests SYSTEM PRIVATE + "${gtest_SOURCE_DIR}" + "${gtest_SOURCE_DIR}/include" + ) +target_compile_definitions(albatross_unit_tests PRIVATE + CSV_IO_NO_THREAD + ) +target_link_libraries(albatross_unit_tests + albatross + gtest + gtest_main + pthread + gflags + nlopt + m + ) +add_custom_target(run_albatross_unit_tests ALL + COMMAND albatross_unit_tests + COMMENT "Running unit tests" + ) add_dependencies(run_albatross_unit_tests -albatross_unit_tests -) + albatross_unit_tests + ) diff --git a/tests/mock_model.h b/tests/mock_model.h index c099c4b0..0fe5b22d 100644 --- a/tests/mock_model.h +++ b/tests/mock_model.h @@ -119,6 +119,6 @@ mock_training_data(const int n = 10) { } return RegressionDataset(features, targets); } -} +} // namespace albatross #endif diff --git a/tests/test_call_trace.cc b/tests/test_call_trace.cc index aba6ed2a..bc9be540 100644 --- a/tests/test_call_trace.cc +++ b/tests/test_call_trace.cc @@ -9,8 +9,8 @@ * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "Core" -#include "CovarianceFunctions" +#include +#include #include diff --git a/tests/test_core_dataset.cc b/tests/test_core_dataset.cc index 6fb3a6eb..9a25a865 100644 --- a/tests/test_core_dataset.cc +++ b/tests/test_core_dataset.cc @@ -10,7 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "Dataset" +#include #include namespace albatross { diff --git a/tests/test_core_distribution.cc b/tests/test_core_distribution.cc index b9878bc7..60adb8a2 100644 --- a/tests/test_core_distribution.cc +++ b/tests/test_core_distribution.cc @@ -10,9 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Distribution" #include "test_core_distribution.h" namespace albatross { diff --git a/tests/test_core_distribution.h b/tests/test_core_distribution.h index f8728b5e..aa111196 100644 --- a/tests/test_core_distribution.h +++ b/tests/test_core_distribution.h @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Distribution" - namespace albatross { void expect_subset_equal(const Eigen::VectorXd &original, @@ -55,4 +54,4 @@ struct DistributionTest : public ::testing::Test { }; TYPED_TEST_CASE_P(DistributionTest); -} +} // namespace albatross diff --git a/tests/test_covariance_function.cc b/tests/test_covariance_function.cc index 63eaf2ae..e6ee2d04 100644 --- a/tests/test_covariance_function.cc +++ b/tests/test_covariance_function.cc @@ -10,7 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "CovarianceFunctions" +#include #include diff --git a/tests/test_covariance_functions.cc b/tests/test_covariance_functions.cc index e1607a84..13b9ffcd 100644 --- a/tests/test_covariance_functions.cc +++ b/tests/test_covariance_functions.cc @@ -11,8 +11,8 @@ */ #include -#include "Core" -#include "CovarianceFunctions" +#include +#include namespace albatross { diff --git a/tests/test_cross_validation.cc b/tests/test_cross_validation.cc index 0bb46230..8e90ec1c 100644 --- a/tests/test_cross_validation.cc +++ b/tests/test_cross_validation.cc @@ -10,13 +10,12 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include #include "test_models.h" -#include "Evaluation" - namespace albatross { // Group values by interval, but return keys that once sorted won't be diff --git a/tests/test_csv_utils.cc b/tests/test_csv_utils.cc index c2e59a25..7464367f 100644 --- a/tests/test_csv_utils.cc +++ b/tests/test_csv_utils.cc @@ -10,13 +10,11 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include +#include +#include #include -#include "Core" - -#include "csv.h" -#include "csv_utils.h" - namespace albatross { struct SubFeature { diff --git a/tests/test_distance_metrics.cc b/tests/test_distance_metrics.cc index 4c4abf1c..ea7fa84f 100644 --- a/tests/test_distance_metrics.cc +++ b/tests/test_distance_metrics.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "CovarianceFunctions" - #include "test_utils.h" namespace albatross { diff --git a/tests/test_eigen_utils.cc b/tests/test_eigen_utils.cc index 80a59941..c1f563db 100644 --- a/tests/test_eigen_utils.cc +++ b/tests/test_eigen_utils.cc @@ -11,11 +11,10 @@ */ #include +#include #include #include -#include "eigen_utils.h" - TEST(test_eigen_utils, test_dense_block_diag) { Eigen::MatrixXd A = Eigen::MatrixXd::Random(2, 2); diff --git a/tests/test_indexing.cc b/tests/test_indexing.cc index 381ed0e7..88be9fee 100644 --- a/tests/test_indexing.cc +++ b/tests/test_indexing.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Core" - namespace albatross { TEST(test_indexing, test_vector_subset) { diff --git a/tests/test_map_utils.cc b/tests/test_map_utils.cc index acf17f17..dd96675f 100644 --- a/tests/test_map_utils.cc +++ b/tests/test_map_utils.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Common" - namespace albatross { TEST(test_map_utils, test_map_contains) { diff --git a/tests/test_model_adapter.cc b/tests/test_model_adapter.cc index c07f448a..addb614a 100644 --- a/tests/test_model_adapter.cc +++ b/tests/test_model_adapter.cc @@ -102,4 +102,4 @@ TEST(test_model_adapter, test_fit) { EXPECT_EQ(adapted_fit.information, fit.information); EXPECT_EQ(adapted_fit.train_ldlt, fit.train_ldlt); } -} +} // namespace albatross diff --git a/tests/test_models.h b/tests/test_models.h index 287e3476..9839f72e 100644 --- a/tests/test_models.h +++ b/tests/test_models.h @@ -10,14 +10,13 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include +#include +#include #include #include "test_utils.h" -#include "GP" -#include "Ransac" -#include "models/least_squares.h" - namespace albatross { inline auto make_simple_covariance_function() { diff --git a/tests/test_prediction.cc b/tests/test_prediction.cc index 5204a521..5f2b8c90 100644 --- a/tests/test_prediction.cc +++ b/tests/test_prediction.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Core" - namespace albatross { struct X {}; diff --git a/tests/test_radial.cc b/tests/test_radial.cc index 5ab24bd9..a336f785 100644 --- a/tests/test_radial.cc +++ b/tests/test_radial.cc @@ -10,12 +10,11 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include "test_utils.h" -#include "CovarianceFunctions" - namespace albatross { inline auto random_spherical_dataset(std::vector points, diff --git a/tests/test_random_utils.cc b/tests/test_random_utils.cc index e56a1649..fb9d0ac5 100644 --- a/tests/test_random_utils.cc +++ b/tests/test_random_utils.cc @@ -9,10 +9,9 @@ * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include -#include "Common" - namespace albatross { TEST(test_random_utils, randint_without_replacement) { diff --git a/tests/test_ransac.cc b/tests/test_ransac.cc index c2c540cb..9c83a0f9 100644 --- a/tests/test_ransac.cc +++ b/tests/test_ransac.cc @@ -13,8 +13,8 @@ #include "test_models.h" -#include "Evaluation" -#include "Ransac" +#include +#include namespace albatross { diff --git a/tests/test_scaling_function.cc b/tests/test_scaling_function.cc index 04a582c0..2922fd20 100644 --- a/tests/test_scaling_function.cc +++ b/tests/test_scaling_function.cc @@ -10,12 +10,11 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include "test_utils.h" -#include "Evaluation" - namespace albatross { /* diff --git a/tests/test_serializable_ldlt.cc b/tests/test_serializable_ldlt.cc index ebe077b1..bb877d45 100644 --- a/tests/test_serializable_ldlt.cc +++ b/tests/test_serializable_ldlt.cc @@ -10,11 +10,10 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include +#include #include -#include "Common" -#include "eigen/serializable_ldlt.h" - namespace albatross { class SerializableLDLTTest : public ::testing::Test { diff --git a/tests/test_serialize.cc b/tests/test_serialize.cc index 70278a8d..07e2e12c 100644 --- a/tests/test_serialize.cc +++ b/tests/test_serialize.cc @@ -10,14 +10,12 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include "test_models.h" -#include "test_utils.h" - -#include "GP" - #include "test_serialize.h" +#include "test_utils.h" namespace albatross { diff --git a/tests/test_serialize.h b/tests/test_serialize.h index a216d057..9a2dc0cb 100644 --- a/tests/test_serialize.h +++ b/tests/test_serialize.h @@ -71,4 +71,4 @@ TYPED_TEST_P(SerializeTest, test_roundtrip_serialize_binary) { expect_roundtrip_serializable(); } -} +} // namespace albatross diff --git a/tests/test_traits_cereal.cc b/tests/test_traits_cereal.cc index dba0225d..ad291e74 100644 --- a/tests/test_traits_cereal.cc +++ b/tests/test_traits_cereal.cc @@ -10,7 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "cereal/traits.h" +#include #include namespace albatross { diff --git a/tests/test_traits_core.cc b/tests/test_traits_core.cc index 07bf83d5..50196431 100644 --- a/tests/test_traits_core.cc +++ b/tests/test_traits_core.cc @@ -10,8 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "Core" - +#include #include namespace albatross { diff --git a/tests/test_traits_covariance_functions.cc b/tests/test_traits_covariance_functions.cc index cbf80fbb..3609ddf8 100644 --- a/tests/test_traits_covariance_functions.cc +++ b/tests/test_traits_covariance_functions.cc @@ -10,8 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "CovarianceFunctions" - +#include #include namespace albatross { diff --git a/tests/test_traits_evaluation.cc b/tests/test_traits_evaluation.cc index da239f43..bf05aac3 100644 --- a/tests/test_traits_evaluation.cc +++ b/tests/test_traits_evaluation.cc @@ -10,8 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include "Evaluation" - +#include #include namespace albatross { diff --git a/tests/test_tune.cc b/tests/test_tune.cc index 938bdf62..53d87ecb 100644 --- a/tests/test_tune.cc +++ b/tests/test_tune.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include - -#include "Tune" #include "test_models.h" +#include +#include namespace albatross { diff --git a/tests/test_tuning_metrics.cc b/tests/test_tuning_metrics.cc index f8c38da2..bfc86065 100644 --- a/tests/test_tuning_metrics.cc +++ b/tests/test_tuning_metrics.cc @@ -10,10 +10,9 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include - -#include "Tune" #include "test_models.h" +#include +#include namespace albatross { diff --git a/tests/test_utils.h b/tests/test_utils.h index 6f86415c..11c4a452 100644 --- a/tests/test_utils.h +++ b/tests/test_utils.h @@ -13,11 +13,8 @@ #ifndef ALBATROSS_TESTS_TEST_UTILS_H #define ALBATROSS_TESTS_TEST_UTILS_H -#include "Core" - -#include "GP" - -#include +#include +#include #include "mock_model.h" From a62c5acbecb2c0e5f4e5eb567239f02039b536a3 Mon Sep 17 00:00:00 2001 From: kleeman Date: Tue, 26 Mar 2019 20:45:47 -0700 Subject: [PATCH 3/7] Move tuning code to tune directory. Add braces to high level include files. --- include/albatross/Common | 2 -- include/albatross/Core | 18 ++++++++++-------- include/albatross/Dataset | 4 ++-- include/albatross/Distribution | 10 +++++----- include/albatross/Evaluation | 12 ++++++------ include/albatross/GP | 7 +++---- include/albatross/LeastSquares | 18 ++++++++++++++++++ include/albatross/Ransac | 6 +++++- include/albatross/Tune | 4 ++-- include/albatross/{utils => tune}/tune.h | 0 .../albatross/{utils => tune}/tuning_metrics.h | 0 tests/test_evaluate.cc | 1 + tests/test_models.h | 2 +- tests/test_random_utils.cc | 6 +++++- tests/test_serializable_ldlt.cc | 2 +- 15 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 include/albatross/LeastSquares rename include/albatross/{utils => tune}/tune.h (100%) rename include/albatross/{utils => tune}/tuning_metrics.h (100%) diff --git a/include/albatross/Common b/include/albatross/Common index 64837e1a..c2c5192a 100644 --- a/include/albatross/Common +++ b/include/albatross/Common @@ -36,8 +36,6 @@ #include #include -#include -#include #include #endif diff --git a/include/albatross/Core b/include/albatross/Core index 46ff7c89..cc220eb4 100644 --- a/include/albatross/Core +++ b/include/albatross/Core @@ -16,13 +16,15 @@ #include "Dataset" #include -#include "core/declarations.h" -#include "core/traits.h" -#include "core/priors.h" -#include "core/parameter_handling_mixin.h" -#include "core/parameter_macros.h" -#include "core/fit_model.h" -#include "core/prediction.h" -#include "core/model.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/include/albatross/Dataset b/include/albatross/Dataset index b0cca95e..40b78839 100644 --- a/include/albatross/Dataset +++ b/include/albatross/Dataset @@ -13,8 +13,8 @@ #ifndef ALBATROSS_DATASET_H #define ALBATROSS_DATASET_H -#include "Distribution" +#include -#include "core/dataset.h" +#include #endif diff --git a/include/albatross/Distribution b/include/albatross/Distribution index 2a2a0abb..fdeb092b 100644 --- a/include/albatross/Distribution +++ b/include/albatross/Distribution @@ -15,11 +15,11 @@ #include "Common" -#include "cereal/traits.h" -#include "eigen/serializable_diagonal_matrix.h" +#include +#include -#include "core/declarations.h" -#include "core/indexing.h" -#include "core/distribution.h" +#include +#include +#include #endif diff --git a/include/albatross/Evaluation b/include/albatross/Evaluation index 1c8594a7..6a9de5ae 100644 --- a/include/albatross/Evaluation +++ b/include/albatross/Evaluation @@ -15,11 +15,11 @@ #include "Core" -#include "evaluation/likelihood.h" -#include "evaluation/traits.h" -#include "evaluation/folds.h" -#include "evaluation/evaluate.h" -#include "evaluation/cross_validation_utils.h" -#include "evaluation/cross_validation.h" +#include +#include +#include +#include +#include +#include #endif diff --git a/include/albatross/GP b/include/albatross/GP index 0660bf65..570bfdad 100644 --- a/include/albatross/GP +++ b/include/albatross/GP @@ -13,11 +13,10 @@ #ifndef ALBATROSS_GP_H #define ALBATROSS_GP_H +#include "Core" #include "CovarianceFunctions" -#include "Evaluation" -#include "eigen/serializable_ldlt.h" -#include "evaluation/cross_validation_utils.h" -#include "models/gp.h" +#include +#include #endif diff --git a/include/albatross/LeastSquares b/include/albatross/LeastSquares new file mode 100644 index 00000000..0f5a7090 --- /dev/null +++ b/include/albatross/LeastSquares @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2019 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef ALBATROSS_LEAST_SQUARES_H +#define ALBATROSS_LEAST_SQUARES_H + +#include + +#endif diff --git a/include/albatross/Ransac b/include/albatross/Ransac index 08048c2e..b981684d 100644 --- a/include/albatross/Ransac +++ b/include/albatross/Ransac @@ -13,6 +13,10 @@ #ifndef ALBATROSS_RANSAC_H #define ALBATROSS_RANSAC_H -#include "models/ransac.h" +#include "Core" +#include "Evaluation" + +#include +#include #endif diff --git a/include/albatross/Tune b/include/albatross/Tune index db8a0f09..ef7683f2 100644 --- a/include/albatross/Tune +++ b/include/albatross/Tune @@ -17,7 +17,7 @@ #include #include -#include -#include +#include +#include #endif diff --git a/include/albatross/utils/tune.h b/include/albatross/tune/tune.h similarity index 100% rename from include/albatross/utils/tune.h rename to include/albatross/tune/tune.h diff --git a/include/albatross/utils/tuning_metrics.h b/include/albatross/tune/tuning_metrics.h similarity index 100% rename from include/albatross/utils/tuning_metrics.h rename to include/albatross/tune/tuning_metrics.h diff --git a/tests/test_evaluate.cc b/tests/test_evaluate.cc index ade40bc0..95a71f55 100644 --- a/tests/test_evaluate.cc +++ b/tests/test_evaluate.cc @@ -12,6 +12,7 @@ #include +#include #include "test_utils.h" namespace albatross { diff --git a/tests/test_models.h b/tests/test_models.h index 9839f72e..fb164a6c 100644 --- a/tests/test_models.h +++ b/tests/test_models.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "test_utils.h" diff --git a/tests/test_random_utils.cc b/tests/test_random_utils.cc index fb9d0ac5..2f4df1b2 100644 --- a/tests/test_random_utils.cc +++ b/tests/test_random_utils.cc @@ -9,9 +9,13 @@ * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include #include +#include + +#include +#include + namespace albatross { TEST(test_random_utils, randint_without_replacement) { diff --git a/tests/test_serializable_ldlt.cc b/tests/test_serializable_ldlt.cc index bb877d45..600f56eb 100644 --- a/tests/test_serializable_ldlt.cc +++ b/tests/test_serializable_ldlt.cc @@ -10,7 +10,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. */ -#include +#include #include #include From 1fc47a32be71ee515a3624ddfbfc9dba67ac0f44 Mon Sep 17 00:00:00 2001 From: kleeman Date: Wed, 27 Mar 2019 10:16:36 -0700 Subject: [PATCH 4/7] remove set(CMAKE_CXX_FLAGS) --- CMakeLists.txt | 64 ++++++++++++++++++++++++++++++++++++++++---- tests/CMakeLists.txt | 1 - 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 768e10a6..bbb83954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,12 +24,66 @@ target_include_directories(albatross SYSTEM INTERFACE "${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/" ) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -fexceptions -frtti") -set(CMAKE_CXX_FLAGS "-std=c++14 -Wshadow -Wswitch-default -Wswitch-enum -Wundef -Wpointer-arith -Wcast-align -Wformat=2 -Wredundant-decls ${CMAKE_CXX_FLAGS}") -set("LOG_LEVEL=8") - include(${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake) add_subdirectory(tests) add_subdirectory(examples) + +set(albatross_BINARIES + albatross_unit_tests + sinc_example + temperature_example + call_trace_example + inspection_example + ) + + +set(albatross_COMPILE_OPTIONS + -Werror + -Wall + -Wno-unused-value + -Wcast-align + -Wchar-subscripts + -Wcomment + -Wdisabled-optimization + -Wformat + -Wformat=2 + -Wformat-nonliteral + -Wformat-security + -Wformat-y2k + -Wimport + -Winit-self + -Winvalid-pch + -Wmissing-braces + -Wmissing-field-initializers + -Wmissing-format-attribute + -Wmissing-include-dirs + -Wparentheses + -Wpointer-arith + -Wredundant-decls + -Wreturn-type + -Wsequence-point + -Wsign-compare + -Wstack-protector + -Wswitch + -Wtrigraphs + -Wuninitialized + -Wunknown-pragmas + -Wunused + -Wunused-function + -Wunused-label + -Wunused-variable + -Wunused-value + -Wunused-variable + -Wvolatile-register-var + -Wwrite-strings + ) +set_target_properties( + ${albatross_BINARIES} + PROPERTIES + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + ) +foreach(TARGET IN LISTS albatross_BINARIES) + target_compile_options(${TARGET} PRIVATE ${albatross_COMPILE_OPTIONS}) +endforeach() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2123548f..7663b17e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,7 +44,6 @@ target_link_libraries(albatross_unit_tests pthread gflags nlopt - m ) add_custom_target(run_albatross_unit_tests ALL COMMAND albatross_unit_tests From f23bee6d1194cd8470ed79ec6c3e5d2437bf25bd Mon Sep 17 00:00:00 2001 From: kleeman Date: Wed, 27 Mar 2019 10:27:56 -0700 Subject: [PATCH 5/7] Use relative path between umbrella includes --- include/albatross/CovarianceFunctions | 2 +- include/albatross/Dataset | 2 +- include/albatross/LeastSquares | 2 ++ include/albatross/Tune | 5 +++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/albatross/CovarianceFunctions b/include/albatross/CovarianceFunctions index b2cbfbfa..ece755c8 100644 --- a/include/albatross/CovarianceFunctions +++ b/include/albatross/CovarianceFunctions @@ -13,7 +13,7 @@ #ifndef ALBATROSS_COVARIANCE_FUNCTIONS_H #define ALBATROSS_COVARIANCE_FUNCTIONS_H -#include +#include "Common" #include #include diff --git a/include/albatross/Dataset b/include/albatross/Dataset index 40b78839..c3475f42 100644 --- a/include/albatross/Dataset +++ b/include/albatross/Dataset @@ -13,7 +13,7 @@ #ifndef ALBATROSS_DATASET_H #define ALBATROSS_DATASET_H -#include +#include "Distribution" #include diff --git a/include/albatross/LeastSquares b/include/albatross/LeastSquares index 0f5a7090..0a769d92 100644 --- a/include/albatross/LeastSquares +++ b/include/albatross/LeastSquares @@ -13,6 +13,8 @@ #ifndef ALBATROSS_LEAST_SQUARES_H #define ALBATROSS_LEAST_SQUARES_H +#include "Core" + #include #endif diff --git a/include/albatross/Tune b/include/albatross/Tune index ef7683f2..c4bef4ef 100644 --- a/include/albatross/Tune +++ b/include/albatross/Tune @@ -15,8 +15,9 @@ #include -#include -#include +#include "Core" +#include "Evaluation" + #include #include From 4b9783443473a7ad42b5e14c28c04be0e454da8a Mon Sep 17 00:00:00 2001 From: kleeman Date: Wed, 27 Mar 2019 17:28:56 -0700 Subject: [PATCH 6/7] Revert back to clang-3.8 since that comes with travis --- cmake/ClangTools.cmake | 3 +-- include/albatross/core/parameter_handling_mixin.h | 5 ++--- include/albatross/core/parameter_macros.h | 14 +++++++------- include/albatross/models/ransac.h | 15 +++++++-------- tests/test_evaluate.cc | 2 +- tests/test_models.h | 2 +- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/cmake/ClangTools.cmake b/cmake/ClangTools.cmake index ffd5d419..5bd57015 100644 --- a/cmake/ClangTools.cmake +++ b/cmake/ClangTools.cmake @@ -22,8 +22,7 @@ endif(CMAKE_CROSSCOMPILING) set(CLANG_FORMAT_PATH "NOTSET" CACHE STRING "Absolute path to the clang-format executable") if("${CLANG_FORMAT_PATH}" STREQUAL "NOTSET") find_program(CLANG_FORMAT NAMES - clang-format-6.0 - clang-format-4.0 + clang-format-3.8 ) message(STATUS "Using clang format: ${CLANG_FORMAT}") if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND") diff --git a/include/albatross/core/parameter_handling_mixin.h b/include/albatross/core/parameter_handling_mixin.h index 1d472e49..8a0c6184 100644 --- a/include/albatross/core/parameter_handling_mixin.h +++ b/include/albatross/core/parameter_handling_mixin.h @@ -120,9 +120,8 @@ inline std::string pretty_param_details(const ParameterStore ¶ms) { << " prior: " << std::setw(15) << prior_name << " bounds: [" << (pair.second.has_prior() ? pair.second.prior->lower_bound() : -INFINITY) - << ", " - << (pair.second.has_prior() ? pair.second.prior->upper_bound() - : INFINITY) + << ", " << (pair.second.has_prior() ? pair.second.prior->upper_bound() + : INFINITY) << "]" << std::endl; } return ss.str(); diff --git a/include/albatross/core/parameter_macros.h b/include/albatross/core/parameter_macros.h index feedae75..086ef53c 100644 --- a/include/albatross/core/parameter_macros.h +++ b/include/albatross/core/parameter_macros.h @@ -96,37 +96,37 @@ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_1(_cond, _action, __VA_ARGS__) + _build_if_1(_cond, _action, __VA_ARGS__) #define _build_if_3(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_2(_cond, _action, __VA_ARGS__) + _build_if_2(_cond, _action, __VA_ARGS__) #define _build_if_4(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_3(_cond, _action, __VA_ARGS__) + _build_if_3(_cond, _action, __VA_ARGS__) #define _build_if_5(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_4(_cond, _action, __VA_ARGS__) + _build_if_4(_cond, _action, __VA_ARGS__) #define _build_if_6(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_5(_cond, _action, __VA_ARGS__) + _build_if_5(_cond, _action, __VA_ARGS__) #define _build_if_7(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_6(_cond, _action, __VA_ARGS__) + _build_if_6(_cond, _action, __VA_ARGS__) #define _build_if_8(_cond, _action, x, ...) \ if (_cond(x)) { \ _action(x); \ } else \ - _build_if_7(_cond, _action, __VA_ARGS__) + _build_if_7(_cond, _action, __VA_ARGS__) #define BUILD_IF(cond, action, ...) \ _GET_NTH_ARG("ignored", ##__VA_ARGS__, _build_if_8, _build_if_7, \ diff --git a/include/albatross/models/ransac.h b/include/albatross/models/ransac.h index a80234ff..2a331d12 100644 --- a/include/albatross/models/ransac.h +++ b/include/albatross/models/ransac.h @@ -136,14 +136,13 @@ ransac(const RegressionDataset &dataset, return model.fit(subset(dataset, inds)); }; - typename RansacFunctions::InlierMetric inlier_metric = - [&](const std::vector &inds, const FitType &fit) { - const auto pred = fit.predict(subset(dataset.features, inds)); - const auto target = subset(dataset.targets, inds); - const MetricPredictType prediction = - pred.template get(); - return metric(prediction, target); - }; + typename RansacFunctions::InlierMetric inlier_metric = [&]( + const std::vector &inds, const FitType &fit) { + const auto pred = fit.predict(subset(dataset.features, inds)); + const auto target = subset(dataset.targets, inds); + const MetricPredictType prediction = pred.template get(); + return metric(prediction, target); + }; typename RansacFunctions::ModelMetric model_metric = [&](const std::vector &inds) { diff --git a/tests/test_evaluate.cc b/tests/test_evaluate.cc index 95a71f55..f63d5c42 100644 --- a/tests/test_evaluate.cc +++ b/tests/test_evaluate.cc @@ -12,8 +12,8 @@ #include -#include #include "test_utils.h" +#include namespace albatross { diff --git a/tests/test_models.h b/tests/test_models.h index fb164a6c..24519753 100644 --- a/tests/test_models.h +++ b/tests/test_models.h @@ -11,8 +11,8 @@ */ #include -#include #include +#include #include #include "test_utils.h" From f99223f3d71a6c0478aca78a1ba610a333532ecc Mon Sep 17 00:00:00 2001 From: kleeman Date: Thu, 28 Mar 2019 08:19:43 -0700 Subject: [PATCH 7/7] Martin's comments --- CMakeLists.txt | 24 +++--------------------- examples/CMakeLists.txt | 19 +++++++++++++++++++ examples/sinc_example_utils.h | 3 ++- tests/CMakeLists.txt | 12 ++++++++++-- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbb83954..a555eb90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,18 +26,6 @@ target_include_directories(albatross SYSTEM INTERFACE include(${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake) -add_subdirectory(tests) -add_subdirectory(examples) - -set(albatross_BINARIES - albatross_unit_tests - sinc_example - temperature_example - call_trace_example - inspection_example - ) - - set(albatross_COMPILE_OPTIONS -Werror -Wall @@ -78,12 +66,6 @@ set(albatross_COMPILE_OPTIONS -Wvolatile-register-var -Wwrite-strings ) -set_target_properties( - ${albatross_BINARIES} - PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON - ) -foreach(TARGET IN LISTS albatross_BINARIES) - target_compile_options(${TARGET} PRIVATE ${albatross_COMPILE_OPTIONS}) -endforeach() + +add_subdirectory(tests) +add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3e91308c..e3e2f754 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -58,3 +58,22 @@ add_custom_target(run_call_trace_example COMMAND call_trace_example COMMENT "Running call_trace_example" ) + +set(albatross_example_BINARIES + sinc_example + temperature_example + call_trace_example + inspection_example + ) + + +set_target_properties( + ${albatross_example_BINARIES} + PROPERTIES + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + ) +foreach(TARGET IN LISTS albatross_example_BINARIES) + target_compile_options(${TARGET} PRIVATE ${albatross_COMPILE_OPTIONS}) +endforeach() + diff --git a/examples/sinc_example_utils.h b/examples/sinc_example_utils.h index 190f9f52..d5f80368 100644 --- a/examples/sinc_example_utils.h +++ b/examples/sinc_example_utils.h @@ -13,9 +13,10 @@ #ifndef ALBATROSS_SINC_EXAMPLE_UTILS_H #define ALBATROSS_SINC_EXAMPLE_UTILS_H -#include "example_utils.h" #include +#include "example_utils.h" + namespace albatross { class SlopeTerm : public CovarianceFunction { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7663b17e..ce17d36e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,4 @@ -add_executable(albatross_unit_tests - EXCLUDE_FROM_ALL +add_executable(albatross_unit_tests EXCLUDE_FROM_ALL test_call_trace.cc test_core_dataset.cc test_core_distribution.cc @@ -52,3 +51,12 @@ add_custom_target(run_albatross_unit_tests ALL add_dependencies(run_albatross_unit_tests albatross_unit_tests ) + +set_target_properties( + albatross_unit_tests + PROPERTIES + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + ) + +target_compile_options(albatross_unit_tests PRIVATE ${albatross_COMPILE_OPTIONS})