-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unit testing, renaming functions, adding docs #124
Open
RayStick
wants to merge
68
commits into
main
Choose a base branch
from
big-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
github-actions
bot
added
the
documentation
Improvements or additions to documentation
label
Sep 13, 2024
RayStick
changed the title
big refactor - renaming and adding tests
Unit testing, renaming functions, adding docs
Sep 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Improvements or additions to documentation
enhancement
Feature improvement or addition
internal
Changes related to GH workflows, actions, apps
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.
Closes #38
Overall description
This PR adds unit testing for this R package.
In order to do this, the main package function(s) needed to be split up into smaller functions, in order to test. When writing tests, it was sometimes obvious that functions should be improved in various ways, and a few sub-optimal coding things were found and corrected.
It also became obvious that there were 2 parts to this package as a whole - the browsing and the mapping. This has been made clearer now, by splitting up two functions, and adding some nice plots.
Changes implemented (by directory)
Parent directory:
.Rbuildignore
and.gitignore
files to better reflect the package structureDESCRIPTION
andNAMESPACE
reflect changes to the package, specifically to do with how imports and exports are handledREADME.md
reflects the new code changesR
directory:There are now 4 main functions that a user can interact with:
browseMetadata.R
(new!)mapMetadata.R
(previously domain_mapping.R)mapMetadata_compare_outputs.R
(previously compare_sessions.R)mapMetadata_convert_outputs.R
(previously convert_outputs.R)All of the other files in the
R
directory are either:data
directory:The same 2 dataframes were made multiple times across the functions. Therefore, to reduce lines of code, they have now been included in the package data:
data/log_Output.rda
data/Output.rda
These can now be read into the functions with one line e.g.
Output <- get("Output")
inst
directory:Some example inputs and outputs have been moved or added, so they can be referenced in the README, or other documentation throughout the package.
man
directory:All new functions require documentation via
.Rd
filestests
directory:All functions require unit tests, written with the testthat package.
Checklist to make it ready for review (for @RayStick):
Checklist for reviewers (@Rainiefantasy )
Tips for user testing (@Rainiefantasy)
setwd('your-path/test_dir')
remove.packages("browseMetadata")
- you may need to specify a pathdevtools::install_github("aim-rsf/browseMetadata", ref = 'big-refactor')
library(browseMetadata)
Testing
browseMetadata.R
Testing
mapMetadata.R
Testing
mapMetadata_convert_outputs.R
mapMetadata_convert_outputs(output_csv = 'OUTPUT_xxx.csv', output_dir = /path/test_dir/')
Check that the above call outputs L-OUTPUT_xxx.csv and that any rows that had multiple categorizations have now been split onto their own rows.
Testing
mapMetadata_compare_outputs.R
inst/inputs
folder to point towards as quick inputs for some of the arguments