Skip to content

Commit

Permalink
7.0.2 (#144)
Browse files Browse the repository at this point in the history
* use nlohmann string conversion not unsafe cast

* remove non-trivial designated initializers

* add more non-trivial designated initializers.

* now use nlohmann_json as a dependecy. it could be installed via conan by using the option multiple_headers=True

* remove expilicit set fPIC flag

* start to add @SpaceIm [patches](https://github.com/SpaceIm/conan-proposal/tree/daeb91349d83d0b8a53b1292eba28a4af728abd5/patches).

add 0001 expected the patch in methods.cxx. There we have to check if the functions are still used.

0002 already added in [7cd5e10](7cd5e10). There seems to be a problem becaus the json_fwd.hpp is not populated if the requirements is installed via conan.

0003 not yet done.

add 0004

0005 already done in [c5118c7](c5118c7)

add 0006

* Fix pypi deploy (#140)

Adapt CC and CXX flag and python version to meet conditions for pypi deploy

* update setup.py to use nlohman multiple_headers

* Make use of extern template.  Use temporary json.hpp instead of json_fwd.hpp which increase build time signifikant, but is temporary required to make CCI run.

* delete unused functions in methdos.h

* fix: take into account that a string wan't be copied if it passe by value

* Move template specification definition from cxx to header

* Revert "Move template specification definition from cxx to header"

This reverts commit ecb7b1f.

* Try different approach in implementing templates

* Revert "Try different approach in implementing templates"

This reverts commit a11b4bf.

* Use macro version to fix templates on windows

* Correct case-insensitive comparison operator
Add missing quotation mark in setup.py

* remove nlohmann_json:multiple_headers  flag

* Set position independent code cmake variable for pypi

* Set CXX_VISIBILTY_PRESET to hidden, should fix #141

* Change CMAKE_CXX_VISIBILITY_PRESET only for static library, otherwise clang won't compile

* Catch negative values for IonizBetheBlochRossi::InelCorrection to avoid negative integrand values. This should avoid sporadic qags-warnings when creating ionization interpolation tables.

* Revert "Catch negative values for IonizBetheBlochRossi::InelCorrection to avoid negative integrand values. This should avoid sporadic qags-warnings when creating ionization interpolation tables."

This reverts commit 273d1c0.

* Change `build_XXX` conan options to `with_XXX` as recommended by conan developers

Co-authored-by: Maximilian Sackel <[email protected]>
  • Loading branch information
Jean1995 and MaxSac authored Apr 16, 2021
1 parent 188d2a9 commit 44265c6
Show file tree
Hide file tree
Showing 64 changed files with 161 additions and 23,308 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- os: linux
dist: focal
name: Linux gcc 7
python: 3.8
python: 3.9
addons:
apt:
sources:
Expand All @@ -49,7 +49,7 @@ jobs:
- os: linux
dist: focal
name: Linux gcc 10
python: 3.8
python: 3.9
addons:
apt:
sources:
Expand All @@ -63,7 +63,7 @@ jobs:
- os: linux
dist: focal
name: Linux clang 6.0
python: 3.8
python: 3.9
addons:
apt:
sources:
Expand All @@ -78,7 +78,7 @@ jobs:
- os: linux
dist: focal
name: Linux clang 10
python: 3.8
python: 3.9
addons:
apt:
sources:
Expand All @@ -96,7 +96,7 @@ install:
- conan profile new default --detect
- conan profile update settings.compiler.libcxx=libstdc++11 default
- mkdir build && cd build
- conan install .. -o build_testing=True --build=missing
- conan install .. -o with_testing=True -o nlohmann_json:multiple_headers=True --build=missing
- conan build ..
- echo "Searching for test file path"
- echo $(pwd)
Expand All @@ -122,7 +122,7 @@ deploy:
on:
repo: tudo-astroparticlephysics/PROPOSAL
tags: true
condition: $CXX = g++-10
condition: $CXX = g++
- provider: pypi
username: "__token__"
skip_existing: true
Expand All @@ -134,4 +134,4 @@ deploy:
repo: tudo-astroparticlephysics/PROPOSAL
tags: true
branch: master
condition: $TRAVIS_PYTHON_VERSION = "3.8"
condition: $TRAVIS_PYTHON_VERSION = "3.9"
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# removes tons of compiler warnings on clang (issue #141). there is probably a cleaner solution.
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif()

option(BUILD_PYTHON "build python interface" OFF)
option(BUILD_EXAMPLE "build example" OFF)
option(BUILD_DOCUMENTATION "build documentation" OFF)
Expand Down
12 changes: 6 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ $ cd PROPOSAL && mkdir build && cd build
Use conan to prepare all dependencies. You can pass additional options to conan.

```sh
$ conan install .. -o build_python=True # other optional dependencies
$ conan install .. -o with_python=True # other optional dependencies
```

The following options can be passed to `conan install`:

| Option. | default | Description |
| --------------------- | ------- | --------------------------------------------- |
| `build_python` | False | Build and install python interface. |
| `build_testing` | False | Build TestFiles for Python. |
| `build_documentation` | False | Build doxygen documentation of C++ code (WIP) |
| Option. | default | Description |
| -------------------- | ------- | --------------------------------------------- |
| `with_python` | False | Build and install python interface. |
| `with_testing` | False | Build TestFiles for Python. |
| `with_documentation` | False | Build doxygen documentation of C++ code (WIP) |

Build and install PROPOSAL. You may require root privileges when installing, depending on the installation location:

Expand Down
25 changes: 13 additions & 12 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class PROPOSALConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_testing": [True, False],
"build_python": [True, False],
"build_documentation": [True, False],
"with_testing": [True, False],
"with_python": [True, False],
"with_documentation": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_testing": False,
"build_python": False,
"build_documentation": False,
"with_testing": False,
"with_python": False,
"with_documentation": False,
}
generators = "cmake_find_package", "cmake_paths"
_cmake = None
Expand All @@ -34,20 +34,21 @@ def config_options(self):
def requirements(self):
self.requires("cubicinterpolation/0.1.4")
self.requires("spdlog/1.8.2")
if self.options.build_python:
self.requires("nlohmann_json/3.9.1")
if self.options.with_python:
self.requires("pybind11/2.6.2")
if self.options.build_testing:
if self.options.with_testing:
self.requires("gtest/1.10.0")
if self.options.build_documentation:
if self.options.with_documentation:
self.requires("doxygen/1.8.20")

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_TESTING"] = self.options.build_testing
self._cmake.definitions["BUILD_PYTHON"] = self.options.build_python
self._cmake.definitions["BUILD_DOCUMENTATION"] = self.options.build_documentation
self._cmake.definitions["BUILD_TESTING"] = self.options.with_testing
self._cmake.definitions["BUILD_PYTHON"] = self.options.with_python
self._cmake.definitions["BUILD_DOCUMENTATION"] = self.options.with_documentation
self._cmake.configure()
return self._cmake

Expand Down
1 change: 1 addition & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ classifiers=
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Physics
Development Status :: 5 - Production/Stable
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def build_cmake(self, ext):
'conan',
'install',
ext.source_dir,
'-o build_python=True',
'-o build_testing=False',
'-o with_python=True',
'-o with_testing=False'
]
sp.run(conan_call, cwd=self.build_temp, check=True)
os.remove(self.build_temp + "/Findpybind11.cmake") # bugfix
Expand All @@ -85,6 +85,7 @@ def build_cmake(self, ext):
'-DCMAKE_BUILD_TYPE=' + cfg,
'-DBUILD_TESTING=OFF',
'-DBUILD_PYTHON=ON',
'-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE',
'-DBUILD_EXAMPLE=OFF',
'-DPYTHON_EXECUTABLE=' + sys.executable,
'-DPYTHON_LIBRARY=' + str(python_lib),
Expand Down
10 changes: 7 additions & 3 deletions src/PROPOSAL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ include(GNUInstallDirs)
add_library(PROPOSAL)
add_library(PROPOSAL::PROPOSAL ALIAS PROPOSAL)

set_target_properties(PROPOSAL PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
if(MSVC)
target_compile_options(PROPOSAL PRIVATE "/bigobj" "/EHsc")
elseif(MINGW)
target_compile_options(PROPOSAL PRIVATE "-Wa,-mbig-obj")
endif()

target_include_directories(PROPOSAL PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -15,13 +17,15 @@ target_include_directories(PROPOSAL PUBLIC

find_package(CubicInterpolation REQUIRED)
find_package(spdlog REQUIRED)
find_package(nlohmann_json REQUIRED)

add_subdirectory(PROPOSAL)
add_subdirectory(detail)

target_link_libraries(PROPOSAL
CubicInterpolation::CubicInterpolation
spdlog::spdlog
nlohmann_json::nlohmann_json
)

install(TARGETS PROPOSAL EXPORT PROPOSALTargets
Expand Down
1 change: 1 addition & 0 deletions src/PROPOSAL/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ endif()

find_package(CubicInterpolation REQUIRED)
find_package(spdlog REQUIRED)
find_package(nlohmann_json REQUIRED)

include ("${CMAKE_CURRENT_LIST_DIR}/PROPOSALTargets.cmake")
2 changes: 1 addition & 1 deletion src/PROPOSAL/PROPOSAL/EnergyCutSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#pragma once

#include "PROPOSAL/json.hpp"
#include <nlohmann/json.hpp>
#include <ostream>

namespace PROPOSAL {
Expand Down
2 changes: 1 addition & 1 deletion src/PROPOSAL/PROPOSAL/Propagator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "PROPOSAL/Secondaries.h"
#include "PROPOSAL/json.hpp"
#include <nlohmann/json.hpp>
#include <unordered_map>

namespace PROPOSAL {
Expand Down
8 changes: 4 additions & 4 deletions src/PROPOSAL/PROPOSAL/crosssection/CrossSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace detail {
using dndx_map_t
= std::unordered_map<size_t, std::tuple<double, dndx_ptr_t>>;
if (cut)
if (cut->GetEcut() == INF and cut->GetVcut() == 1)
if (cut->GetEcut() == INF && cut->GetVcut() == 1)
return std::unique_ptr<dndx_map_t>();
auto calc = make_dndx(interpol, param, p, m, cut, hash);
auto dndx_map = std::make_unique<dndx_map_t>();
Expand All @@ -95,7 +95,7 @@ namespace detail {
= std::unordered_map<size_t, std::tuple<double, dndx_ptr_t>>;
if (cut) // TODO: is this branch realy necessary, why is a dndx created
// for these settings?
if (cut->GetEcut() == INF and cut->GetVcut() == 1)
if (cut->GetEcut() == INF && cut->GetVcut() == 1)
return std::unique_ptr<dndx_map_t>();
auto dndx_map = std::make_unique<dndx_map_t>();
for (auto& c : m.GetComponents()) {
Expand Down Expand Up @@ -335,7 +335,7 @@ class CrossSection : public CrossSectionBase {
inline double CalculatedEdx(double energy) override
{
auto loss = 0.;
if (not dedx)
if (!dedx)
return loss;
// will produce no working in cpp17
// for (auto& [weight, calc] : *dedx)
Expand All @@ -349,7 +349,7 @@ class CrossSection : public CrossSectionBase {
inline double CalculatedE2dx(double energy) override
{
auto loss = 0.;
if (not de2dx)
if (!de2dx)
return loss;
// will produce no working in cpp17
// for (auto& [weight, calc] : *de2dx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,27 @@ std::function<double(double, double, double)> retransform_loss<Param>::func
namespace crosssection {
struct ComptonKleinNishina;
}
template <>

#ifndef CROSSSECTIONDNDXINTERPOLANT_INSTANTIATION
extern template
std::function<double(double, double, double)> transform_loss<crosssection::ComptonKleinNishina>::func;
#endif

template <>
#ifndef CROSSSECTIONDNDXINTERPOLANT_INSTANTIATION
extern template
std::function<double(double, double, double)> retransform_loss<crosssection::ComptonKleinNishina>::func;
#endif

template <typename T1, typename... Args>
auto build_dndx_def(T1 const& param, ParticleDef const& p, Args... args)
{
auto dndx = std::make_shared<CrossSectionDNDXIntegral>(param, p, args...);
auto v_lim = AxisBuilderDNDX::v_limits { 0, 1,
InterpolationSettings::NODES_DNDX_V };
auto energy_lim
= AxisBuilderDNDX::energy_limits { param.GetLowerEnergyLim(p),
InterpolationSettings::UPPER_ENERGY_LIM,
InterpolationSettings::NODES_DNDX_E };
auto energy_lim = AxisBuilderDNDX::energy_limits();
energy_lim.low = param.GetLowerEnergyLim(p);
energy_lim.up = InterpolationSettings::UPPER_ENERGY_LIM;
energy_lim.nodes = InterpolationSettings::NODES_DNDX_E ;
auto axis_builder = AxisBuilderDNDX(v_lim, energy_lim);
axis_builder.refine_definition_range(
[dndx](double E) { return dndx->Calculate(E); });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged
#include <memory>

namespace PROPOSAL {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include "PROPOSAL/json_fwd.hpp"
#include <nlohmann/json.hpp> // TODO: Use json_fwd.hpp as soon as https://github.com/conan-io/conan-center-index/pull/5149 is merged

namespace PROPOSAL {
struct CrossSectionBase;
Expand Down
4 changes: 2 additions & 2 deletions src/PROPOSAL/PROPOSAL/density_distr/density_distr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <functional>
#include <string>
#include "PROPOSAL/math/Cartesian3D.h"
#include "PROPOSAL/json.hpp"
#include <nlohmann/json.hpp>

namespace PROPOSAL {
class Axis {
Expand Down Expand Up @@ -147,4 +147,4 @@ class Density_distr {

namespace PROPOSAL {
std::shared_ptr<Density_distr> CreateDensityDistribution(const nlohmann::json&);
} // namespace PROPOSAL
} // namespace PROPOSAL
2 changes: 1 addition & 1 deletion src/PROPOSAL/PROPOSAL/geometry/Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#pragma once

#include "PROPOSAL/geometry/Geometry.h"
#include "PROPOSAL/json.hpp"
#include <nlohmann/json.hpp>


namespace PROPOSAL {
Expand Down
Loading

0 comments on commit 44265c6

Please sign in to comment.