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

better test for monotonically increasing/decreasing #96

Open
jordansread opened this issue Aug 7, 2018 · 1 comment
Open

better test for monotonically increasing/decreasing #96

jordansread opened this issue Aug 7, 2018 · 1 comment

Comments

@jordansread
Copy link
Member

for

if (depths[2] - depths[1] < 0 ){stop('depths must be in descending order')}
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
Copy link
Member

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?

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

No branches or pull requests

2 participants