diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index 9749f8403..b1d317a15 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -68,8 +68,9 @@ public interface IndexedHistogramGroup, V : Any> : Group.() -> Unit): IndexedHistogram override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { - require(left.histogramSpace == this) { "Can't operate on a histogram produced by external space" } - require(right.histogramSpace == this) { "Can't operate on a histogram produced by external space" } + require(left.histogramSpace == this && right.histogramSpace == this) { + "A histogram belonging to a different group cannot be operated." + } return IndexedHistogram(this, histogramValueAlgebra { left.values + right.values }) }