JuliaMath / JuliaMath/NaNMath.jl

Missing values support

Open
#30 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
57
Forks
30
PR merge metrics
No merged PRs in 30d

Description

I tested out this package on 0.7 with `missings` and got the following error:

I think this is because `Statistics` is not imported by `NaNMath`, so the function calls to `NaNMath.mean` can't fall base on `Statistics.mean`.

I think the solution here is to add `import Statistics` and add fall backs for operations of type `Any` so those are called when there are missing values. Does that seem feasible?

```
nm.mean([1.,2., missing])
> ERROR: WARNING: Base.mean is deprecated: it has been moved to the standard library package `Statistics`.
Add `using Statistics` to your imports.
in module Base
MethodError: no method matching mean(::Array{Union{Missing, Float64},1})
You may have intended to import Base.mean
Closest candidates are:
mean(::AbstractArray{T<:AbstractFloat,N} where N) where T<:AbstractFloat at /Users/peterdeffebach/.julia/packages/NaNMath/pEda/src/NaNMath.jl:167
Stacktrace:
[1] top-level scope at none:0
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in NaNMath.jl around the mean implementation at line 167 and review how Statistics.mean is imported and how calls on arrays containing missing are dispatched. Reproduce the reported nm.mean([1., 2., missing]) failure, then verify that the intended fallback behavior works for missing-valued inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.