Skip to content
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

Merged
merged 7 commits into from
Jul 16, 2018

Conversation

andreasnoack
Copy link
Member

@giordano
Copy link
Contributor

Maybe add a test for #27992, too?

@andreasnoack
Copy link
Member Author

Maybe add a test for #27992, too?

I've just added that.

@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)
Copy link
Member

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?

Copy link
Contributor

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

# 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
Copy link
Member

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".

@andreasnoack andreasnoack merged commit 5b4d203 into master Jul 16, 2018
@andreasnoack andreasnoack deleted the anj/reducediminit branch July 16, 2018 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants