Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
add isstrictlyconvex
Browse files Browse the repository at this point in the history
  • Loading branch information
Evizero committed Aug 21, 2016
1 parent 9131c9f commit ae22d4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/LearnBase.jl
Expand Up @@ -79,18 +79,24 @@ function isminimizable end
function isdifferentiable end
function istwicedifferentiable end
function isconvex end
function isstrictlyconvex end
function isstronglyconvex end
function isnemitski end
function isunivfishercons end
function isfishercons end
function islipschitzcont end
function islocallylipschitzcont end
function islipschitzcont_deriv end
function islipschitzcont_deriv end # maybe overkill
function isclipable end
function ismarginbased end
function isclasscalibrated end
function isdistancebased end

# fallback to supersets
isstrictlyconvex(any) = isstronglyconvex(any)
isconvex(any) = isstrictlyconvex(any)
islocallylipschitzcont(any) = islipschitzcont(any)

"""
Anything that takes an input and performs some kind
of function to produce an output. For example a linear
Expand Down Expand Up @@ -250,6 +256,7 @@ export
isdifferentiable,
istwicedifferentiable,
isconvex,
isstrictlyconvex,
isstronglyconvex,
isnemitski,
isunivfishercons,
Expand Down
13 changes: 12 additions & 1 deletion test/runtests.jl
Expand Up @@ -46,6 +46,7 @@ using Base.Test
@test typeof(isdifferentiable) <: Function
@test typeof(istwicedifferentiable) <: Function
@test typeof(isconvex) <: Function
@test typeof(isstrictlyconvex) <: Function
@test typeof(isstronglyconvex) <: Function
@test typeof(isnemitski) <: Function
@test typeof(isunivfishercons) <: Function
Expand All @@ -70,6 +71,16 @@ using StatsBase
@test StatsBase.fit! == LearnBase.fit!
@test StatsBase.nobs == LearnBase.nobs

# Test superset fallbacks
immutable MyStronglyConvexType end
LearnBase.isstronglyconvex(::MyStronglyConvexType) = true
LearnBase.islipschitzcont(::MyStronglyConvexType) = true
@test isstronglyconvex(MyStronglyConvexType())
@test isstrictlyconvex(MyStronglyConvexType())
@test isconvex(MyStronglyConvexType())
@test islipschitzcont(MyStronglyConvexType())
@test islocallylipschitzcont(MyStronglyConvexType())

# IntervalSet
let s = IntervalSet(-1,1)
@test typeof(s) == IntervalSet{Int}
Expand Down Expand Up @@ -100,7 +111,7 @@ let s = IntervalSet(-1,1.0)
@test 1 in s
# @show s LearnBase.randtype(s)
end

# DiscreteSet
let s = DiscreteSet([-1,1])
@test typeof(s) == DiscreteSet{Vector{Int}}
Expand Down

0 comments on commit ae22d4c

Please sign in to comment.