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

minimum, maximum and extrema with specifing dims for an array that have all missing value dim doesn't work #35308

Closed
Paalon opened this issue Mar 30, 2020 · 4 comments · Fixed by #35323

Comments

@Paalon
Copy link
Contributor

Paalon commented Mar 30, 2020

minimum, maximum and extrema with specifing dims for an array that have all missing value dim doesn't work.

julia> minimum([1 missing; 2 missing], dims=1)
ERROR: TypeError: non-boolean (Missing) used in boolean context
Stacktrace:
 [1] reducedim_init(::Function, ::typeof(min), ::Array{Union{Missing, Int64},2}, ::Int64) at ./reducedim.jl:148
 [2] _mapreduce_dim(::Function, ::Function, ::NamedTuple{(),Tuple{}}, ::Array{Union{Missing, Int64},2}, ::Int64) at ./reducedim.jl:317
 [3] #mapreduce#580 at ./reducedim.jl:307 [inlined]
 [4] _minimum at ./reducedim.jl:679 [inlined]
 [5] _minimum at ./reducedim.jl:678 [inlined]
 [6] #minimum#589 at ./reducedim.jl:652 [inlined]
 [7] top-level scope at REPL[6]:1
@pdeffebach
Copy link
Contributor

Note that

julia> minimum([1, 2, missing])
missing

julia> min(1, missing)
missing

So this is just about the keyword argument for dims. This is not a case of adding missing propagation to a function that otherwise errors.

@nalimilan
Copy link
Member

Good catch. I have an inefficient fix at #35323. An efficient one would take much more work.

@stev47
Copy link
Contributor

stev47 commented Jan 5, 2021

seems to be fixed by 76952a8

@stev47 stev47 closed this as completed Jan 5, 2021
@nalimilan
Copy link
Member

As noted at #35323, this isn't completely fixed unfortunately. See the note there:

                # TODO: Some types, like BigInt, don't support typemin/typemax.
                # So a Matrix{Union{BigInt, Missing}} can still error here.

@nalimilan nalimilan reopened this Jan 5, 2021
nalimilan added a commit that referenced this issue Dec 10, 2023
`v0 != v0` returns `missing` for missing values. Use the
largest/smallest non-missing value to initialize the array. This is an
inefficient approach. Faster alternatives would be to avoid using an
initial value at all, and instead keep track of whether a value has been
set in a separate mask; or to use `typemax`/`typemin` for types that
support them.

Fixes #35308.
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 a pull request may close this issue.

4 participants