-
Notifications
You must be signed in to change notification settings - Fork 15
Add Coerce #37
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
Merged
Merged
Add Coerce #37
Changes from 8 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
5eb55b1
Added Coerce transform
7d4fc92
Fixed the tests for Coerce transform
e3be036
Fixed a style issue
a75ac7b
Updated Coerce transform
106c92e
Added a missing dependency for tests
93fa98e
Revised Coerce transform
81d6c4a
Added a new constructor for Coerce struct
654cc04
Added missing parameters to Coerce transform & Tidied up Coerce trans…
bd6ee77
Revised Coerce transform
5d82ca6
Update src/transforms/coerce.jl
ceferisbarov 4d4b732
Update src/transforms/coerce.jl
ceferisbarov 083bfb9
Update src/transforms/coerce.jl
ceferisbarov 567bf3a
Updated docstring od Coerce transform
0355178
Update src/transforms/coerce.jl
ceferisbarov 6b6e430
Update test/runtests.jl
ceferisbarov dc0a308
Updated tests for Coerce transform
362798d
Merge branch 'coerce' of https://github.com/ceferisbarov/TableTransfo…
967eda0
Removed an unnecessary dependency from test/runtests.jl
a194745
Updated the reverse function for Coerce transform
8a7f82d
Update test/transforms.jl
ceferisbarov 1f949c9
Update src/transforms/coerce.jl
ceferisbarov 530828f
Refactored the revert function of Coerce transform
16afabf
Update src/transforms/coerce.jl
ceferisbarov a572062
Update src/transforms/coerce.jl
ceferisbarov 92b8f21
Update src/transforms/coerce.jl
ceferisbarov bf913d7
Update src/transforms/coerce.jl
ceferisbarov be90b87
Fixed a typo
b005beb
Fixed a typo
eae03d4
Added categorical tests for Coerce transform
147bb14
Added a missing dependency
7a9eeb5
Update test/runtests.jl
juliohm 6c9457f
Refactored the reverse function of Coerce transform
b3d4387
Merge branch 'coerce' of https://github.com/ceferisbarov/TableTransfo…
580dd2e
Update test/transforms.jl
juliohm 41fec8b
Update test/transforms.jl
juliohm b98ff15
Update test/transforms.jl
juliohm 1fd2523
Update test/transforms.jl
juliohm 8252563
Update src/transforms/coerce.jl
juliohm 537c335
Added Coerce to README
7a2d1ab
Update README.md
juliohm c735b9b
Merge branch 'master' into coerce
ceferisbarov d99e7e8
Removed a space
f196d3a
Update README.md
juliohm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ export | |
| DropMissing, | ||
| Rename, | ||
| Identity, | ||
| Coerce, | ||
| Center, | ||
| Scale, | ||
| MinMax, | ||
|
|
||
This file contains hidden or 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 hidden or 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,34 @@ | ||
| # ------------------------------------------------------------------ | ||
| # Licensed under the MIT License. See LICENSE in the project root. | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| """ | ||
| Coerce(pairs, tight=false, verbosity=1) | ||
| Return a copy of the table, ensuring that the element scitypes of the columns match the new specification. | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Valid specifications (more to be added): | ||
| (1) one or more column_name=>Scitype pairs | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| struct Coerce{P, T, V} <: Transform | ||
| pairs::P | ||
| tight::T | ||
| verbosity::V | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| Coerce(pair...; tight=false, verbosity=1) = Coerce(pair, tight, verbosity) | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| isrevertible(::Type{<:Coerce}) = true | ||
|
|
||
| function apply(transform::Coerce, table) | ||
| newtable = ScientificTypes.coerce(table, transform.pairs...; tight=transform.tight, verbosity=transform.verbosity) | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| scitypes = [ScientificTypes.elscitype(x) for x in Tables.columns(table)] | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| colnames = Tables.columnnames(table) | ||
| pairs = [Pair(i, j) for (i, j) in zip(colnames, scitypes)] | ||
|
|
||
| return newtable, pairs | ||
ceferisbarov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| revert(transform::Coerce, newtable, cache) = ScientificTypes.coerce(newtable, cache...) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.