Updates from #370 (#397)

This PR keeps the useful changes from PR #370, which was never finished.
This commit is contained in:
Hans Dembinski 2024-04-24 17:39:24 +02:00 committed by GitHub
parent b11364eb99
commit cd3e1110cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 51 additions and 14 deletions

View File

@ -22,7 +22,7 @@ jobs:
cov:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch Boost superproject
run: |
cd ..

View File

@ -32,7 +32,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: prepare build
run: |
mkdir build

View File

@ -25,7 +25,7 @@ jobs:
appleclang:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch Boost superproject
run: |
cd ..
@ -49,7 +49,7 @@ jobs:
gcc7:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: egor-tensin/setup-gcc@v1
with:
version: 7
@ -73,7 +73,7 @@ jobs:
gcc10:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch Boost superproject
run: |
cd ..
@ -94,7 +94,7 @@ jobs:
clang14:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch Boost superproject
run: |
cd ..

View File

@ -14,7 +14,7 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch Boost superproject
run: |
cd ..

View File

@ -11,7 +11,7 @@ add_library(boost_histogram INTERFACE)
add_library(Boost::histogram ALIAS boost_histogram)
target_include_directories(boost_histogram INTERFACE include)
target_compile_features(boost_histogram INTERFACE cxx_std_14)
target_link_libraries(boost_histogram
INTERFACE
Boost::config
@ -22,6 +22,8 @@ target_link_libraries(boost_histogram
Boost::math
)
target_compile_features(boost_histogram INTERFACE cxx_std_14)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Standalone build, fetch dependencies

View File

@ -9,7 +9,13 @@
**Multi-dimensional generalised histograms with convenient interface**
Coded with ❤. Powered by the [Boost community](https://www.boost.org) and the [Scikit-HEP Project](http://scikit-hep.org). Licensed under the [Boost Software License](http://www.boost.org/LICENSE_1_0.txt).
Coded with ❤. Powered by the [Boost community](https://www.boost.org) and the [Scikit-HEP Project](http://scikit-hep.org).
## License
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
## Properties
**Supported compiler versions** gcc >= 5.5, clang >= 3.8, msvc >= 14.1
**Supported C++ versions** 14, 17, 20
@ -33,7 +39,7 @@ Check out the [full documentation](https://www.boost.org/doc/libs/master/libs/hi
💡 Boost.Histogram is a mature library with 100 % of code lines covered by unit tests, is benchmarked for performance, and has extensive documentation. If you still find some issue or find the documentation lacking, tell us about it by [submitting an issue](https://github.com/boostorg/histogram/issues). Chat with us on the [Boost channel on Slack](https://cpplang.slack.com) and [Gitter](https://gitter.im/boostorg/histogram).
## Code examples
## Code example
The following stripped-down example was taken from the [Getting started](https://www.boost.org/doc/libs/master/libs/histogram/doc/html/histogram/getting_started.html) section in the documentation. Have a look into the docs to see the full version with comments and more examples.
@ -115,3 +121,10 @@ Details on the benchmark are given in the [documentation](https://www.boost.org/
**John Buonagurio** | Manager at [**E<sup><i>x</i></sup>ponent<sup>&reg;</sup>**](https://www.exponent.com)
*"I just wanted to say 'thanks' for your awesome Histogram library. I'm working on a software package for processing meteorology data and I'm using it to generate wind roses with the help of Qt and QwtPolar. Looks like you thought of just about everything here &ndash; the circular axis type was practically designed for this application, everything 'just worked'."*
## More information
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-template)
* [Report bugs](https://github.com/boostorg/template/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[template]` tag at the beginning of the subject line.

View File

@ -83,7 +83,7 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
large_int& operator+=(const large_int& o) {
if (this == &o) {
auto tmp{o};
auto tmp = o; // make a copy
return operator+=(tmp);
}
bool carry = false;

View File

@ -40,6 +40,8 @@ boost_test(TYPE compile-fail SOURCES histogram_fail4.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::histogram Boost::core)
boost_test(TYPE run SOURCES quick.cpp)
boost_test(TYPE run SOURCES accumulators_count_test.cpp)
boost_test(TYPE run SOURCES accumulators_mean_test.cpp)
boost_test(TYPE run SOURCES accumulators_sum_test.cpp)

View File

@ -39,6 +39,7 @@ alias odr :
;
alias cxx14 :
[ run quick.cpp ]
[ run accumulators_count_test.cpp ]
[ run accumulators_fraction_test.cpp ]
[ run accumulators_mean_test.cpp ]

View File

@ -31,19 +31,19 @@ int main() {
BOOST_TEST_EQ(h.at(1), (fraction_t{1, 0}));
// cannot use std::vector<bool> because of vector specialization
std::vector<char> s = {true, false};
std::vector<char> s = {{true, false}};
std::vector<int> x = {0, 1};
h.fill(x, sample(s));
BOOST_TEST_EQ(h.at(0), (fraction_t{2, 1}));
BOOST_TEST_EQ(h.at(1), (fraction_t{1, 1}));
// any contiguous container of bool works which is not specialized
std::array<bool, 2> s2 = {false, true};
std::array<bool, 2> s2 = {{false, true}};
h.fill(x, sample(s2));
BOOST_TEST_EQ(h.at(0), (fraction_t{2, 2}));
BOOST_TEST_EQ(h.at(1), (fraction_t{2, 1}));
std::valarray<bool> s3 = {false, true};
std::valarray<bool> s3 = {{false, true}};
h.fill(x, sample(s3));
BOOST_TEST_EQ(h.at(0), (fraction_t{2, 3}));
BOOST_TEST_EQ(h.at(1), (fraction_t{3, 1}));

19
test/quick.cpp Normal file
View File

@ -0,0 +1,19 @@
// Copyright 2022 Hans Dembinski
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/histogram.hpp>
#include "throw_exception.hpp"
int main() {
using namespace boost::histogram;
auto h = make_histogram(axis::integer<>(0, 5));
h(0);
auto values = {1, 2};
h.fill(values);
}