Skip to content

Commit a78d54c

Browse files
authored
chore: update Boost.Histogram to 1.77+ (#594)
* chore: update boost-histogram
1 parent 17eb0f2 commit a78d54c

File tree

10 files changed

+20
-16
lines changed

10 files changed

+20
-16
lines changed

extern/config

Submodule config updated 256 files

extern/histogram

Submodule histogram updated 60 files

include/bh_python/accumulators/ostream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
7979
template <class CharT, class Traits, class T>
8080
std::basic_ostream<CharT, Traits>&
8181
operator<<(std::basic_ostream<CharT, Traits>& os,
82-
const ::boost::histogram::accumulators::thread_safe<T>& x) {
82+
const ::boost::histogram::accumulators::count<T, true>& x) {
8383
os << x.load();
8484
return os;
8585
}

include/bh_python/histogram.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace pybind11 {
2020
/// The descriptor for atomic_* is the same as the descriptor for *, as long this uses
2121
/// standard layout
2222
template <class T>
23-
struct format_descriptor<bh::accumulators::thread_safe<T>> : format_descriptor<T> {
24-
static_assert(std::is_standard_layout<bh::accumulators::thread_safe<T>>::value, "");
23+
struct format_descriptor<bh::accumulators::count<T, true>> : format_descriptor<T> {
24+
static_assert(std::is_standard_layout<bh::accumulators::count<T, true>>::value, "");
2525
};
2626

2727
} // namespace pybind11

include/bh_python/storage.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <bh_python/accumulators/weighted_mean.hpp>
1212
#include <bh_python/accumulators/weighted_sum.hpp>
1313

14-
#include <boost/histogram/accumulators/thread_safe.hpp>
14+
#include <boost/histogram/accumulators/count.hpp>
1515
#include <boost/histogram/storage_adaptor.hpp>
1616
#include <boost/histogram/unlimited_storage.hpp>
1717

@@ -23,7 +23,7 @@ namespace storage {
2323

2424
// Names match Python names
2525
using int64 = bh::dense_storage<uint64_t>;
26-
using atomic_int64 = bh::dense_storage<bh::accumulators::thread_safe<uint64_t>>;
26+
using atomic_int64 = bh::dense_storage<bh::accumulators::count<uint64_t, true>>;
2727
using double_ = bh::dense_storage<double>;
2828
using unlimited = bh::unlimited_storage<>;
2929
using weight = bh::dense_storage<accumulators::weighted_sum<double>>;
@@ -80,8 +80,12 @@ template <class Archive>
8080
void save(Archive& ar, const storage::atomic_int64& s, unsigned /* version */) {
8181
// We cannot view the memory as a numpy array, because the internal layout of
8282
// std::atomic is undefined. So no reinterpret_casts are allowed.
83-
py::array_t<std::int64_t> a(static_cast<py::ssize_t>(s.size()));
84-
std::copy(s.begin(), s.end(), a.mutable_data());
83+
py::array_t<std::uint64_t> a(static_cast<py::ssize_t>(s.size()));
84+
85+
auto in_ptr = s.begin();
86+
auto out_ptr = a.mutable_data();
87+
for(; in_ptr != s.end(); ++in_ptr, ++out_ptr)
88+
*out_ptr = in_ptr->value();
8589
ar << a;
8690
}
8791

@@ -187,15 +191,15 @@ struct type_caster<storage::atomic_int64::value_type> {
187191
auto ptr = PyNumber_Long(src.ptr());
188192
if(!ptr)
189193
return false;
190-
value.store(PyLong_AsUnsignedLongLong(ptr));
194+
value = PyLong_AsUnsignedLongLong(ptr);
191195
Py_DECREF(ptr);
192196
return !PyErr_Occurred();
193197
}
194198

195199
static handle cast(storage::atomic_int64::value_type src,
196200
return_value_policy /* policy */,
197201
handle /* parent */) {
198-
return PyLong_FromUnsignedLongLong(src.load());
202+
return PyLong_FromUnsignedLongLong(src.value());
199203
}
200204
};
201205
} // namespace detail

0 commit comments

Comments
 (0)