Skip to content

Commit

Permalink
Merge pull request #100 from capitalone/dev
Browse files Browse the repository at this point in the history
Bug fix and update to CLA
  • Loading branch information
KrishanBhasin committed Nov 23, 2020
2 parents 2457f48 + fd97215 commit 567a64e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .whitesource
@@ -0,0 +1,8 @@
{
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,3 @@

# Currently sharing all of the files together
* @sajohnston @KrishanBhasin
10 changes: 2 additions & 8 deletions README.md
Expand Up @@ -113,12 +113,6 @@ https://cran.r-project.org/package=dataCompareR

## External Contributors

Contributors: We welcome your interest in Capital One’s Open Source Projects (the “Project”).
We welcome and appreciate your contributions! Before we can accept any contributions, we ask that you please be sure to sign the [Contributor License Agreement (CLA)](https://cla-assistant.io/capitalone/dataCompareR).

Any Contributor to the project must accept and sign a CLA indicating agreement to the license terms. Except for the license granted in this CLA to Capital One and to recipients of software distributed by Capital One, you reserve all right, title, and interest in and to your contributions; this CLA does not impact your rights to use your own contributions for any other purpose.

[Link to Individual CLA](https://docs.google.com/forms/d/19LpBBjykHPox18vrZvBbZUcK6gQTj7qv1O5hCduAZFU/viewform)

[Link to Corporate CLA ](https://docs.google.com/forms/d/e/1FAIpQLSeAbobIPLCVZD_ccgtMWBDAcN68oqbAJBQyDTSAQ1AkYuCp_g/viewform)

This project adheres to the [Open Source Code of Conduct](https://developer.capitalone.com/single/code-of-conduct/). By participating, you are expected to honor this code.
This project adheres to the [Open Source Code of Conduct](https://developer.capitalone.com/resources/code-of-conduct/). By participating, you are expected to honor this code.
4 changes: 2 additions & 2 deletions dataCompareR/R/pd_matchRows.R
Expand Up @@ -140,8 +140,8 @@ matchSingleIndex <- function(df_a, df_b, index_key, original_keys)
#' contains the vectors for the dropped rows
matchMultiIndex <- function(df_a, df_b, indices)
{
df_a$dataCompareR_merged_indices <- do.call(paste,c(df_a[indices],sep = ""))
df_b$dataCompareR_merged_indices <- do.call(paste,c(df_b[indices],sep = ""))
df_a$dataCompareR_merged_indices <- do.call(paste,c(df_a[indices],sep = "_"))
df_b$dataCompareR_merged_indices <- do.call(paste,c(df_b[indices],sep = "_"))

mtchedData <- matchSingleIndex(df_a, df_b, 'dataCompareR_merged_indices', indices)

Expand Down
34 changes: 34 additions & 0 deletions dataCompareR/tests/testthat/testMatchMultiIndex.R
Expand Up @@ -93,3 +93,37 @@ test_that("matchMultiIndex doesn't produce any warnings when creating output" ,
expect_message(summary(a),"dataCompareR is generating the summary...")

})

test_that("Merged indices remain unique in multi-index cases", {

# Create data frames with values that if merged without a separator, would
# produce the same merged index.

# No differences
ky <- c(1, 2)
ky1 <- c("a1", "a")
ky2 <- c("b", "1b")
df1 <- data.frame(ky1, ky2, ky, stringsAsFactors = FALSE)

# Second data frame. Same as first
df2 <- df1

# Matching data fame will be the same as well
dfMtch <- df1

# Do the actual matching. If the indices weren't unique, an error would be raised
# This shouldn't produce any errors because they are separate indices
expect_silent(mtch <- matchMultiIndex(df1, df2, c("ky1", "ky2"))) # Expected matched subset

# Check that the output is still as expected
mtchSorted <- arrange(mtch[[1]], ky1, ky2)
dfMtchSorted <- arrange(dfMtch, ky1, ky2)

expect_equal(mtchSorted[,1], dfMtchSorted[,1])
expect_equal(mtchSorted[,2], dfMtchSorted[,2])

mtch2Sorted <- arrange(mtch[[2]], ky1, ky2)

expect_equal(mtch2Sorted[,1], dfMtchSorted[,1])
expect_equal(mtch2Sorted[,2], dfMtchSorted[,2])
})
34 changes: 34 additions & 0 deletions dataCompareR/tests/testthat/testMatchRows.R
Expand Up @@ -166,3 +166,37 @@ test_that("matchRows correctly finds matching rows", {
expect_equal(mtchSorted32[[1]], msgB1) # Missing indices from A
expect_equal(mtchSorted32[[2]], msgB2) # Missing indices from A
})

test_that("Merged indices remain unique in multi-index cases", {

# Create data frames with values that if merged without a separator, would
# produce the same merged index.

# No differences
ky <- c(1, 2)
ky1 <- c("a1", "a")
ky2 <- c("b", "1b")
df1 <- data.frame(ky1, ky2, ky, stringsAsFactors = FALSE)

# Second data frame. Same as first
df2 <- df1

# Matching data fame will be the same as well
dfMtch <- df1

# Do the actual matching. If the indices weren't unique, an error would be raised
# This shouldn't produce any errors because they are separate indices
expect_silent(mtch <- matchRows(df1, df2, c("ky1", "ky2"))) # Expected matched subset

# Check that the output is still as expected
mtchSorted <- arrange(mtch[[1]], ky1, ky2)
dfMtchSorted <- arrange(dfMtch, ky1, ky2)

expect_equal(mtchSorted[,1], dfMtchSorted[,1])
expect_equal(mtchSorted[,2], dfMtchSorted[,2])

mtch2Sorted <- arrange(mtch[[2]], ky1, ky2)

expect_equal(mtch2Sorted[,1], dfMtchSorted[,1])
expect_equal(mtch2Sorted[,2], dfMtchSorted[,2])
})

0 comments on commit 567a64e

Please sign in to comment.