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

Allow sector borderline input (#326) #327

Closed
wants to merge 5 commits into from
Closed

Allow sector borderline input (#326) #327

wants to merge 5 commits into from

Conversation

jdhoffa
Copy link
Member

@jdhoffa jdhoffa commented Nov 26, 2020

match_name now accepts a loanbook object that may or may not have the sector and borderline defined. If defined, it will use these values, otherwise, it will join our proprietary sector classifications.

A fun side-product of this is that users can now manually set the sectors!

Relates to 2DegreesInvesting/r2dii.analysis#227
Closes #326

Here I check if the input loanbook has sector or borderline before
joining the original columns back.
@jdhoffa jdhoffa requested a review from maurolepore November 26, 2020 11:33
@jdhoffa jdhoffa changed the title Allow sector borderline input Allow sector borderline input (#326) Nov 26, 2020
Copy link
Contributor

@maurolepore maurolepore left a comment

Choose a reason for hiding this comment

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

Do you remember why we chose to not allow using "sector" before? Maybe to avoid complicating the code with assertions to ensure sector was valid?

If there is no good reason, then this LGTM and I approve.

If there is a good reason to not allow using "sector", then it might be safer to start the body of abort_reserved_column() with something like this:

if (getOptions("r2dii.match_abort_reserved_column") == "dissable") {
  return(invisible(data))
}

Then in r2dii.analysis we could set options(r2dii.match_abort_reserved_column = "dissable") in our testing environment so that match_name() let us use reserved columns.

@jdhoffa
Copy link
Member Author

jdhoffa commented Nov 27, 2020

After running a git bisect, I found that the commit that introduced this checking of reserved columns was: c298fae.
This PR closed #233. It seems that match_name produced an error if sector was provided, so we simply elected to not allow it on input.

It looks as though, through some refactoring, we may have accidentally fixed this bug, and now it seems as though providing a sector column on input produces the expected behavior.

I'm happy with this solution, and would like to merge as is, but will wait for you to have a look at this and see if you agree.

maurolepore added a commit that referenced this pull request Nov 27, 2020
Closes #326
Closes #327 -- this is a simpler/safer way to solve it.
Relates to:
* https://github.com/2DegreesInvesting/r2dii.analysis/pull/227
* https://github.com/2DegreesInvesting/r2dii.analysis/pull/230

This change is internal, and motivated by our need to break the
dependency between r2dii.data and its reverse dependencies. The
problem we are trying to solve is this:

r2dii.data provides data that is used in some functions if its
reverse dependencies -- like r2dii.match. Concretely, changes in
the sector classification dataset (in r2dii.data) make tests to
fail in reverse dependencies like r2dii.match that store a
snapshot of expected output (e.g. of match_name()).

This commit allows us to use generate such snaphsots with a
frozen loanbook, and thus make r2dii packages less prone to
meaningless errors when CRAN checks for reverse dependencies.
@maurolepore maurolepore marked this pull request as draft November 27, 2020 19:50
@maurolepore
Copy link
Contributor

Closing this in favor of #328

@jdhoffa jdhoffa deleted the 326-allow_sector_input branch November 30, 2020 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

match_name should allow loanbook_demo to have reserved columns sector and borderline
2 participants