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

Bugfix 117 connor #218

Merged
merged 99 commits into from
Oct 18, 2019
Merged

Bugfix 117 connor #218

merged 99 commits into from
Oct 18, 2019

Conversation

cjb643
Copy link
Contributor

@cjb643 cjb643 commented Jul 24, 2018

closes #117 Documentation and citations have been added for all functions in SW_Flow_lib.c. Unit tests, have been added for the following functions in SW_Flow_lib.c;

infiltrate_water_high, infiltrate_water_low
petfunc
svapor
transp_weighted_avg
grass_EsT_partitioning, shrub_EsT_partitioning, tree_EsT_partitioning, forb_EsT_partitioning
pot_soil_evap
pot_soil_evap_bs
pot_transp
watrate
evap_litter_veg_surfaceWater
evap_fromSurface
remove_from_soil
hydraulic_redistribution

citations are found in SOILWAT2.bib.

Documentation was also added for all functions in SW_SoilWater.c #115

Unit tests added for the following functions; svapor, petfunc, transp_weighted_avg, EsT_partitioning, pot_soil_evap, pot_soil_evap_bs, pot_transp, watrate, evap_fromSurface, remove_from_soil, infiltrate_water_low.  infiltrate_water_low is lacking complete documentation.
Added unit tests for hydraulic_redistribution
Updated documentation and citations for SW_Flow_lib.c, SW_SoilWater.c, and SOILWAT2.bib
@cjb643 cjb643 requested a review from CaitlinA July 24, 2018 22:41
@CaitlinA
Copy link
Member

@cjb643

Your latest commit is failing to compile on all CIs with error message:

 SW_SoilWater.c: In function 'SW_SWCbulk2SWPmatric':
SW_SoilWater.c:973:1: warning: "/*" within comment [-Wcomment]
 /**
  
SW_SoilWater.c:985:4: error: unknown type name 'These'
    These are the values for each layer obtained via lyr[n]:
    ^~~~~
SW_SoilWater.c:985:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'the'
    These are the values for each layer obtained via lyr[n]:
              ^~~
SW_SoilWater.c:997:11: error: invalid suffix "cm" on integer constant
   1 bar = 1024cm water)
           ^~~~~~
SW_SoilWater.c:1014:24: error: 'lyr' undeclared (first use in this function)
    theta1 = (swcBulk / lyr->width) * 100. / (1. - fractionGravel);
                        ^~~
SW_SoilWater.c:1014:24: note: each undeclared identifier is reported only once for each function it appears in
make: *** [makefile:137: libSOILWAT2.a] Error 1

Please don't push code with compilation errors up onto github

Copy link
Member

@CaitlinA CaitlinA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some simple recommendations. Please change throughout and also fix your failing tests on the CI. Then I will review again.

SW_Flow_lib.c Outdated

Equations based on Corbett and Crouse 1968. @cite Corbett1968

@param *pptleft Remaining precipitation, (cm/day).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix tabs in the sections so they are aligned in the correct spot.

Also no comma is need before units i.e. Remaining precipitation (cm/day)

SW_Flow_lib.c Outdated
@brief Infiltrate water into soil layers under high water conditions, otherwise
known as saturated percolation.

@param swc Displays soilwater content in each layer before drainage, (cm^3 H2O).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doublecheck: Do these superscripts come up as squared and cubed in the .html version?

SW_Flow_lib.c Outdated

Equations based on Penman 1948. @cite Penman1948
Equations based on ASCE 2000. @cite ASCE2000
Equations based on Bowen 1926. @cite Bowen1926
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list of equations could be written as

Equations based on Penman 1948 @cite Penman 1948, ASCE 2000 .....,

SW_Flow_lib.c Outdated
@param cor[MAX_ST_RGR][MAX_LAYERS + 1] Two dimensional array containing soiltemperature data.
@param nlyrTemp The number of soil temperature layers.
@param depth_Temp Depths of soil temperature layers (cm).
@param sTempR Temperature values of soil temperature layers (C).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can add a degree sign, or notation so that a degree sign appears on .html

SW_Flow_lib.c Outdated Show resolved Hide resolved
SW_Flow_lib.c Outdated Show resolved Hide resolved
SW_SoilWater.c Outdated
The equation and its coefficients are based on a
paper by Cosby,Hornberger,Clapp,Ginn, in WATER RESOURCES RESEARCH
June 1984. Moisture retention data was fit to the power function.
Equations are based on a paper by Cosby,Hornberger,Clapp,Ginn. @cite Cosby1984
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces between commas

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep note about moisture retention data being fit to the power function

EXPECT_DOUBLE_EQ(swc5[i], swcsat5[i]); // test that swc is now equal to or below swcsat in all layers but the top
swc5[i] = (int)(swc5[i] * 10000000 + 0.5)/ 10000000; // need to round for unit test, despite using EXPECT_DOUBLE_EQ
swcsat5[i] = (int)(swcsat5[i] * 10000000 + 0.5)/ 10000000; // need to round for unit test, despite using EXPECT_DOUBLE_EQ
EXPECT_DOUBLE_EQ(swc5[i], swcsat5[i]); // test that swc is now equal to or below swcsat in all layers but the top
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of rounding and then using EXPECT_DOUBLE_EQ what if we use EXPECT_NEAR instead. You test two numbers within a 'tolerance'. There is an example of its use in test_SW_SoilWater.cc

double expReturnTemp[] = {0.201, 0.245, 0.299, 0.364, 0.443, 0.539, 0.653, 0.788,
0.948, 1.137, 0.136, 0.01, 0.032, 0.057, 0.060}; // These are the expected outcomes for the variable arads.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of empty space (one space/enter is typically fine for a break)

hydraulic_redistribution(swc1, swcwp1, lyrRootCo1, hydred1, nlyrs, maxCondroot, swp50, shapeCond, scale);

EXPECT_DOUBLE_EQ(hydred[0], 0); //no hydred in top layer
for(unsigned int i = 0; i < nlyrs; i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add spacing

Updated documentaion for SW_Flow_lib.c and W_SoilWater.c, changed unit test for infiltrate_water_high function from EXPECT_DOUBLE_EQ to EXPECT_NEAR
@codecov
Copy link

codecov bot commented Jul 31, 2018

Codecov Report

Merging #218 into master will increase coverage by 1.3%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #218     +/-   ##
=========================================
+ Coverage   64.94%   66.25%   +1.3%     
=========================================
  Files          19       20      +1     
  Lines        3569     3621     +52     
=========================================
+ Hits         2318     2399     +81     
+ Misses       1251     1222     -29
Impacted Files Coverage Δ
generic.c 16.36% <ø> (ø) ⬆️
SW_Flow.c 81.74% <ø> (ø) ⬆️
SW_Site.c 69.44% <ø> (+12.39%) ⬆️
SW_Carbon.c 77.02% <ø> (ø) ⬆️
Times.c 45.32% <ø> (ø) ⬆️
SW_Control.c 97.72% <ø> (ø) ⬆️
SW_VegProd.c 69.72% <ø> (ø) ⬆️
SW_SoilWater.c 58.11% <100%> (+1.12%) ⬆️
SW_Flow_lib.c 87.77% <100%> (+2.42%) ⬆️
rands.c 63.49% <100%> (-1.59%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b30031...5c4a1d2. Read the comment docs.

Updated failing tests that were affected by if (st->lyrFrozen[i]) statements
Copy link
Member

@CaitlinA CaitlinA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Mostly you need to change formatting issues in the test file itself (tabs, spacing), and then I will pass it along to Daniel for review. I pointed out some examples of what I wanted changed.

Thanks,
Caitlin

test/test_SW_Flow_Lib.cc Show resolved Hide resolved
EXPECT_DOUBLE_EQ(test, expReturnSlope[i]); //Tests the return of the petfunc against the expected return for the petfunc.

slope += 4.3; //Incrments slope input variable.
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misaligned tab (just an example, fix through out)

test/test_SW_Flow_Lib.cc Outdated Show resolved Hide resolved
unknown and others added 2 commits August 6, 2018 16:51
Replaced all instances of EXPECT_DOUBLE_EQ combined with rounding with EXPECT_NEAR
@CaitlinA
Copy link
Member

Your PR is failing on some of your new tests. Please fix.

Fixed failing tests dealing with st->lyrFrozen[i]
Fixed remaining failing tests at line 940.
@CaitlinA
Copy link
Member

@cjb643 You are still failing your unit-test specific failures - Please fix ASAP so we can wrap this up.

cjb643 and others added 7 commits August 20, 2018 10:45
Changes made to tests affected by if (st->lyrFrozen[i]) causing them to fail
Simplified a failing group of tests due to st->yrFrozen[i]  receiving a load of value 1372188672, which is not a valid value for type 'Bool'
Changed EXPECT_LT(sTemp3[k], 100); to EXPECT_LT(sTemp3[k], 1000); at ln 569.
Added multiple resets.  Undid change to line 569 of test_SW_Flow_lib_temp.cc
CaitlinA
CaitlinA previously approved these changes Aug 21, 2018
@CaitlinA CaitlinA requested a review from dschlaep August 21, 2018 15:52
- addressing #89 (Re-organize repository with more sub-folders)
…eptions)

- fix #266 (comment)
- addressing #266

- new script `tools/run_doxygen.sh`
- new make targets: "doc" and "doc_clean"

- continuous integration: travis-ci will now use the new script which fails on warnings, but disregards exceptions that are documented in the new file `doc/doxygen_exceptions.txt`

- currently, there is one known exception, see #267

- moved `Doxyfile` to `doc/` (addressing #89)
This works well locally, but travis-ci fails with
```
# Examine log file for remaining warnings/errors
warnings=$(grep "warning\|error" ${log})
grep "warning\|error" ${log}
makefile:260: recipe for target 'doc' failed
make: *** [doc] Error 1
The command "make doc" exited with 2.
```

It is not clear to me why `grep "warning\|error" ${log}` would exit with code 2. As an attempt, I catch grep's stderr and assign it to `warnings` as well.
It is also not clear whether or not travis-ci expects that this script (called by `make doc`) should define an exit value if we got warnings (see https://docs.travis-ci.com/user/job-lifecycle#how-does-this-work-or-why-you-should-not-use-exit-in-build-steps).
- previous commit 6f6a058 didn't work

- maybe travis-ci prefers extended (instead of basic) regular expressions? --> add `-E` option

- for goodness sake, we now search for case insensitive warnings/errors -> option `-i`
- previous commit 6f6a058 didn't work

- after installing and running travis locally, it seems that `grep` returns a non-zero exit status if nothing matches (i.e., we want nothing to match!)
--> use grep ... || echo "" instead
- this commit uses a wrong filename for doxygen exceptions, i.e., the `make doc` should fail on travis-ci because it will find doxygen warnings

- if indeed, travis-ci fails with this commit, then our continuous integration checks pass both positive and negative cases correctly
- commit 952e100 tested if travis-ci checks fail if `make doc` finds warnings:
it did find warnings and printed them to the output; however, it did not fail

--> add non-zero `exit` code to script if there are warnings
- link to latest doi release on zenodo
- remove github downloads (since it wasn't doing what we wanted it for)
- rename "Unix" badge to more appropriately "*nix"
- addressing #74 (Include detailed user manual in doxygen documentation)
- close #75 (Include detailed installation instructions in doxygen documentation)

- subpages for inputs and outputs are currently only place holders
- function `create_test_soillayers` can now use the fully fledged function `set_soillayers` (from commit "Merge branch 'feature_soillayerswap' into Bugfix_117_Connor") -- instead of the unit-test local and feature-incomplete `_set_layers`

- small fix to README concerning installation of clang via macports
@dschlaep dschlaep mentioned this pull request Aug 30, 2019
- include input files verbatim
- this requires that the `doxyfile` "EXAMPLE_PATH" is set correctly
@codecov
Copy link

codecov bot commented Sep 5, 2019

Codecov Report

Merging #218 into master will increase coverage by 1.44%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #218      +/-   ##
=========================================
+ Coverage   64.86%   66.3%   +1.44%     
=========================================
  Files          19      20       +1     
  Lines        3569    3621      +52     
=========================================
+ Hits         2315    2401      +86     
+ Misses       1254    1220      -34
Impacted Files Coverage Δ
generic.c 16.36% <ø> (ø) ⬆️
SW_Flow.c 81.74% <ø> (ø) ⬆️
SW_VegEstab.c 15.07% <ø> (ø) ⬆️
SW_Main_lib.c 0% <ø> (ø)
SW_Carbon.c 77.02% <ø> (ø) ⬆️
SW_Files.c 80.95% <ø> (ø) ⬆️
SW_Control.c 97.72% <ø> (ø) ⬆️
SW_Sky.c 89.74% <ø> (ø) ⬆️
SW_Output_mock.c 9.73% <ø> (ø) ⬆️
SW_VegProd.c 69.72% <ø> (ø) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f0a9b5...9321af3. Read the comment docs.

- clarified/expanded comments in input files for stand-alone use and for SOILWAT2 user manual
- added notes for users to highlight dependencies and forcing inputs vs. parameters
- improve clarity of user manual
- add output section
- general updates
- added instructions on a minimal latex installation with tinytex
5df18a0 [5df18a0]
Parents:
e4daa32
Author:
Unknown <cjb643@nau.edu>
Date:
August 21, 2018 at 4:33:36 PM EDT
Labels:
origin/Bugfix_216_unitTests

- added basic doxygen documentation for several functions
@dschlaep dschlaep merged commit acce170 into master Oct 18, 2019
@dschlaep dschlaep deleted the Bugfix_117_Connor branch October 18, 2019 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for SW_Flow_lib.c
3 participants