-
-
Notifications
You must be signed in to change notification settings - Fork 50
added TableDataset #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19a77ac
81369e8
8eaa656
b9c65eb
8585fc7
dc4b007
d483b6d
52a456d
1d52456
134f1bc
a2f6261
d30c7f8
81b36dd
9b36af1
77d9d2b
519a3a7
6f00d25
2462546
d40c1f8
77459fa
c0f3fcc
d92e32b
6161b0a
aa9f9af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
[deps] | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" | ||
DLPipelines = "e6530d7c-7faa-4ede-a0d6-9eff9baad396" | ||
DataAugmentation = "88a5189c-e7ff-4f85-ac6b-e6158070f02e" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" | ||
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" | ||
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
ShowCases = "605ecd9f-84a6-4c9e-81e2-4798472b76a3" | ||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These seem orthogonal, maybe @lorenzoh can double-check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JLD2, Makie and ShowCases are already in the master branch, not sure why they're shown here. Might just be that the list was sorted on a ]pkg command. |
||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
include("../imports.jl") | ||
|
||
@testset ExtendedTestSet "TableDataset" begin | ||
|
||
@testset ExtendedTestSet "TableDataset from rowaccess table" begin | ||
Tables.columnaccess(::Type{<:Tables.MatrixTable}) = false | ||
Tables.rowaccess(::Type{<:Tables.MatrixTable}) = true | ||
|
||
testtable = Tables.table([1 4.0 "7"; 2 5.0 "8"; 3 6.0 "9"]) | ||
td = TableDataset(testtable) | ||
|
||
@test all(getobs(td, 1) .== [1, 4.0, "7"]) | ||
@test nobs(td) == 3 | ||
end | ||
|
||
@testset ExtendedTestSet "TableDataset from columnaccess table" begin | ||
Tables.columnaccess(::Type{<:Tables.MatrixTable}) = true | ||
Tables.rowaccess(::Type{<:Tables.MatrixTable}) = false | ||
|
||
testtable = Tables.table([1 4.0 "7"; 2 5.0 "8"; 3 6.0 "9"]) | ||
td = TableDataset(testtable) | ||
|
||
@test [data for data in getobs(td, 2)] == [2, 5.0, "8"] | ||
@test nobs(td) == 3 | ||
manikyabard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@test getobs(td, 1) isa NamedTuple | ||
end | ||
|
||
@testset ExtendedTestSet "TableDataset from DataFrames" begin | ||
testtable = DataFrame( | ||
col1=[1, 2, 3, 4, 5], | ||
col2=["a", "b", "c", "d", "e"], | ||
col3=[10, 20, 30, 40, 50], | ||
col4=["A", "B", "C", "D", "E"], | ||
col5=[100., 200., 300., 400., 500.], | ||
split=["train", "train", "train", "valid", "valid"] | ||
) | ||
td = TableDataset(testtable) | ||
@test td isa TableDataset{<:DataFrame} | ||
|
||
@test [data for data in getobs(td, 1)] == [1, "a", 10, "A", 100., "train"] | ||
@test nobs(td) == 5 | ||
end | ||
|
||
@testset ExtendedTestSet "TableDataset from CSV" begin | ||
open("test.csv", "w") do io | ||
write(io, "col1,col2,col3,col4,col5, split\n1,a,10,A,100.,train") | ||
end | ||
testtable = CSV.File("test.csv") | ||
td = TableDataset(testtable) | ||
@test td isa TableDataset{<:CSV.File} | ||
@test [data for data in getobs(td, 1)] == [1, | ||
"a", | ||
10, | ||
"A", | ||
100., | ||
"train"] | ||
@test nobs(td) == 1 | ||
rm("test.csv") | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.