Skip to content

Commit a6b5e81

Browse files
pre-commit-ci[bot]henryiii
authored andcommitted
style: pre-commit fixes
1 parent 1d1771d commit a6b5e81

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

include/bh_python/fill.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
#include <bh_python/overload.hpp>
1313
#include <bh_python/vector_string_caster.hpp>
1414

15+
#include <boost/core/ignore_unused.hpp>
1516
#include <boost/histogram/detail/accumulator_traits.hpp>
1617
#include <boost/histogram/detail/axes.hpp>
1718
#include <boost/histogram/sample.hpp>
1819
#include <boost/histogram/unsafe_access.hpp>
1920
#include <boost/histogram/weight.hpp>
2021
#include <boost/mp11.hpp>
2122
#include <boost/variant2/variant.hpp>
22-
#include <boost/core/ignore_unused.hpp>
2323

2424
#include <stdexcept>
2525
#include <type_traits>
@@ -228,7 +228,7 @@ void fill_impl(bh::detail::accumulator_traits_holder<false, boost::span<double>>
228228
if(sarray.ndim() != 2)
229229
throw std::invalid_argument("Sample array for MultiWeight must be 2D");
230230

231-
auto buf = sarray.request();
231+
auto buf = sarray.request();
232232
// releasing gil here is safe, we don't manipulate refcounts
233233
py::gil_scoped_release lock;
234234
std::size_t buf_shape0 = static_cast<std::size_t>(buf.shape[0]);

include/bh_python/multi_weight.hpp

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ template <class T>
1616
struct multi_weight_value : public boost::span<T> {
1717
using boost::span<T>::span;
1818

19-
void operator()(const boost::span<T> values) {
20-
operator+=(values);
21-
}
19+
void operator()(const boost::span<T> values) { operator+=(values); }
2220

2321
template <class S>
2422
bool operator==(const S values) const {
@@ -29,18 +27,20 @@ struct multi_weight_value : public boost::span<T> {
2927
}
3028

3129
template <class S>
32-
bool operator!=(const S values) const { return !operator==(values); }
33-
34-
//template <class S>
35-
//void operator+=(const S values) {
36-
//void operator+=(const std::vector<T> values) {
37-
// if(values.size() != this->size())
38-
// throw std::runtime_error("size does not match");
39-
// auto it = this->begin();
40-
// for(const T& x : values)
41-
// *it++ += x;
42-
//}
43-
//void operator+=(const boost::span<T> values) {
30+
bool operator!=(const S values) const {
31+
return !operator==(values);
32+
}
33+
34+
// template <class S>
35+
// void operator+=(const S values) {
36+
// void operator+=(const std::vector<T> values) {
37+
// if(values.size() != this->size())
38+
// throw std::runtime_error("size does not match");
39+
// auto it = this->begin();
40+
// for(const T& x : values)
41+
// *it++ += x;
42+
// }
43+
// void operator+=(const boost::span<T> values) {
4444
template <class S>
4545
void operator+=(const S values) {
4646
if(values.size() != this->size())
@@ -85,7 +85,10 @@ class multi_weight {
8585
: base_type{idx}
8686
, par_{par} {}
8787

88-
decltype(auto) operator*() const { return Reference{par_->buffer_.get() + this->base() * par_->nelem_, par_->nelem_}; }
88+
decltype(auto) operator*() const {
89+
return Reference{par_->buffer_.get() + this->base() * par_->nelem_,
90+
par_->nelem_};
91+
}
8992

9093
MWPtr par_ = nullptr;
9194
};
@@ -99,9 +102,7 @@ class multi_weight {
99102
multi_weight(const std::size_t k = 0)
100103
: nelem_{k} {}
101104

102-
multi_weight(const multi_weight& other) {
103-
*this = other;
104-
}
105+
multi_weight(const multi_weight& other) { *this = other; }
105106

106107
multi_weight& operator=(const multi_weight& other) {
107108
nelem_ = other.nelem_;
@@ -114,7 +115,7 @@ class multi_weight {
114115
std::size_t size() const { return size_; }
115116

116117
void reset(std::size_t n) {
117-
size_ = n;
118+
size_ = n;
118119
buffer_.reset(new element_type[size_ * nelem_]);
119120
default_fill();
120121
}
@@ -135,8 +136,12 @@ class multi_weight {
135136
const_iterator begin() const { return {this, 0}; }
136137
const_iterator end() const { return {this, size_}; }
137138

138-
reference operator[](std::size_t i) { return reference{buffer_.get() + i * nelem_, nelem_}; }
139-
const_reference operator[](std::size_t i) const { return const_reference{buffer_.get() + i * nelem_, nelem_}; }
139+
reference operator[](std::size_t i) {
140+
return reference{buffer_.get() + i * nelem_, nelem_};
141+
}
142+
const_reference operator[](std::size_t i) const {
143+
return const_reference{buffer_.get() + i * nelem_, nelem_};
144+
}
140145

141146
template <class T>
142147
bool operator==(const multi_weight<T>& other) const {
@@ -177,8 +182,8 @@ class multi_weight {
177182
}
178183

179184
public:
180-
std::size_t size_ = 0; // Number of bins
181-
std::size_t nelem_ = 0; // Number of weights per bin
185+
std::size_t size_ = 0; // Number of bins
186+
std::size_t nelem_ = 0; // Number of weights per bin
182187
std::unique_ptr<element_type[]> buffer_;
183188
};
184189

0 commit comments

Comments
 (0)