You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First- I don't think we need this for onsets and annotations, xref #75, #72). But I think it is useful to have, at least for folks doing the encoding (which are EDF.jl's users but not EDF.jl itself). However, it should be:
function_nearest_representable_edf_time_value(x, rm::RoundingMode=RoundNearest)
returnround(x, rm; digits=(8- (ndigits(floor(Int, x)) +signbit(x) +!isinteger(x))))
end
where I've added an optional rounding mode. The difference here is !isinteger - we lose a digit when we have to write the decimal.
Running
using Printf
functionedf_roundtrip(x::Real)
result =missingifisinteger(x)
str =string(trunc(Int, x))
iflength(str) <=8
result = str
endelse
fpart, ipart =modf(x)
ipart_str =string('-'^signbit(x), Int(abs(ipart))) # handles `-0.0` case
fpart_str =@sprintf"%.7f"abs(fpart)
fpart_str = fpart_str[3:end] # remove leading `0.`iflength(ipart_str) <7
result = ipart_str *'.'* fpart_str[1:(7-length(ipart_str))]
elseiflength(ipart_str) <=8
result = ipart_str
endendif!ismissing(result)
returnparse(Float64, result)
enderror("failed to fit header field into EDF's 8 ASCII character limit. Got: $x")
returnnothingendedf_roundtrip_error(x) =abs(x -edf_roundtrip(x))
function_nearest_representable_edf_time_value(x, rm::RoundingMode=RoundNearest)
returnround(x, rm; digits=(8- (ndigits(floor(Int, x)) +signbit(x) +!isinteger(x))))
end
f = x ->edf_roundtrip_error(_nearest_representable_edf_time_value(x))
lines(xs, f.(xs))
which modifies the _edf_repr code for use here, I get
whereas if I remove the ! to match the current code, I get
The text was updated successfully, but these errors were encountered:
EDF.jl/src/types.jl
Lines 117 to 121 in 2eef49f
First- I don't think we need this for onsets and annotations, xref #75, #72). But I think it is useful to have, at least for folks doing the encoding (which are EDF.jl's users but not EDF.jl itself). However, it should be:
where I've added an optional rounding mode. The difference here is
!isinteger
- we lose a digit when we have to write the decimal.Running
which modifies the
_edf_repr
code for use here, I getwhereas if I remove the
!
to match the current code, I getThe text was updated successfully, but these errors were encountered: