Hey @randrescastaneda I've finally completed this PR. Here is a summary of what I have done:
Refactor the code
I haven't changed your logic much, but I broke the code down into smaller functions that can be easily unit tested
Re-organize the code
I reorganized the code into 4 main sections: 1) setup, 2) Identify regions 3) Identify countries 4) Variables related to missing countries
Modify part of the logic
As I mentioned above, I did not touch the logic much. I believe the only place I changed some of the logic is in section 2)
Identify regions to fix the region selection issue.
Add unit tests
I added a lot of unit tests. I still think we are not testing all the possible combinations, but I feel much more comfortable about
changing that code now.
Remove part of the code
I removed some elements of the lret list as they were never used outside of the create_countries_vctr function.
Can you please do the following:
Urgent: Review the PR to see if we can merge it.
Less urgent: Review the code and unit tests corresponding to section 4. I still don't have a full handle on this part of the code, and I'm not 100% confident that I implemented the correct unit tests.
Hey @randrescastaneda I've finally completed this PR. Here is a summary of what I have done:
I haven't changed your logic much, but I broke the code down into smaller functions that can be easily unit tested
lret
list as they were never used outside of thecreate_countries_vctr
function.Can you please do the following:
Thanks!