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

nanpctile() gives an error: UndefVarError: T not defined for multidimension array #15

Closed
Rapsodia86 opened this issue Mar 30, 2022 · 10 comments · Fixed by #18
Closed

nanpctile() gives an error: UndefVarError: T not defined for multidimension array #15

Rapsodia86 opened this issue Mar 30, 2022 · 10 comments · Fixed by #18

Comments

@Rapsodia86
Copy link

Hello!
I wanted to apply some statistic functions over a big array: 1675×1265×20 Array{Float32, 3} that has NaNs.
While it works well to get e.g. median across third dimension and reduce to matrix:
median_ar = nanmedian(rast_fin, dim=3)
it gives: 1675×1265 Matrix{Float32}

however, when try:
iqr_25_ar =nanpctile(rast_fin, 25, dim=3)
it gives error: UndefVarError: T not defined

What am I missing?
Thanks!

Stacktrace:
[1] _nanquantile!(A::SubArray{Float32, 1, Array{Float32, 3}, Tuple{Int64, Int64, Base.Slice{Base.OneTo{Int64}}}, true}, q::Float64, #unused#::Colon)
@ NaNStatistics C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:152
[2] macro expansion
@ C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:212 [inlined]
[3] _nanquantile!(B::Array{Float32, 3}, A::Array{Float32, 3}, q::Float64, dims::Tuple{Static.StaticInt{3}})
@ NaNStatistics C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:268
[4] macro expansion
@ C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:268 [inlined]
[5] _nanquantile!(B::Array{Float32, 3}, A::Array{Float32, 3}, q::Float64, dims::Tuple{Int64})
@ NaNStatistics C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:268
[6] _nanquantile!
@ C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:141 [inlined]
[7] _nanquantile!
@ C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:131 [inlined]
[8] __nanpctile!(A::Array{Float32, 3}, p::Int64, #unused#::Colon, region::Int64)
@ NaNStatistics C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:74
[9] __nanpctile(A::Array{Float32, 3}, p::Int64, dims::Function, dim::Int64)
@ NaNStatistics C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:17
[10] #nanpctile#49
@ C:\Users\monikat.julia\packages\NaNStatistics\ryatP\src\Sorting\nanpctile.jl:14 [inlined]

@Rapsodia86 Rapsodia86 changed the title nanpctile() frows error: UndefVarError: T not defined for multidimension array nanpctile() gives an error: UndefVarError: T not defined for multidimension array Mar 30, 2022
@brenhinkeller
Copy link
Owner

Hmm, good question. Which versions of Julia and NaNStatistics are you on? I can't seem to reproduce locally:

julia> a = rand(Float32, 1675, 1265, 20);

julia> using NaNStatistics

julia> nanpctile(a, 25, dim=3)
1675×1265 Matrix{Float32}:
 0.201905   0.213346  0.135244  0.312824   0.41867   …  0.0960994  0.154106   0.203496
 0.278074   0.236499  0.393272  0.21953    0.26126      0.174516   0.304279   0.307603
 0.239232   0.214348  0.262016  0.231451   0.276992     0.314799   0.370971   0.391675
 0.231702   0.49299   0.22068   0.20867    0.258393     0.199616   0.242694   0.131189
 0.0668727  0.336019  0.162326  0.218961   0.291756     0.249817   0.320886   0.234961
 0.158791   0.461463  0.284553  0.335379   0.287451  …  0.492462   0.317864   0.214808
 0.317202   0.251075  0.444729  0.355543   0.358705     0.195932   0.209493   0.306191
 0.381318   0.178761  0.212641  0.427774   0.141498     0.41383    0.139773   0.240451
 0.315014   0.173859  0.302293  0.23046    0.359963     0.359434   0.251495   0.229947
 0.216419   0.356514  0.440597  0.282261   0.172553     0.200759   0.179912   0.221218
 0.138713   0.388478  0.186638  0.233991   0.142028  …  0.433376   0.290844   0.216663
 0.158581   0.306969  0.276007  0.207912   0.314541     0.240828   0.278426   0.190032
 0.459776   0.188694  0.440165  0.181132   0.287091     0.168395   0.269304   0.375729
 0.310182   0.438171  0.391576  0.247264   0.271928     0.452179   0.161462   0.200436
 0.43586    0.154172  0.228099  0.201191   0.438236     0.286919   0.0969754  0.250468
 0.263719   0.26898   0.336066  0.326184   0.17316   …  0.363671   0.125518   0.323522
 0.33322    0.16957   0.107144  0.20838    0.285        0.286996   0.164111   0.284478
 0.257866   0.522421  0.306314  0.318473   0.284455     0.235368   0.248147   0.282748
 0.298578   0.32154   0.365487  0.189053   0.159999     0.265808   0.332364   0.365041
 0.271009   0.306294  0.171621  0.185273   0.377907     0.285846   0.0691201  0.292488
 0.277543   0.311748  0.191368  0.0777754  0.154933  …  0.193494   0.324027   0.271002
 0.229155   0.30209   0.184567  0.2792     0.301323     0.193195   0.256912   0.39149
 0.333308   0.24761   0.217494  0.406887   0.280803     0.183032   0.358676   0.207282
 0.357351   0.309931  0.191074  0.266505   0.199703     0.215182   0.345186   0.234963
 0.391713   0.283921  0.188846  0.344098   0.241541     0.268291   0.266011   0.197915
 0.314499   0.2841    0.30525   0.401528   0.152633  …  0.167575   0.377583   0.236827
 0.0793513  0.219738  0.139858  0.210716   0.14795      0.349948   0.312297   0.267818
 0.151663   0.155163  0.215905  0.190777   0.146133     0.286513   0.287612   0.250017
 0.176962   0.24979   0.359025  0.225649   0.318893     0.336431   0.339919   0.361817
 0.265544   0.318422  0.201094  0.228046   0.227932     0.28833    0.434047   0.319823
 0.283635   0.226708  0.219345  0.165486   0.274064  …  0.352266   0.19097    0.234822
 ⋮                                                   ⋱
 0.311681   0.323112  0.368197  0.267128   0.383434  …  0.143218   0.272182   0.186523
 0.251469   0.446104  0.151469  0.224057   0.436067     0.238204   0.266451   0.429897
 0.308806   0.301209  0.414878  0.337857   0.491233     0.231168   0.181843   0.356309
 0.237886   0.275072  0.261577  0.362267   0.303012     0.103261   0.311101   0.31108
 0.418175   0.383054  0.135382  0.30774    0.319802     0.211916   0.153432   0.315661
 0.394925   0.145993  0.240632  0.370278   0.372589  …  0.195052   0.404884   0.232299
 0.271849   0.281936  0.249793  0.299438   0.212459     0.124529   0.385071   0.297644
 0.154386   0.163948  0.279069  0.309223   0.346081     0.231901   0.395833   0.268941
 0.268111   0.497233  0.182525  0.335265   0.201526     0.233485   0.217399   0.389154
 0.373573   0.214063  0.277369  0.211133   0.515728     0.275293   0.335343   0.385843
 0.233291   0.30642   0.28293   0.177617   0.489046  …  0.224444   0.434184   0.275463
 0.173864   0.218865  0.109955  0.242567   0.152826     0.35337    0.217209   0.29524
 0.194855   0.493664  0.210693  0.155549   0.245459     0.219501   0.155598   0.178034
 0.133659   0.245331  0.323084  0.195487   0.333885     0.167532   0.208822   0.303439
 0.254429   0.202363  0.123782  0.371056   0.448275     0.316468   0.252061   0.372761
 0.343538   0.327914  0.288322  0.274093   0.298337  …  0.299169   0.080843   0.293657
 0.183983   0.452706  0.299203  0.376133   0.163436     0.124624   0.288508   0.412623
 0.191729   0.431828  0.310435  0.388841   0.276166     0.396557   0.361394   0.248067
 0.354493   0.168587  0.191503  0.276639   0.248208     0.119547   0.118179   0.222302
 0.390037   0.280628  0.388301  0.277035   0.297027     0.13783    0.177205   0.303176
 0.247677   0.147748  0.162335  0.280476   0.296622  …  0.36042    0.147374   0.416966
 0.220133   0.229865  0.270091  0.162126   0.316335     0.265098   0.464074   0.262431
 0.329481   0.342525  0.283391  0.28715    0.169664     0.374533   0.2507     0.283014
 0.476446   0.198537  0.255019  0.185916   0.198302     0.350275   0.149193   0.0631866
 0.195514   0.312179  0.316391  0.1724     0.37374      0.172825   0.205591   0.260561
 0.217447   0.260249  0.176607  0.101252   0.381988  …  0.289043   0.418625   0.281236
 0.113865   0.427509  0.197099  0.31183    0.297451     0.174565   0.359918   0.415651
 0.44377    0.204027  0.387042  0.282492   0.220362     0.300617   0.0903022  0.185137
 0.19224    0.415326  0.107594  0.41815    0.246445     0.415882   0.282922   0.285532
 0.211436   0.279145  0.263116  0.155819   0.265713     0.234683   0.169139   0.338886

@Rapsodia86
Copy link
Author

Here is the info:
julia> VERSION
v"1.7.2"
julia> Pkg.status("NaNStatistics")
Status C:\Users\monikat\.julia\environments\v1.7\Project.toml
[b946abbf] NaNStatistics v0.6.7

Hm.. yeah, I see it works for you. I am using VSC julia extension.

@brenhinkeller
Copy link
Owner

Huh, odd. I don't have easy access to a Windows machine but I can try enabling CI on Windows and seeing if that catches anything.

@Rapsodia86
Copy link
Author

One more, there are some cells that NaNs go across all arrays (20x NaN). But I would expect to get NaN for those cells as I get for median calculation right?

Huh, odd. I don't have easy access to a Windows machine but I can try enabling CI on Windows and seeing if that catches anything.

That would be great! Thank you for looking into it!

@brenhinkeller
Copy link
Owner

Ah, I think I found the problem

@brenhinkeller
Copy link
Owner

Ok, that should do it. Try updating to v0.6.9 once that gets registered and see if that works on your end!

@Rapsodia86
Copy link
Author

Thank you! Will surely inform you if that works:)

brenhinkeller referenced this issue Apr 1, 2022
Fix bug in handling of percentiles of all-NaN collections
@brenhinkeller
Copy link
Owner

@Rapsodia86
Copy link
Author

Works! Perfect! Thank you very much!

@brenhinkeller
Copy link
Owner

Any time!

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.

2 participants