diff --git a/src/main/kotlin/org/jetbrains/bio/viktor/F64Array.kt b/src/main/kotlin/org/jetbrains/bio/viktor/F64Array.kt index 81aa408..7fe09a5 100644 --- a/src/main/kotlin/org/jetbrains/bio/viktor/F64Array.kt +++ b/src/main/kotlin/org/jetbrains/bio/viktor/F64Array.kt @@ -147,6 +147,19 @@ open class F64Array protected constructor( } } + @Suppress("nothing_to_inline") + private inline fun outOfBounds(indices: IntArray, shape: IntArray): Nothing { + val nDim = shape.size + val reason = when { + indices.size > nDim -> "too many indices" + indices.size < nDim -> "too few indices" + else -> "(${indices.joinToString(", ")}) out of bounds " + + "for shape ${shape.joinToString(", ")}" + } + + throw IndexOutOfBoundsException(reason) + } + /** * Returns a sequence of views along the specified [axis]. * diff --git a/src/main/kotlin/org/jetbrains/bio/viktor/Internals.kt b/src/main/kotlin/org/jetbrains/bio/viktor/Internals.kt index fd8c848..e671953 100644 --- a/src/main/kotlin/org/jetbrains/bio/viktor/Internals.kt +++ b/src/main/kotlin/org/jetbrains/bio/viktor/Internals.kt @@ -10,29 +10,16 @@ internal fun IntArray.remove(pos: Int) = when (pos) { } @Suppress("nothing_to_inline") -inline fun checkIndex(label: String, pos: Int, size: Int) { +internal inline fun checkIndex(label: String, pos: Int, size: Int) { if (pos < 0 || pos >= size) { throw IndexOutOfBoundsException("$label must be in [0, $size)") } } @Suppress("nothing_to_inline") -inline fun check1D(a: F64Array) { +internal inline fun check1D(a: F64Array) { check(a.nDim == 1) { "expected a 1-D array" } } @Suppress("nothing_to_inline") -inline fun unsupported(): Nothing = throw UnsupportedOperationException() - -@Suppress("nothing_to_inline") -internal inline fun outOfBounds(indices: IntArray, shape: IntArray): Nothing { - val nDim = shape.size - val reason = when { - indices.size > nDim -> "too many indices" - indices.size < nDim -> "too few indices" - else -> "(${indices.joinToString(", ")}) out of bounds " + - "for shape ${shape.joinToString(", ")}" - } - - throw IndexOutOfBoundsException(reason) -} \ No newline at end of file +internal inline fun unsupported(): Nothing = throw UnsupportedOperationException() \ No newline at end of file