Skip to content

Commit

Permalink
Make one-arg EventTime an event, not censored
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Oct 9, 2017
1 parent 796526b commit fc3bf4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/eventtimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
EventTime{T}
Immutable object containing the real-valued time to an event as well as an indicator of
whether the time corresponds to an observed event or right censoring.
whether the time corresponds to an observed event (`true`) or right censoring (`false`).
"""
struct EventTime{T<:Real}
time::T
status::Bool
end

EventTime(time::T) where {T<:Real} = EventTime{T}(time, false)
EventTime(time::T) where {T<:Real} = EventTime{T}(time, true)

## Overloaded Base functions

Expand Down
9 changes: 5 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ end
@testset "Event times" begin
@test isevent(EventTime{Int}(44, true))
@test !isevent(EventTime(3.2, false))
@test !isevent(EventTime(2.5f0))
@test isevent(EventTime(2.5f0))

@test iscensored(EventTime(3))
@test !iscensored(EventTime(2.1, true))
@test !iscensored(EventTime(3))
@test iscensored(EventTime(2.1, false))

@test eltype(EventTime(1)) == Int

@test sprint(show, EventTime(1)) == "1+"
@test sprint(show, EventTime(1, true)) == "1"
@test sprint(show, EventTime(1, false)) == "1+"

@test convert(Int, EventTime(1)) == 1
@test convert(EventTime, 1) == EventTime(1)
Expand Down

0 comments on commit fc3bf4a

Please sign in to comment.