Skip to content

Commit

Permalink
Rename TaxonLHTCollector to TaxonLHTPredictedGetter
Browse files Browse the repository at this point in the history
  • Loading branch information
d2gex committed Apr 5, 2024
1 parent e65de77 commit 32d1dd4
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 89 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export(FishlifeLHTNameSpace)
export(MixinUtilities)
export(PredictedLHTPicker)
export(TaxaUpdateExtractor)
export(TaxonLHTCollector)
export(TaxonLHTPredictor)
export(TaxonPredictedLHTGetter)
export(TaxonUpdateExtractor)
export(UpdatedLHTGenerator)
export(UpdatedLHTPicker)
Expand Down
2 changes: 1 addition & 1 deletion R/predicted_lht_picker.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PredictedLHTPicker <- R6::R6Class("PredictedLHTPicker", inherit = MixinUtilities
pick_and_backtransform = function() {
results <- self$wanted_lht_df
for (ind_taxon in self$wanted_lht_df$taxon) {
taxon_grabber <- TaxonLHTCollector$new(self$master_db, ind_taxon)
taxon_grabber <- TaxonPredictedLHTGetter$new(self$master_db, ind_taxon)
taxon_details <- taxon_grabber$extract()
subset_estimated_lhts <- private$subset_taxon_detail_matrix(taxon_details$estimated_lhts)
results <- private$backtransform_and_fill_user_df(subset_estimated_lhts, ind_taxon, results)
Expand Down
4 changes: 2 additions & 2 deletions R/taxon_lht_collector.R → R/taxon_predicted_lht_getter.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Single Taxon LHT GRABBER class
#'
#' @description
#' Class that abstracts away the underlying FishLife dynamics and grab the details of a given taxon
TaxonLHTCollector <- R6::R6Class("TaxonLHTCollector", public = list(
#' Abstracts away the underlying FishLife dynamics and grab the predicted LHT details of a given taxon
TaxonPredictedLHTGetter <- R6::R6Class("TaxonPredictedLHTGetter", public = list(

master_db = NULL,
taxon = NULL,
Expand Down
14 changes: 7 additions & 7 deletions R/updated_lht_generator.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#' Multiple Updated LHT Generator class
#'
#' @description
#' Class that allows the streamline-generation of predicted LHTs given new data.
#' Allows the streamline-generation of updated LHTs given new data.
UpdatedLHTGenerator <- R6::R6Class("UpdatedLHTGenerator", public = list(

master_db = NULL,
predicting_lht_df = NULL,
func_domains = NULL,
transform_function_list = NULL,
lht_names = NULL,
# // @formatter:off
#' @description
#' Initialise the Updated LHT Generator class
#'
#' @param master_db Fishlife database
#' @param predicting_lht_df dataframe providing the taxon details and their predicting LHT values
#' @param func_domains list of transforming function which names must conform to FishLife's expectations
#' @param transform_function_list list of transforming function which names must conform to FishLife's expectations
#' @param lht_names list of user-defined LHT names associated with their FishLife's counterparts
#' @export
# // @formatter:on
initialize = function(master_db, predicting_lht_df, func_domains, lht_names) {
initialize = function(master_db, predicting_lht_df, transform_function_list, lht_names) {
self$master_db <- master_db
self$predicting_lht_df <- predicting_lht_df
self$func_domains <- func_domains
self$transform_function_list <- transform_function_list
self$lht_names <- lht_names
},
# // @formatter:off
Expand Down Expand Up @@ -97,7 +97,7 @@ UpdatedLHTGenerator <- R6::R6Class("UpdatedLHTGenerator", public = list(
updated_lhts <- list()
for (ind_species in names(all_species_local_lhts)) {
species_local_lhts <- all_species_local_lhts[[ind_species]]
taxon_extractor <- TaxonLHTCollector$new(self$master_db, ind_species)
taxon_extractor <- TaxonPredictedLHTGetter$new(self$master_db, ind_species)
taxon_details <- taxon_extractor$extract()
if (is.null(taxon_details)) {
stop(paste("Unable to find life history traits for taxa", ind_species))
Expand All @@ -106,7 +106,7 @@ UpdatedLHTGenerator <- R6::R6Class("UpdatedLHTGenerator", public = list(
taxon_details$estimated_lhts,
taxon_details$estimated_covariance,
species_local_lhts,
self$func_domains)
self$transform_function_list)
updated_lhts[[ind_species]] <- taxon_predictor$predict()
}
return(updated_lhts)
Expand Down
69 changes: 0 additions & 69 deletions man/TaxonLHTCollector.Rd

This file was deleted.

69 changes: 69 additions & 0 deletions man/TaxonPredictedLHTGetter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions man/UpdatedLHTGenerator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-taxon_lht_predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_that("Testing sample data is loaded properly", {


test_that("Predict LHT for a specific taxa", {
t_extractor <- TaxonLHTCollector$new(testing_db, "Trisopterus luscus")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "Trisopterus luscus")
t.luscus_details <- t_extractor$extract()
estimated_lhts <- t.luscus_details$estimated_lhts
estimated_covariance <- t.luscus_details$estimated_covariance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
test_that("Unable to find specific species", {
t_extractor <- TaxonLHTCollector$new(testing_db, "I do not exist as species")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "I do not exist as species")
species_details <- t_extractor$extract()
expect_equal(is.null(species_details), TRUE)
})

test_that("Specific species is found", {
t_extractor <- TaxonLHTCollector$new(testing_db, "Trisopterus luscus")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "Trisopterus luscus")
species_details <- t_extractor$extract()
expect_equal(is.null(species_details), FALSE)
})

test_that("Taxon is found and is different to species", {
t_extractor <- TaxonLHTCollector$new(testing_db, "Trisopterus")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "Trisopterus")
taxon_details <- t_extractor$extract()
t_extractor <- TaxonLHTCollector$new(testing_db, "Trisopterus luscus")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "Trisopterus luscus")
species_details <- t_extractor$extract()
expect_equal(is.null(taxon_details), FALSE)
expect_equal(is.null(species_details), FALSE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-taxon_update_extractor.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("Extraction and backtransformation of predicted LHT values", {

# (1) Fetch ...
t_extractor <- TaxonLHTCollector$new(testing_db, "Trisopterus luscus")
t_extractor <- TaxonPredictedLHTGetter$new(testing_db, "Trisopterus luscus")
t.luscus_details <- t_extractor$extract()

estimated_lhts <- t.luscus_details$estimated_lhts
Expand Down

0 comments on commit 32d1dd4

Please sign in to comment.