You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionreinterpret(::typeof(reshape), ::Type{T}, a::A) where {T,S,A<:AbstractArray{S}}
100
101
functionthrowintmult(S::Type, T::Type)
101
102
@noinline
102
-
throw(ArgumentError("`reinterpret(reshape, T, a)` requires that one of `sizeof(T)` (got $(sizeof(T))) and `sizeof(eltype(a))` (got $(sizeof(S))) be an integer multiple of the other"))
103
+
throw(ArgumentError(LazyString("`reinterpret(reshape, T, a)` requires that one of `sizeof(T)` (got ",
104
+
sizeof(T), ") and `sizeof(eltype(a))` (got ", sizeof(S), ") be an integer multiple of the other")))
103
105
end
104
106
functionthrowsize1(a::AbstractArray, T::Type)
105
107
@noinline
106
-
throw(ArgumentError("`reinterpret(reshape, $T, a)` where `eltype(a)` is $(eltype(a)) requires that `axes(a, 1)` (got $(axes(a, 1))) be equal to 1:$(sizeof(T) ÷sizeof(eltype(a))) (from the ratio of element sizes)"))
108
+
throw(ArgumentError(LazyString("`reinterpret(reshape, ", T, ", a)` where `eltype(a)` is ", eltype(a),
109
+
" requires that `axes(a, 1)` (got ", axes(a, 1), ") be equal to 1:",
110
+
sizeof(T) ÷sizeof(eltype(a)), " (from the ratio of element sizes)")))
107
111
end
108
112
functionthrowfromsingleton(S, T)
109
113
@noinline
110
-
throw(ArgumentError("`reinterpret(reshape, $T, a)` where `eltype(a)` is $S requires that $T be a singleton type, since $S is one"))
114
+
throw(ArgumentError(LazyString("`reinterpret(reshape, ", T, ", a)` where `eltype(a)` is ", S,
115
+
" requires that ", T, " be a singleton type, since ", S, " is one")))
111
116
end
112
117
isbitstype(T) ||throwbits(S, T, T)
113
118
isbitstype(S) ||throwbits(S, T, S)
@@ -851,8 +856,8 @@ end
851
856
inpackedsize =packedsize(In)
852
857
outpackedsize =packedsize(Out)
853
858
inpackedsize == outpackedsize ||
854
-
throw(ArgumentError("Packed sizes of types $Outand $In do not match; got $outpackedsize \
855
-
and $inpackedsize, respectively."))
859
+
throw(ArgumentError(LazyString("Packed sizes of types ", Out, "and ", In,
860
+
" do not match; got ", outpackedsize, "and ", inpackedsize, ", respectively.")))
Copy file name to clipboardExpand all lines: test/reinterpretarray.jl
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -40,9 +40,8 @@ end
40
40
@test_throwsArgumentError("cannot reinterpret `Vector{Int32}` as `Int32`, type `Vector{Int32}` is not a bits type") reinterpret(Int32, Av)
41
41
@test_throwsArgumentError("cannot reinterpret a zero-dimensional `Int64` array to `Int32` which is of a different size") reinterpret(Int32, reshape([Int64(0)]))
42
42
@test_throwsArgumentError("cannot reinterpret a zero-dimensional `Int32` array to `Int64` which is of a different size") reinterpret(Int64, reshape([Int32(0)]))
43
-
@test_throwsArgumentError("""cannot reinterpret an `$Int` array to `Tuple{$Int, $Int}` whose first dimension has size `5`.
44
-
The resulting array would have non-integral first dimension.
45
-
""") reinterpret(Tuple{Int,Int}, [1,2,3,4,5])
43
+
@test_throwsArgumentError("cannot reinterpret an `$Int` array to `Tuple{$Int, $Int}` whose first dimension has size `5`."*
44
+
" The resulting array would have a non-integral first dimension.") reinterpret(Tuple{Int,Int}, [1,2,3,4,5])
46
45
47
46
@test_throwsArgumentError("`reinterpret(reshape, Complex{Int64}, a)` where `eltype(a)` is Int64 requires that `axes(a, 1)` (got Base.OneTo(4)) be equal to 1:2 (from the ratio of element sizes)") reinterpret(reshape, Complex{Int64}, A)
48
47
@test_throwsArgumentError("`reinterpret(reshape, T, a)` requires that one of `sizeof(T)` (got 24) and `sizeof(eltype(a))` (got 16) be an integer multiple of the other") reinterpret(reshape, NTuple{3, Int64}, B)
0 commit comments