add test for edit/split
This commit is contained in:
parent
77769d040f
commit
39b5a334c7
3 changed files with 20 additions and 11 deletions
12
src/edit.jl
12
src/edit.jl
|
@ -1,17 +1,17 @@
|
|||
"""
|
||||
split_log(log::CoordLog, at::Unsigned, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||
|
||||
Split `log` at `at`, i.e. to `1:at` and `at:end` then assign `notes_1` and `notes_2` to notes for each other.
|
||||
Split `log` at `at`, i.e. to `1:at` and `(at + 1):end` then assign `notes_1` and `notes_2` to notes for each other.
|
||||
"""
|
||||
function split_log(log::CoordLog, at::Unsigned, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||
function split_log(log::CoordLog, at::Unsigned, notes_1::AbstractString, notes_2::AbstractString)::Tuple{CoordLog, CoordLog}
|
||||
@assert at < size(log.coords)[1] "Split index must be less than original log length($(size(log.coords)[1]))"
|
||||
[
|
||||
(
|
||||
CoordLog(log.coords[1:at, :], log.logdate, notes_1),
|
||||
CoordLog(log.coords[at:end, :], log.logdate, notes_2),
|
||||
]
|
||||
CoordLog(log.coords[(at + 1):end, :], log.logdate, notes_2),
|
||||
)
|
||||
end
|
||||
|
||||
function split_log(log::CoordLog, at::Integer, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||
function split_log(log::CoordLog, at::Integer, notes_1::AbstractString, notes_2::AbstractString)::Tuple{CoordLog, CoordLog}
|
||||
split_log(log, UInt(at), notes_1, notes_2)
|
||||
end
|
||||
|
||||
|
|
|
@ -85,8 +85,4 @@ function parse_log(filepaths::Vector{T}; interactive=false)::Vector{CoordLog} wh
|
|||
parse_log(filepath; interactive=interactive)
|
||||
end |> Iterators.flatten |> collect
|
||||
end
|
||||
CoordLog(
|
||||
[1.0 2.0 3.0; 4.0 5.0 6.0],
|
||||
Dates.now(),
|
||||
"a"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@ using Dates
|
|||
using Test
|
||||
|
||||
@testset "CoordVisualize" begin
|
||||
"Must be same as the first log in `sample_log.txt`"
|
||||
sample_log_1 = CoordVisualize.CoordLog[CoordVisualize.CoordLog{Float64}([-54.0 -10.000000953674 -35.000003814697; -54.0 -10.000000953674 -35.000003814697; -54.0 -10.000000953674 -36.013381958008; -54.0 -10.000000953674 -37.615753173828; -54.0 -10.000000953674 -39.261665344238; -54.0 -10.000000953674 -40.727695465088; -54.0 -10.000000953674 -42.168701171875; -54.0 -10.000000953674 -43.820377349854; -54.0 -11.018865585327 -47.018901824951; -54.0 -14.0 -51.176284790039; -54.663269042969 -14.0 -55.0; -58.297706604004 -14.0 -55.0; -63.16588973999 -16.0 -55.0; -66.000007629395 -16.0 -55.526763916016; -66.000007629395 -16.0 -59.460041046143; -66.000007629395 -16.0 -63.24658203125; -66.000007629395 -16.0 -67.261924743652; -66.000007629395 -16.0 -71.199310302734], Dates.DateTime("2023-10-22T10:02:04"), "")]
|
||||
|
||||
"Must be same as the second log in `sample_log.txt`"
|
||||
sample_log_2 = CoordVisualize.CoordLog{Float64}([895.0 7.0 -978.0; 895.0 7.0 -978.0; 895.0 7.0 -977.38684082031; 895.0 7.0 -975.71923828125; 897.0 7.0 -974.39855957031; 898.80633544922 7.0 -973.0; 901.38275146484 7.0 -973.0; 904.18518066406 7.0 -973.0; 907.25793457031 7.0 -973.0; 911.19061279297 7.0 -973.0; 915.05682373047 7.0 -973.0; 919.1259765625 7.0 -973.0; 923.12609863281 7.0 -973.0; 926.94378662109 7.0 -973.0; 930.82952880859 7.0 -973.0; 934.84539794922 7.0 -973.0; 938.83020019531 7.0 -973.0; 944.04681396484 8.0 -973.0; 948.01483154297 8.0148372650146 -973.0; 951.48193359375 9.0000009536743 -973.0; 955.5927734375 10.000000953674 -973.0; 954.96008300781 10.000000953674 -973.0; 958.39764404297 11.000000953674 -973.0; 962.41009521484 12.000000953674 -973.0; 966.17108154297 12.000000953674 -973.0; 969.40936279297 12.000000953674 -973.0; 969.47576904297 13.0 -973.0; 973.32684326172 13.0 -973.0; 977.21990966797 13.0 -973.0; 981.09814453125 13.0 -973.0; 985.05871582031 13.0 -973.0; 989.03479003906 13.0 -973.0; 992.83026123047 13.0 -973.0; 996.90203857422 13.0 -973.0], DateTime("0000-01-01T00:00:00"), "")
|
||||
|
||||
sample_result = CoordVisualize.parse_log("sample_log.txt"; interactive=false)
|
||||
|
@ -35,5 +37,16 @@ using Test
|
|||
CoordVisualize.assign_note!(sample_log_2, "test string ✅")
|
||||
@test sample_log_2.note == "test string ✅"
|
||||
end
|
||||
|
||||
@testset "split" begin
|
||||
splitted_1, splitted_2 = CoordVisualize.split_log(sample_log_1[1], 10, "former one", "latter one")
|
||||
@debug "splitted_1 and splitted_2"
|
||||
@debug splitted_1
|
||||
@debug splitted_2
|
||||
@test CoordVisualize.n_coords(splitted_1) == 10
|
||||
@test CoordVisualize.n_coords(splitted_2) == CoordVisualize.n_coords(sample_log_1[1]) - 10
|
||||
@test splitted_1.note == "former one"
|
||||
@test splitted_2.note == "latter one"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue