From f70f3fb06e2b9bc4d6d9cab8242da7c6ec947440 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 9 Aug 2024 22:56:34 -0400 Subject: [PATCH 1/2] tighten signature of repeat --- base/abstractarraymath.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 0f028a0f66729..874a2215892bb 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -432,7 +432,7 @@ julia> repeat([1, 2, 3], 2, 3) 3 3 3 ``` """ -function repeat(A::AbstractArray, counts...) +function repeat(A::AbstractArray, counts::Integer...) return repeat(A, outer=counts) end From 5a3f95607d1ed9a6acda565e367128fc404bdb16 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:45:40 -0500 Subject: [PATCH 2/2] replace signature change with ArgumentError --- base/abstractarraymath.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 874a2215892bb..54b6d75cee2dc 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -432,7 +432,7 @@ julia> repeat([1, 2, 3], 2, 3) 3 3 3 ``` """ -function repeat(A::AbstractArray, counts::Integer...) +function repeat(A::AbstractArray, counts...) return repeat(A, outer=counts) end @@ -518,6 +518,9 @@ function check(arr, inner, outer) # TODO: Currently one based indexing is demanded for inner !== nothing, # but not for outer !== nothing. Decide for something consistent. Base.require_one_based_indexing(arr) + if !all(n -> n isa Integer, inner) + throw(ArgumentError("repeat requires integer counts, got inner = $inner")) + end if any(<(0), inner) throw(ArgumentError("no inner repetition count may be negative; got $inner")) end @@ -526,6 +529,9 @@ function check(arr, inner, outer) end end if outer !== nothing + if !all(n -> n isa Integer, outer) + throw(ArgumentError("repeat requires integer counts, got outer = $outer")) + end if any(<(0), outer) throw(ArgumentError("no outer repetition count may be negative; got $outer")) end