ncss-tech / soilDB

soilDB: Simplified Access to National Cooperative Soil Survey Databases
http://ncss-tech.github.io/soilDB/
GNU General Public License v3.0
81 stars 20 forks source link

CRAN failures related to `fetchHenry()` and `waterDayYear()` #333

Closed brownag closed 9 months ago

brownag commented 9 months ago

fetchHenry() and waterDayYear() are failing tests due to slight offsets in the expected values. I will need to resubmit the package within two weeks, so unless there is an obvious fix I will likely skip these tests on CRAN going forward to prevent minor issues like this causing problems for the package as a whole.

Possibly related prior issues:

Version: 2.8.0
Check: tests
Result: ERROR 
    Running ‘testthat.R’ [17s/26s]
  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > library(soilDB)
    > 
    > test_check("soilDB")
    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]

    ══ Skipped tests (83) ══════════════════════════════════════════════════════════
    • On CRAN (76): 'test-ISSR800.R:5:3', 'test-ISSR800.R:42:3',
      'test-OSDquery.R:5:3', 'test-OSDquery.R:30:3', 'test-ROSETTA.R:42:3',
      'test-ROSETTA.R:65:3', 'test-ROSETTA.R:88:3', 'test-SDA_query.R:6:3',
      'test-SDA_query.R:42:3', 'test-SDA_query.R:68:3', 'test-SDA_query.R:88:3',
      'test-SDA_query.R:120:3', 'test-SDA_query.R:158:3', 'test-SDA_query.R:180:3',
      'test-SDA_query.R:198:3', 'test-SDA_query.R:219:3',
      'test-SoilDataViewer.R:2:3', 'test-fetchEDIT_tools.R:37:3',
      'test-fetchKSSL.R:5:3', 'test-fetchKSSL.R:24:3', 'test-fetchKSSL.R:57:3',
      'test-fetchKSSL.R:75:3', 'test-fetchKSSL.R:92:3', 'test-fetchKSSL.R:107:3',
      'test-fetchKSSL.R:121:3', 'test-fetchKSSL.R:155:3', 'test-fetchLDM.R:3:3',
      'test-fetchNASIS.R:103:3', 'test-fetchNASISWebReport.R:6:3',
      'test-fetchNASISWebReport.R:27:3', 'test-fetchNASISWebReport.R:44:3',
      'test-fetchNASISWebReport.R:63:3', 'test-fetchNASISWebReport.R:80:3',
      'test-fetchOSD.R:9:3', 'test-fetchOSD.R:32:3', 'test-fetchOSD.R:46:3',
      'test-fetchOSD.R:63:3', 'test-fetchOSD.R:81:3', 'test-fetchOSD.R:98:3',
      'test-fetchSCAN.R:7:3', 'test-fetchSCAN.R:27:3',
      'test-fetchSDA_component.R:8:3', 'test-fetchSDA_component.R:23:3',
      'test-fetchSDA_component.R:35:3', 'test-fetchSDA_component.R:53:3',
      'test-fetchSDA_spatial.R:5:3', 'test-fetchSDA_spatial.R:32:3',
      'test-fetchSRI.R:3:3', 'test-fetchSRI.R:29:3', 'test-fetchSoilGrids.R:5:3',
      'test-get_OSD.R:7:3', 'test-get_OSD.R:33:3', 'test-get_SDA_coecoclass.R:2:3',
      'test-get_SDA_cosurfmorph.R:3:3', 'test-get_SDA_hydric.R:3:3',
      'test-get_SDA_interpretation.R:8:3', 'test-get_SDA_interpretation.R:23:3',
      'test-get_SDA_interpretation.R:41:3', 'test-get_SDA_interpretation.R:59:3',
      'test-get_SDA_muaggatt.R:2:3', 'test-get_SDA_pmgroupname.R:2:3',
      'test-get_SDA_property.R:16:3', 'test-get_SDA_property.R:42:3',
      'test-get_SDA_property.R:59:3', 'test-get_SDA_property.R:97:3',
      'test-get_SDA_property.R:223:3', 'test-get_SDA_property.R:261:3',
      'test-get_SSURGO_utils.R:2:3', 'test-mukey-WCS.R:6:3',
      'test-seriesExtent.R:3:3', 'test-siblings.R:6:3', 'test-siblings.R:29:3',
      'test-siblings.R:43:3', 'test-soilDBdata.R:3:3', 'test-waterDayYear.R:75:3',
      'test-waterDayYear.R:91:3'
    • local NASIS database not available (7): 'test-dbQueryNASIS.R:6:5',
      'test-fetchNASIS.R:51:5', 'test-fetchNASIS.R:85:5',
      'test-fetchNASIS.R:127:5', 'test-fetchNASIS.R:134:5',
      'test-fetchNASIS.R:141:5', 'test-fetchNASISLabData.R:27:5'

    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure ('test-fetchHenry.R:142:3'): summarizeSoilTemperature() works as expected ──
    res$Winter not equal to 6.16.
    1/1 mismatches
    [1] 6.12 - 6.16 == -0.04
    ── Failure ('test-fetchHenry.R:144:3'): summarizeSoilTemperature() works as expected ──
    res$Summer not equal to 16.92.
    1/1 mismatches
    [1] 17 - 16.9 == 0.06
    ── Failure ('test-waterDayYear.R:24:3'): works as expected ─────────────────────
    res$wy not equal to 2019.
    1/1 mismatches
    [1] 2018 - 2019 == -1
    ── Failure ('test-waterDayYear.R:25:3'): works as expected ─────────────────────
    res$wd not equal to 1.
    1/1 mismatches
    [1] 366 - 1 == 365

    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]
    Error: Test failures
    Execution halted
Flavor: [r-devel-linux-x86_64-debian-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/soilDB-00check.html)

Version: 2.8.0
Check: tests
Result: ERROR 
    Running ‘testthat.R’ [23s/22s]
  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > library(soilDB)
    > 
    > test_check("soilDB")
    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]

    ══ Skipped tests (83) ══════════════════════════════════════════════════════════
    • On CRAN (76): 'test-ISSR800.R:5:3', 'test-ISSR800.R:42:3',
      'test-OSDquery.R:5:3', 'test-OSDquery.R:30:3', 'test-ROSETTA.R:42:3',
      'test-ROSETTA.R:65:3', 'test-ROSETTA.R:88:3', 'test-SDA_query.R:6:3',
      'test-SDA_query.R:42:3', 'test-SDA_query.R:68:3', 'test-SDA_query.R:88:3',
      'test-SDA_query.R:120:3', 'test-SDA_query.R:158:3', 'test-SDA_query.R:180:3',
      'test-SDA_query.R:198:3', 'test-SDA_query.R:219:3',
      'test-SoilDataViewer.R:2:3', 'test-fetchEDIT_tools.R:37:3',
      'test-fetchKSSL.R:5:3', 'test-fetchKSSL.R:24:3', 'test-fetchKSSL.R:57:3',
      'test-fetchKSSL.R:75:3', 'test-fetchKSSL.R:92:3', 'test-fetchKSSL.R:107:3',
      'test-fetchKSSL.R:121:3', 'test-fetchKSSL.R:155:3', 'test-fetchLDM.R:3:3',
      'test-fetchNASIS.R:103:3', 'test-fetchNASISWebReport.R:6:3',
      'test-fetchNASISWebReport.R:27:3', 'test-fetchNASISWebReport.R:44:3',
      'test-fetchNASISWebReport.R:63:3', 'test-fetchNASISWebReport.R:80:3',
      'test-fetchOSD.R:9:3', 'test-fetchOSD.R:32:3', 'test-fetchOSD.R:46:3',
      'test-fetchOSD.R:63:3', 'test-fetchOSD.R:81:3', 'test-fetchOSD.R:98:3',
      'test-fetchSCAN.R:7:3', 'test-fetchSCAN.R:27:3',
      'test-fetchSDA_component.R:8:3', 'test-fetchSDA_component.R:23:3',
      'test-fetchSDA_component.R:35:3', 'test-fetchSDA_component.R:53:3',
      'test-fetchSDA_spatial.R:5:3', 'test-fetchSDA_spatial.R:32:3',
      'test-fetchSRI.R:3:3', 'test-fetchSRI.R:29:3', 'test-fetchSoilGrids.R:5:3',
      'test-get_OSD.R:7:3', 'test-get_OSD.R:33:3', 'test-get_SDA_coecoclass.R:2:3',
      'test-get_SDA_cosurfmorph.R:3:3', 'test-get_SDA_hydric.R:3:3',
      'test-get_SDA_interpretation.R:8:3', 'test-get_SDA_interpretation.R:23:3',
      'test-get_SDA_interpretation.R:41:3', 'test-get_SDA_interpretation.R:59:3',
      'test-get_SDA_muaggatt.R:2:3', 'test-get_SDA_pmgroupname.R:2:3',
      'test-get_SDA_property.R:16:3', 'test-get_SDA_property.R:42:3',
      'test-get_SDA_property.R:59:3', 'test-get_SDA_property.R:97:3',
      'test-get_SDA_property.R:223:3', 'test-get_SDA_property.R:261:3',
      'test-get_SSURGO_utils.R:2:3', 'test-mukey-WCS.R:6:3',
      'test-seriesExtent.R:3:3', 'test-siblings.R:6:3', 'test-siblings.R:29:3',
      'test-siblings.R:43:3', 'test-soilDBdata.R:3:3', 'test-waterDayYear.R:75:3',
      'test-waterDayYear.R:91:3'
    • local NASIS database not available (7): 'test-dbQueryNASIS.R:6:5',
      'test-fetchNASIS.R:51:5', 'test-fetchNASIS.R:85:5',
      'test-fetchNASIS.R:127:5', 'test-fetchNASIS.R:134:5',
      'test-fetchNASIS.R:141:5', 'test-fetchNASISLabData.R:27:5'

    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure ('test-fetchHenry.R:142:3'): summarizeSoilTemperature() works as expected ──
    res$Winter not equal to 6.16.
    1/1 mismatches
    [1] 6.12 - 6.16 == -0.04
    ── Failure ('test-fetchHenry.R:144:3'): summarizeSoilTemperature() works as expected ──
    res$Summer not equal to 16.92.
    1/1 mismatches
    [1] 17 - 16.9 == 0.06
    ── Failure ('test-waterDayYear.R:24:3'): works as expected ─────────────────────
    res$wy not equal to 2019.
    1/1 mismatches
    [1] 2018 - 2019 == -1
    ── Failure ('test-waterDayYear.R:25:3'): works as expected ─────────────────────
    res$wd not equal to 1.
    1/1 mismatches
    [1] 366 - 1 == 365

    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]
    Error: Test failures
    Execution halted
Flavor: [r-devel-linux-x86_64-fedora-clang](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-clang/soilDB-00check.html)

Version: 2.8.0
Check: tests
Result: ERROR 
    Running ‘testthat.R’ [37s/38s]
  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > library(soilDB)
    > 
    > test_check("soilDB")
    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]

    ══ Skipped tests (83) ══════════════════════════════════════════════════════════
    • On CRAN (76): 'test-ISSR800.R:5:3', 'test-ISSR800.R:42:3',
      'test-OSDquery.R:5:3', 'test-OSDquery.R:30:3', 'test-ROSETTA.R:42:3',
      'test-ROSETTA.R:65:3', 'test-ROSETTA.R:88:3', 'test-SDA_query.R:6:3',
      'test-SDA_query.R:42:3', 'test-SDA_query.R:68:3', 'test-SDA_query.R:88:3',
      'test-SDA_query.R:120:3', 'test-SDA_query.R:158:3', 'test-SDA_query.R:180:3',
      'test-SDA_query.R:198:3', 'test-SDA_query.R:219:3',
      'test-SoilDataViewer.R:2:3', 'test-fetchEDIT_tools.R:37:3',
      'test-fetchKSSL.R:5:3', 'test-fetchKSSL.R:24:3', 'test-fetchKSSL.R:57:3',
      'test-fetchKSSL.R:75:3', 'test-fetchKSSL.R:92:3', 'test-fetchKSSL.R:107:3',
      'test-fetchKSSL.R:121:3', 'test-fetchKSSL.R:155:3', 'test-fetchLDM.R:3:3',
      'test-fetchNASIS.R:103:3', 'test-fetchNASISWebReport.R:6:3',
      'test-fetchNASISWebReport.R:27:3', 'test-fetchNASISWebReport.R:44:3',
      'test-fetchNASISWebReport.R:63:3', 'test-fetchNASISWebReport.R:80:3',
      'test-fetchOSD.R:9:3', 'test-fetchOSD.R:32:3', 'test-fetchOSD.R:46:3',
      'test-fetchOSD.R:63:3', 'test-fetchOSD.R:81:3', 'test-fetchOSD.R:98:3',
      'test-fetchSCAN.R:7:3', 'test-fetchSCAN.R:27:3',
      'test-fetchSDA_component.R:8:3', 'test-fetchSDA_component.R:23:3',
      'test-fetchSDA_component.R:35:3', 'test-fetchSDA_component.R:53:3',
      'test-fetchSDA_spatial.R:5:3', 'test-fetchSDA_spatial.R:32:3',
      'test-fetchSRI.R:3:3', 'test-fetchSRI.R:29:3', 'test-fetchSoilGrids.R:5:3',
      'test-get_OSD.R:7:3', 'test-get_OSD.R:33:3', 'test-get_SDA_coecoclass.R:2:3',
      'test-get_SDA_cosurfmorph.R:3:3', 'test-get_SDA_hydric.R:3:3',
      'test-get_SDA_interpretation.R:8:3', 'test-get_SDA_interpretation.R:23:3',
      'test-get_SDA_interpretation.R:41:3', 'test-get_SDA_interpretation.R:59:3',
      'test-get_SDA_muaggatt.R:2:3', 'test-get_SDA_pmgroupname.R:2:3',
      'test-get_SDA_property.R:16:3', 'test-get_SDA_property.R:42:3',
      'test-get_SDA_property.R:59:3', 'test-get_SDA_property.R:97:3',
      'test-get_SDA_property.R:223:3', 'test-get_SDA_property.R:261:3',
      'test-get_SSURGO_utils.R:2:3', 'test-mukey-WCS.R:6:3',
      'test-seriesExtent.R:3:3', 'test-siblings.R:6:3', 'test-siblings.R:29:3',
      'test-siblings.R:43:3', 'test-soilDBdata.R:3:3', 'test-waterDayYear.R:75:3',
      'test-waterDayYear.R:91:3'
    • local NASIS database not available (7): 'test-dbQueryNASIS.R:6:5',
      'test-fetchNASIS.R:51:5', 'test-fetchNASIS.R:85:5',
      'test-fetchNASIS.R:127:5', 'test-fetchNASIS.R:134:5',
      'test-fetchNASIS.R:141:5', 'test-fetchNASISLabData.R:27:5'

    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure ('test-fetchHenry.R:142:3'): summarizeSoilTemperature() works as expected ──
    res$Winter not equal to 6.16.
    1/1 mismatches
    [1] 6.12 - 6.16 == -0.04
    ── Failure ('test-fetchHenry.R:144:3'): summarizeSoilTemperature() works as expected ──
    res$Summer not equal to 16.92.
    1/1 mismatches
    [1] 17 - 16.9 == 0.06
    ── Failure ('test-waterDayYear.R:24:3'): works as expected ─────────────────────
    res$wy not equal to 2019.
    1/1 mismatches
    [1] 2018 - 2019 == -1
    ── Failure ('test-waterDayYear.R:25:3'): works as expected ─────────────────────
    res$wd not equal to 1.
    1/1 mismatches
    [1] 366 - 1 == 365

    [ FAIL 4 | WARN 0 | SKIP 83 | PASS 216 ]
    Error: Test failures
    Execution halted
Flavor: [r-devel-linux-x86_64-fedora-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/soilDB-00check.html)
brownag commented 9 months ago

Turns out it was a fairly simple fix. The same type of problem in both functions: creating dates in the current year rather than in the target year sometimes leads to offsets in julian days due to leap years. This error cropped up right on 2024-01-01.

This means that the values returned by summarizeSoilTemperature() have been, up until this point, slightly dependent on the year in which they are calculated (regardless of the input data). Now the year is derived from the input data, so it should be stable across years. Tthe expected values for winter and summer temperature have been updated (change in the hundreths place) and tolerance added. The tests are all now skipped on CRAN.

dylanbeaudette commented 9 months ago

Nice catch! Thanks for fixing this.