From 2eef49f6c22cea61a85d2aa934255ddc1a8ec8a0 Mon Sep 17 00:00:00 2001 From: Dave Kleinschmidt Date: Tue, 17 Oct 2023 15:46:46 -0400 Subject: [PATCH] add autoformatting (#73) * autoformatting * maybe if we push one change the action will fail?? * println debugging * Update .github/workflows/Format.yml Co-authored-by: Phillip Alday * Update .github/workflows/Format.yml Co-authored-by: Phillip Alday * Update .github/workflows/Format.yml Co-authored-by: Phillip Alday * Update .github/workflows/Format.yml Co-authored-by: Phillip Alday * fix * insert malformed change * Revert "insert malformed change" This reverts commit 4f397e5e6094e2e79036547029624c707978f3e4. * format everything --------- Co-authored-by: Phillip Alday --- .github/workflows/Format.yml | 42 +++++++ .gitignore | 1 + docs/make.jl | 4 +- format/Manifest.toml | 221 +++++++++++++++++++++++++++++++++++ format/Project.toml | 2 + format/run.jl | 14 +++ src/read.jl | 15 ++- src/types.jl | 5 +- src/write.jl | 18 ++- test/runtests.jl | 45 ++++--- 10 files changed, 335 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/Format.yml create mode 100644 format/Manifest.toml create mode 100644 format/Project.toml create mode 100644 format/run.jl diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml new file mode 100644 index 0000000..1e72b6f --- /dev/null +++ b/.github/workflows/Format.yml @@ -0,0 +1,42 @@ +name: Format Check +on: + # because we rely on ReviewDog to trigger failure, there's no reason to run on anything + pull_request: + paths: + - "**/*.jl" + - ".github/workflows/FormatCheck.yml" +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +jobs: + format-check: + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1.9" + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v3 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/cache@v1 + with: + cache-name: "${{ github.workflow }}-${{ github.job }}-${{ matrix.pkg.name }}-${{ matrix.version }}-${{ matrix.os }}-${{ matrix.arch }}" + cache-compiled: true + - name: Instantiate `format` environment and format + run: | + julia --project=format -e 'using Pkg; Pkg.instantiate()' + julia --project=format 'format/run.jl' + - uses: reviewdog/action-suggester@v1 + with: + tool_name: JuliaFormatter + fail_on_error: true diff --git a/.gitignore b/.gitignore index b6d4700..cf7a0f8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.DS_Store Manifest.toml docs/build/ +!format/Manifest.toml \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index c9b3a0c..bbdf787 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,9 +1,9 @@ using Documenter using EDF -makedocs(modules=[EDF], +makedocs(; modules=[EDF], sitename="EDF.jl", authors="Beacon Biosignals, Inc.", pages=["API" => "index.md"]) -deploydocs(repo="github.com/beacon-biosignals/EDF.jl.git") +deploydocs(; repo="github.com/beacon-biosignals/EDF.jl.git") diff --git a/format/Manifest.toml b/format/Manifest.toml new file mode 100644 index 0000000..ba35806 --- /dev/null +++ b/format/Manifest.toml @@ -0,0 +1,221 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.9.3" +manifest_format = "2.0" +project_hash = "30b405be1c677184b7703a9bfb3d2100029ccad0" + +[[deps.ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[deps.Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[deps.CSTParser]] +deps = ["Tokenize"] +git-tree-sha1 = "3ddd48d200eb8ddf9cb3e0189fc059fd49b97c1f" +uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f" +version = "3.3.6" + +[[deps.CommonMark]] +deps = ["Crayons", "JSON", "PrecompileTools", "URIs"] +git-tree-sha1 = "532c4185d3c9037c0237546d817858b23cf9e071" +uuid = "a80b9123-70ca-4bc0-993e-6e3bcb318db6" +version = "0.8.12" + +[[deps.Compat]] +deps = ["UUIDs"] +git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "4.10.0" + + [deps.Compat.extensions] + CompatLinearAlgebraExt = "LinearAlgebra" + + [deps.Compat.weakdeps] + Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[deps.Crayons]] +git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" +uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" +version = "4.1.1" + +[[deps.DataStructures]] +deps = ["Compat", "InteractiveUtils", "OrderedCollections"] +git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.18.15" + +[[deps.Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" + +[[deps.Glob]] +git-tree-sha1 = "97285bbd5230dd766e9ef6749b80fc617126d496" +uuid = "c27321d9-0574-5035-807b-f59d2c89b15c" +version = "1.3.1" + +[[deps.InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[deps.JSON]] +deps = ["Dates", "Mmap", "Parsers", "Unicode"] +git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.21.4" + +[[deps.JuliaFormatter]] +deps = ["CSTParser", "CommonMark", "DataStructures", "Glob", "Pkg", "PrecompileTools", "Tokenize"] +git-tree-sha1 = "80031f6e58b09b0de4553bf63d9a36ec5db57967" +uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899" +version = "1.0.39" + +[[deps.LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.3" + +[[deps.LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "7.84.0+0" + +[[deps.LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.10.2+0" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[deps.Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[deps.Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[deps.MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.2+0" + +[[deps.Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[deps.MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2022.10.11" + +[[deps.NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" + +[[deps.OrderedCollections]] +git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.6.2" + +[[deps.Parsers]] +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "2.7.2" + +[[deps.Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.9.2" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.2.0" + +[[deps.Preferences]] +deps = ["TOML"] +git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.4.1" + +[[deps.Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[deps.REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[deps.Random]] +deps = ["SHA", "Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[deps.Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[deps.TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.3" + +[[deps.Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.0" + +[[deps.Tokenize]] +git-tree-sha1 = "90538bf898832b6ebd900fa40f223e695970e3a5" +uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" +version = "0.5.25" + +[[deps.URIs]] +git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" +uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" +version = "1.5.1" + +[[deps.UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[deps.Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[deps.Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.13+0" + +[[deps.nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.48.0+0" + +[[deps.p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+0" diff --git a/format/Project.toml b/format/Project.toml new file mode 100644 index 0000000..f3aab8b --- /dev/null +++ b/format/Project.toml @@ -0,0 +1,2 @@ +[deps] +JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" diff --git a/format/run.jl b/format/run.jl new file mode 100644 index 0000000..3499f03 --- /dev/null +++ b/format/run.jl @@ -0,0 +1,14 @@ +using JuliaFormatter + +function main() + perfect = format("."; style=YASStyle(), verbose=true) + if perfect + @info "Linting complete - no files altered" + else + @info "Linting complete - files altered" + run(`git status`) + end + return nothing +end + +main() diff --git a/src/read.jl b/src/read.jl index 0ab17bd..91e408e 100644 --- a/src/read.jl +++ b/src/read.jl @@ -81,7 +81,8 @@ function read_file_header(io::IO) patient_id = something(tryparse(PatientID, patient_id_raw), String(patient_id_raw)) recording_id_raw = strip(String(Base.read(io, 80))) - recording_id = something(tryparse(RecordingID, recording_id_raw), String(recording_id_raw)) + recording_id = something(tryparse(RecordingID, recording_id_raw), + String(recording_id_raw)) start_raw = Base.read(io, 8) push!(start_raw, UInt8(' ')) @@ -108,7 +109,8 @@ function read_file_header(io::IO) end function read_signal_headers(io::IO, signal_count) - fields = [String(Base.read(io, size)) for signal in 1:signal_count, (_, size) in SIGNAL_HEADER_FIELDS] + fields = [String(Base.read(io, size)) + for signal in 1:signal_count, (_, size) in SIGNAL_HEADER_FIELDS] signal_headers = [SignalHeader(strip(fields[i, 1]), strip(fields[i, 2]), strip(fields[i, 3]), parse_float(fields[i, 4]), parse_float(fields[i, 5]), parse_float(fields[i, 6]), @@ -139,7 +141,7 @@ function read_to!(io::IO, x::AbstractArray{T}) where {T} end function read_signals!(file::File) - for record_index in 1:file.header.record_count, signal in file.signals + for record_index in 1:(file.header.record_count), signal in file.signals read_signal_record!(file, signal, record_index) end return nothing @@ -157,7 +159,8 @@ end function read_signal_record!(file::File, signal::AnnotationsSignal, record_index::Int) bytes_per_sample = sizeof(sample_type(file)) - io_for_record = IOBuffer(Base.read(file.io, bytes_per_sample * signal.samples_per_record)) + io_for_record = IOBuffer(Base.read(file.io, + bytes_per_sample * signal.samples_per_record)) tals_for_record = TimestampedAnnotationList[] while !eof(io_for_record) && Base.peek(io_for_record) != 0x00 push!(tals_for_record, read_tal(io_for_record)) @@ -172,7 +175,8 @@ function read_tal(io::IO) timestamp = split(String(bytes), '\x15'; keepempty=false) onset_in_seconds = flipsign(parse(Float64, timestamp[1]), sign) duration_in_seconds = length(timestamp) == 2 ? parse(Float64, timestamp[2]) : nothing - annotations = convert(Vector{String}, split(String(readuntil(io, 0x00)), '\x14'; keepempty=true)) + annotations = convert(Vector{String}, + split(String(readuntil(io, 0x00)), '\x14'; keepempty=true)) isempty(last(annotations)) && pop!(annotations) return TimestampedAnnotationList(onset_in_seconds, duration_in_seconds, annotations) end @@ -182,6 +186,7 @@ function read_tal_onset_sign(io::IO) sign === 0x2b && return 1 sign === 0x2d && return -1 error("starting byte of a TAL must be '+' or '-'; found $sign") + return nothing end ##### diff --git a/src/types.jl b/src/types.jl index 37eeaa1..39e0f50 100644 --- a/src/types.jl +++ b/src/types.jl @@ -161,7 +161,8 @@ function AnnotationsSignal(records::Vector{Vector{TimestampedAnnotationList}}) # but cleanly refactoring the package to do this would be a more involved # change than is meritted at the moment (since normal signals are already # treated similarly, i.e. the `SignalHeader` is overly trusted). - max_bytes_per_record = maximum(sum(write_tal(IOBuffer(), tal) for tal in record) for record in records) + max_bytes_per_record = maximum(sum(write_tal(IOBuffer(), tal) for tal in record) + for record in records) return AnnotationsSignal(Int16(cld(max_bytes_per_record, 2)), records) end @@ -267,7 +268,7 @@ struct File{T<:SUPPORTED_SAMPLE_TYPES,I<:IO} signals::Vector{Union{Signal{T},AnnotationsSignal}} end -function Base.show(io::IO, edf::File{T}) where T +function Base.show(io::IO, edf::File{T}) where {T} print(io, "EDF.File with ", length(edf.signals), ' ', 8 * sizeof(T), "-bit-encoded signals") return nothing diff --git a/src/write.jl b/src/write.jl index e1e327f..65940b4 100644 --- a/src/write.jl +++ b/src/write.jl @@ -35,19 +35,23 @@ function _edf_repr(x::Real) end end error("failed to fit number into EDF's 8 ASCII character limit: $x") + return nothing end _edf_metadata_repr(::Missing) = 'X' _edf_metadata_repr(x) = _edf_repr(x) -function _edf_repr(metadata::T) where T<:Union{PatientID,RecordingID} +function _edf_repr(metadata::T) where {T<:Union{PatientID,RecordingID}} header = T <: RecordingID ? String["Startdate"] : String[] - return join([header; [_edf_metadata_repr(getfield(metadata, name)) for name in fieldnames(T)]], ' ') + return join([header; + [_edf_metadata_repr(getfield(metadata, name)) for name in fieldnames(T)]], + ' ') end function edf_write(io::IO, value, byte_limit::Integer) edf_value = _edf_repr(value) - sizeof(edf_value) > byte_limit && error("EDF value exceeded byte limit (of $byte_limit bytes) while writing: $value") + sizeof(edf_value) > byte_limit && + error("EDF value exceeded byte limit (of $byte_limit bytes) while writing: $value") bytes_written = Base.write(io, edf_value) while bytes_written < byte_limit bytes_written += Base.write(io, UInt8(' ')) @@ -76,8 +80,10 @@ end ##### function write_header(io::IO, file::File) - length(file.signals) <= 9999 || error("EDF does not allow files with more than 9999 signals") - expected_bytes_written = BYTES_PER_FILE_HEADER + BYTES_PER_SIGNAL_HEADER * length(file.signals) + length(file.signals) <= 9999 || + error("EDF does not allow files with more than 9999 signals") + expected_bytes_written = BYTES_PER_FILE_HEADER + + BYTES_PER_SIGNAL_HEADER * length(file.signals) bytes_written = 0 bytes_written += edf_write(io, file.header.version, 8) bytes_written += edf_write(io, file.header.patient, 80) @@ -106,7 +112,7 @@ end function write_signals(io::IO, file::File) bytes_written = 0 - for record_index in 1:file.header.record_count + for record_index in 1:(file.header.record_count) for signal in file.signals bytes_written += write_signal_record(io, signal, record_index) end diff --git a/test/runtests.jl b/test/runtests.jl index 3a6e18a..3a35121 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,12 +9,12 @@ using Test ##### Testing utilities ##### -function deep_equal(a::T, b::T) where T +function deep_equal(a::T, b::T) where {T} nfields = fieldcount(T) if nfields == 0 return isequal(a, b) # Use `isequal` instead of `==` to handle `missing` else - for i = 1:nfields + for i in 1:nfields typeof(getfield(a, i)) <: IO && continue # Two different files will have different IO sources isdefined(a, i) || return !isdefined(b, i) # Call two undefs equal deep_equal(getfield(a, i), getfield(b, i)) || return false @@ -23,7 +23,7 @@ function deep_equal(a::T, b::T) where T return true end -function deep_equal(a::T, b::T) where T<:AbstractArray +function deep_equal(a::T, b::T) where {T<:AbstractArray} length(a) == length(b) || return false for (x, y) in zip(a, b) deep_equal(x, y) || return false @@ -54,18 +54,24 @@ const DATADIR = joinpath(@__DIR__, "data") @test length(edf.signals) == 140 for signal in edf.signals if signal isa EDF.Signal - @test length(signal.samples) == signal.header.samples_per_record * edf.header.record_count + @test length(signal.samples) == + signal.header.samples_per_record * edf.header.record_count else @test length(signal.records) == edf.header.record_count # XXX seems like this test file actually contains nonsensical onset timestamps... # according to the EDF+ specification, onsets should be relative to the start time of # the entire file, but it seems like whoever wrote these onsets might have used values # that were relative to the start of the surrounding data record - expected = [[TimestampedAnnotationList(0.0, nothing, String[""]), TimestampedAnnotationList(0.0, nothing, ["start"])], - [TimestampedAnnotationList(1.0, nothing, String[""]), TimestampedAnnotationList(0.1344, 0.256, ["type A"])], - [TimestampedAnnotationList(2.0, nothing, String[""]), TimestampedAnnotationList(0.3904, 1.0, ["type A"])], - [TimestampedAnnotationList(3.0, nothing, String[""]), TimestampedAnnotationList(2.0, nothing, ["type B"])], - [TimestampedAnnotationList(4.0, nothing, String[""]), TimestampedAnnotationList(2.5, 2.5, ["type A"])], + expected = [[TimestampedAnnotationList(0.0, nothing, String[""]), + TimestampedAnnotationList(0.0, nothing, ["start"])], + [TimestampedAnnotationList(1.0, nothing, String[""]), + TimestampedAnnotationList(0.1344, 0.256, ["type A"])], + [TimestampedAnnotationList(2.0, nothing, String[""]), + TimestampedAnnotationList(0.3904, 1.0, ["type A"])], + [TimestampedAnnotationList(3.0, nothing, String[""]), + TimestampedAnnotationList(2.0, nothing, ["type B"])], + [TimestampedAnnotationList(4.0, nothing, String[""]), + TimestampedAnnotationList(2.5, 2.5, ["type A"])], [TimestampedAnnotationList(5.0, nothing, String[""])]] @test all(signal.records .== expected) @test AnnotationsSignal(signal.records).samples_per_record == 16 @@ -112,11 +118,14 @@ const DATADIR = joinpath(@__DIR__, "data") @test eof(io) end - @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-0.0023405432)) == "-0.00234" - @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(0.0023405432)) == "0.002340" + @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-0.0023405432)) == + "-0.00234" + @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(0.0023405432)) == + "0.002340" @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(1.002343)) == "1.002343" @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(1011.05432)) == "1011.054" - @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1011.05432)) == "-1011.05" + @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1011.05432)) == + "-1011.05" @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1013441.5)) == "-1013442" @test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1013441.3)) == "-1013441" @test EDF._edf_repr(34577777) == "34577777" @@ -131,13 +140,15 @@ const DATADIR = joinpath(@__DIR__, "data") uneven = EDF.read(joinpath(DATADIR, "test_uneven_samp.edf")) @test sprint(show, uneven) == "EDF.File with 2 16-bit-encoded signals" @test uneven.header.version == "0" - @test uneven.header.patient == "A 3Hz sinewave and a 0.2Hz block signal, both starting in their positive phase" + @test uneven.header.patient == + "A 3Hz sinewave and a 0.2Hz block signal, both starting in their positive phase" @test uneven.header.recording == "110 seconds from 13-JUL-2000 12.05.48hr." @test uneven.header.is_contiguous @test uneven.header.start == DateTime(2000, 1, 31, 23, 0, 59) @test uneven.header.record_count == 11 @test uneven.header.seconds_per_record == 10.0 - @test uneven.signals[1].header.samples_per_record != uneven.signals[2].header.samples_per_record + @test uneven.signals[1].header.samples_per_record != + uneven.signals[2].header.samples_per_record @test length(uneven.signals) == 2 nonint = EDF.read(joinpath(DATADIR, "test_float_extrema.edf")) @@ -156,7 +167,7 @@ const DATADIR = joinpath(@__DIR__, "data") # for x in signal: # f.write("%s\n" % x) # ``` - mne = map(line->parse(Float32, line), eachline(joinpath(DATADIR, "mne_values.csv"))) + mne = map(line -> parse(Float32, line), eachline(joinpath(DATADIR, "mne_values.csv"))) for (a, b) in zip(EDF.decode(signal), mne) @test a ≈ b atol=0.01 end @@ -168,7 +179,8 @@ const DATADIR = joinpath(@__DIR__, "data") truncated_file = joinpath(dir, "test_truncated" * last(splitext(full_file))) full_edf_bytes = read(joinpath(DATADIR, full_file)) write(truncated_file, full_edf_bytes[1:(end - 1)]) - @test_logs((:warn, "Number of data records in file header does not match " * + @test_logs((:warn, + "Number of data records in file header does not match " * "file size. Skipping 1 truncated data record(s)."), EDF.read(truncated_file)) edf = EDF.read(joinpath(DATADIR, full_file)) @@ -243,7 +255,6 @@ const DATADIR = joinpath(@__DIR__, "data") end end - @testset "BDF+ Files" begin # This is a `BDF+` file containing only trigger information. # It is similiar to a `EDF Annotations` file except that