-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from eliascarv/choose
Rename `_filter` to `choose` and create colspec.jl file in test folder
- Loading branch information
Showing
6 changed files
with
112 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
@testset "ColSpec" begin | ||
vecnames = [:a, :b, :c, :d, :e, :f] | ||
tupnames = (:a, :b, :c, :d, :e, :f) | ||
|
||
# vector of symbols | ||
colspec = [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# tuple of symbols | ||
colspec = (:a, :c, :e) | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# vector of strings | ||
colspec = ["a", "c", "e"] | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# tuple of strings | ||
colspec = ("a", "c", "e") | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# vector of integers | ||
colspec = [1, 3, 5] | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# tuple of integers | ||
colspec = (1, 3, 5) | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# regex | ||
colspec = r"[ace]" | ||
snames = TableTransforms.choose(colspec, vecnames) | ||
@test snames == [:a, :c, :e] | ||
snames = TableTransforms.choose(colspec, tupnames) | ||
@test snames == [:a, :c, :e] | ||
|
||
# colon | ||
snames = TableTransforms.choose(:, vecnames) | ||
@test snames == [:a, :b, :c, :d, :e, :f] | ||
snames = TableTransforms.choose(:, tupnames) | ||
@test snames == [:a, :b, :c, :d, :e, :f] | ||
|
||
# throws | ||
@test_throws AssertionError TableTransforms.choose(r"x", vecnames) | ||
@test_throws AssertionError TableTransforms.choose(r"x", tupnames) | ||
@test_throws AssertionError TableTransforms.choose(String[], vecnames) | ||
@test_throws AssertionError TableTransforms.choose(String[], tupnames) | ||
@test_throws AssertionError TableTransforms.choose(Symbol[], vecnames) | ||
@test_throws AssertionError TableTransforms.choose(Symbol[], tupnames) | ||
|
||
# type stability | ||
@inferred TableTransforms.choose([:a, :b], vecnames) | ||
@inferred TableTransforms.choose([:a, :b], tupnames) | ||
@inferred TableTransforms.choose((:a, :b), vecnames) | ||
@inferred TableTransforms.choose((:a, :b), tupnames) | ||
@inferred TableTransforms.choose(["a", "b"], vecnames) | ||
@inferred TableTransforms.choose(["a", "b"], tupnames) | ||
@inferred TableTransforms.choose(("a", "b"), vecnames) | ||
@inferred TableTransforms.choose(("a", "b"), tupnames) | ||
@inferred TableTransforms.choose([1, 2], vecnames) | ||
@inferred TableTransforms.choose([1, 2], tupnames) | ||
@inferred TableTransforms.choose((1, 2), vecnames) | ||
@inferred TableTransforms.choose((1, 2), tupnames) | ||
@inferred TableTransforms.choose(r"[ab]", vecnames) | ||
@inferred TableTransforms.choose(r"[ab]", tupnames) | ||
@inferred TableTransforms.choose(:, vecnames) | ||
@inferred TableTransforms.choose(:, tupnames) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters