GLEON / rLakeAnalyzer

An R version of Lake Analyzer
43 stars 26 forks source link

better test for monotonically increasing/decreasing #96

Open jordansread opened 6 years ago

jordansread commented 6 years ago

for https://github.com/GLEON/rLakeAnalyzer/blob/2253bd90f109d9cebf6a5e63fb756a6a474cbc14/R/center.buoyancy.R#L32 we only test the top two depths, then ignore anything below but have an assumption that depths aren't scrambled below the top two.

So this will make it through the test:

depths = c(0, 0.5, 1, 9.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
         17, 18, 19, 20)

we can use

all(depths == cummax(depths))

to test for this if we need depths to be monotonically increasing (or cummin(depths) for decreasing)

lawinslow commented 6 years ago

Weird, that isn't a very useful check.

Alternative to all(depths == cummax(depths)), could use is.unsorted to check. Big question here really is do we want to sort it for the user, or just throw an error?