-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust initialization in maximum and minimum (version 2) #28116
Conversation
maximum of OffsetArray example
Maybe add a test for #27992, too? |
I've just added that. |
test/reducedim.jl
Outdated
@test maximum(abs, Areduc, dims=region) ≈ safe_maxabs(Areduc, region) | ||
@test minimum(abs, Areduc, dims=region) ≈ safe_minabs(Areduc, region) | ||
@test @inferred sum(Areduc, dims=region) ≈ safe_sum(Areduc, region) | ||
@test @inferred prod(Areduc, dims=region) ≈ safe_prod(Areduc, region) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this @inferred
apply to the approx operator or the LHS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it applies to the isapprox
:
julia> f(x) = x < 0 ? '1' : 1
f (generic function with 1 method)
julia> using Test
julia> @inferred f(1)
ERROR: return type Int64 does not match inferred return type Union{Char, Int64}
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] top-level scope at none:0
julia> @inferred f(1) == 1
true
julia> @inferred(f(1)) == 1
ERROR: return type Int64 does not match inferred return type Union{Char, Int64}
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] top-level scope at none:0
base/abstractarray.jl
Outdated
# dimensions. When adding adding the dimensions, we have to respect the | ||
# index type of the input array (e.g. in the case of OffsetArrays) | ||
tmp = similar(Aslice, typeof(r1), reduced_indices(Aslice, 1:ndims(Aslice))) | ||
tmp[first(CartesianIndices(tmp))] = r1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstindex(tmp)
would work too, right?
Typo above: "adding adding".
76d4af0
to
38419ed
Compare
See #27845 and #28101 (comment)