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

Expect shape #1469

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Expect shape #1469

wants to merge 5 commits into from

Conversation

MichaelChirico
Copy link
Contributor

@MichaelChirico MichaelChirico commented Oct 4, 2021

Closes #1423

Implementation as of now has a few design choices, happy to adapt as seen fit:

  • Added the function to R/expect-length.R since it fits so nicely alongside expect_length(), but gave it its own test file.
  • Subsumes expect_length(), i.e., expect_shape(x, n) matches expect_length(x, n). Makes it easier for a series of tests to all use expect_shape(), instead of jumping between expect_length() and expect_shape() from test to test
  • Allows expect_shape(., nrow=m, ncol=n), which is usually the same as expect_shape(., c(m, n)), expect when length(dim(.)) > 2, a rather boutique use case of wanting to test only the first 2 dimensions of an array.

@@ -0,0 +1,46 @@
test_that("shape computed correctly", {
Copy link
Member

Choose a reason for hiding this comment

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

By convention, we now match tests/testthat/test-abc.R to R/abc.R.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good... would you prefer expect_shape in its own file, or these tests moved over to test-expect-length?

R/expect-length.R Outdated Show resolved Hide resolved
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.

Proposed expectations: expect_nrow(), expect_ncol(), expect_dim()
2 participants