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

removeBrokenSpeciesListLinks filter not working properly #59

Open
nmprista opened this issue Oct 12, 2022 · 4 comments
Open

removeBrokenSpeciesListLinks filter not working properly #59

nmprista opened this issue Oct 12, 2022 · 4 comments
Assignees
Labels
2_preparation Generating probabilities and Zero's, subsetting species 9_needs_more_tests Please add more tests

Comments

@nmprista
Copy link
Contributor

removeBrokenSpeciesListLinks is filtering only on SLspeciesListName. Needs to filter based on SLyear, SLcatchFraction and SLcountry.

@nmprista nmprista added the 2_preparation Generating probabilities and Zero's, subsetting species label Oct 12, 2022
@nmprista nmprista changed the title removeBrokenSpeciesListLinks removeBrokenSpeciesListLinks filter not working properly Oct 12, 2022
@nicholascarey nicholascarey self-assigned this Oct 13, 2022
@davidcurrie2001
Copy link
Contributor

I will create an example

@davidcurrie2001 davidcurrie2001 self-assigned this Oct 13, 2022
@davidcurrie2001
Copy link
Contributor

library(icesRDBES)

# Get some test data - if you get errors or an emptry object check your wd
myLohr <- importRDBESDownloadData('data-raw/WGRDBES-EST_TEST_LOHR_eg_3_2_3_6.zip')

# Test 1) removeBrokenSpeciesListLinks() works ok - it doesn't remove any SS rows  valid data

# Check number of SS rows before removing broken species list links (300)
nrow(myLohr[["SS"]])
# Try removing any broken links
test1 <- removeBrokenSpeciesListLinks(myLohr)
# Check number of SS rows after removing broken species list links - no broken links so shoudl be the same (300)
nrow(test1[["SS"]])


# Test 2) removeBrokenSpeciesListLinks() works ok.  Let's try removing all species lists from SL and check all SS rows are removed.
test2 <- filterRDBESDataObject(myLohr,c("SLspeclistName"),c("xxx"))

# Check number of SS rows before removing broken species list links (300)
nrow(test2[["SS"]])
# Try removing any broken links
test3 <- removeBrokenSpeciesListLinks(test2)
# Check number of SS rows after removing broken species list links - we've removed all SL rows so all SS entries shoudl be broken - number of SS rows shoudl now be zero - it is :-)
nrow(test3[["SS"]])


# Test 3) removeBrokenSpeciesListLinks() does not work correctly.  Change all SL entries to relate to "Dis" rather than "Lan" - the current removeBrokenSpeciesListLinks() function thinks everything is ok so doesn't remove any SS rows - however the correct behaviour should be to remove all SS rows
test4 <- myLohr
test4[["SL"]]$SLcatchFrac <- "Dis"
# Note that all SS rows are Lan but all SL rows are Dis - we now have a mis-match between SL and SS
unique(test4[["SS"]]$SScatchFra)
unique(test4[["SL"]]$SLcatchFrac)

# Check number of SS rows before removing broken species list links (300)
nrow(test4[["SS"]])
# Try removing any broken links
test5 <- removeBrokenSpeciesListLinks(test4)
# Check number of SS rows after removing broken species list links - we shoudl have zero rows because we don't have an SL entry that matches on Species List Name, catch fraction, country, and year - however we still have 300 rows :-(
nrow(test5[["SS"]])


@davidcurrie2001 davidcurrie2001 removed their assignment Oct 13, 2022
@nicholascarey
Copy link
Contributor

Revised and should be working now but needs tested.

@nmprista nmprista added the 10_priority Chairs-label - priority issue (work on these when you can) label Oct 22, 2023
@rix133 rix133 added the 9_needs_more_tests Please add more tests label Nov 3, 2023
@nmprista nmprista removed the 10_priority Chairs-label - priority issue (work on these when you can) label Nov 17, 2023
@rix133
Copy link
Contributor

rix133 commented Oct 14, 2024

test-removeBrokenSpeciesListLinks needs the 4 use cases see above implemented as tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2_preparation Generating probabilities and Zero's, subsetting species 9_needs_more_tests Please add more tests
Projects
None yet
Development

No branches or pull requests

4 participants