Skip to content
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

Define all.equal for transformations #22

Merged
merged 3 commits into from Jan 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,5 +1,6 @@
### Version 0.1.0.9001
### Version 0.1.0.9001-2

* Define `all.equal` for object of S3 class "transformation".
* Fix a bug in `column_transformation` wherein `NULL` return
values corrupted the data.frame instead of dropping columns.

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -6,7 +6,7 @@ Description: A way of thinking about data preparation that
online prediction so that both can be described by the same codebase.
With mungebits, you can save time on having to re-implement your
R code to work in production and instead re-use the same codebase.
Version: 0.1.0.9001
Version: 0.1.0.9002
Author: Robert Krzyzanowski <rob@syberia.io>
Maintainer: Robert Krzyzanowski <rob@syberia.io>
Authors@R: c(person("Robert", "Krzyzanowski",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
@@ -1,5 +1,6 @@
# Generated by roxygen2 (4.1.1): do not edit by hand

S3method(all,equal.transformation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertzk FYI NAMESPACE was generated incorrectly. You need to specify #' @method all.equal transformation in your roxygen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - thank you.

S3method(debug,default)
S3method(debug,mungebit)
S3method(debug,mungepiece)
Expand Down
6 changes: 6 additions & 0 deletions R/column_transformation.R
Expand Up @@ -309,3 +309,9 @@ print.column_transformation <- function(x, ...) {
print_transformation(x, ..., byline = "Column transformation")
}

#' @export
all.equal.transformation <- function(target, current, ...) {
identical(parent.env(environment(target))$transformation,
parent.env(environment(current))$transformation)
}

2 changes: 1 addition & 1 deletion man/mungepiece.Rd
Expand Up @@ -4,7 +4,7 @@
\name{mungepiece}
\alias{mungepiece}
\title{Mungepiece.}
\format{\preformatted{Class 'R6ClassGenerator' <environment: 0x7f9a254f7550>
\format{\preformatted{Class 'R6ClassGenerator' <environment: 0x7ff39da70188>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe wrap in dontrun

- attr(*, "name")= chr "mungepiece_generator"
}}
\usage{
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-printing.R
Expand Up @@ -164,5 +164,16 @@ describe("transformations", {
ct <- multi_column_transformation(function(x) { 2 * x + 1 }, nonstandard = TRUE)
expect_output(print(ct), "non-standard", fixed = TRUE)
})

test_that("it can tell when the train and predict of a column transformation differ", {
bit <- mungebit$new(column_transformation(function(x) x), column_transformation(function(x) x + 1))
expect_output(print(bit), "train function")
expect_output(print(bit), "predict function")
})

test_that("it can tell when the train and predict of a column transformation are equivalent", {
bit <- mungebit$new(column_transformation(function(x) x))
expect_output(print(bit), "train and predict function")
})
})