Skip to content

Commit

Permalink
v0.5.2-p1
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jun 3, 2022
1 parent 8469f0d commit cd1a9fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,34 @@ function indsdict!(d::Dict{T}, cdata::Tuple) where T
d
end

"""
Sort `a` by values of `vec`.
"""
function sortbyvec!(a, vec)
sort!(a, by = x -> findfirst(y -> x == y, vec))
end

"""
Find all non-unique values.
"""
nonunique(v) = [k for (k, v) in StatsBase.countmap(v) if v > 1]


################################################################################
################################################################################

"""
Return `true` if value NaN or Missing.
"""
isnanormissing(x::Number) = isnan(x)
isnanormissing(x::AbstractFloat) = isnan(x)
isnanormissing(x::Missing) = true

"""
Return `true` if value > 0, other cases - `false` (Missing, Nothing, NaN)
"""
ispositive(::Missing) = false
ispositive(::Nothing) = false
ispositive(x::AbstractFloat) = isnan(x) ? false : x > zero(x)
ispositive(x) = x > zero(x)

Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ using Test, Tables, TypedTables, CSV
keys(itr2)
@test length(itr2) == 2

@test MetidaBase.nonunique([1,2,3,3,4,5,6,6]) == [6,3]

@test MetidaBase.sortbyvec!([1,2,3,4,5,6,7,8], [2,5,3,1,8,4,6,7]) == [2,5,3,1,8,4,6,7]

#Ststutils
MetidaBase.sdfromcv(0.4) 0.38525317015992666
MetidaBase.varfromcv(0.4) 0.1484200051182734
Expand Down

2 comments on commit cd1a9fb

@PharmCat
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/61689

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" cd1a9fb83008b7a52bc311ee3a331e5381e8b3de
git push origin v0.5.2

Please sign in to comment.