Skip to content

Commit

Permalink
Do not throw on merging non-initialized flat histors
Browse files Browse the repository at this point in the history
  • Loading branch information
shahor02 committed Jun 3, 2024
1 parent 53c5a42 commit 03683e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions DataFormats/common/src/FlatHisto1D.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ FlatHisto1D<T>& FlatHisto1D<T>::operator=(const FlatHisto1D<T>& rhs)
if (this == &rhs) {
return *this;
}
if (!rhs.canFill()) {
if (!rhs.canFill() && rhs.getNBins()) { // was initialized
throw std::runtime_error("trying to copy read-only histogram");
} else {
}
if (rhs.getNBins()) {
mContainer = rhs.mContainer;
init(gsl::span<const T>(mContainer.data(), mContainer.size()));
}
Expand Down
5 changes: 3 additions & 2 deletions DataFormats/common/src/FlatHisto2D.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ FlatHisto2D<T>& FlatHisto2D<T>::operator=(const FlatHisto2D<T>& rhs)
if (this == &rhs) {
return *this;
}
if (!rhs.canFill()) {
if (!rhs.canFill() && rhs.getNBins()) { // was initialized
throw std::runtime_error("trying to copy read-only histogram");
} else {
}
if (rhs.getNBins()) {
mContainer = rhs.mContainer;
init(gsl::span<const T>(mContainer.data(), mContainer.size()));
}
Expand Down

0 comments on commit 03683e1

Please sign in to comment.