Closed wvictor14 closed 4 years ago
Thank you! Instead of merging this pull request, I'll "convert this pull request to a draft" until the worksheet is finished. I've never tried this draft feature before!
expect_sorted
function that checks if a vector is sorted, it's defined in-line (is there a way to reference line-numbers for .ipynb
files on github?). This seems to work but someone else should check..digest(dim(tibble))
instead of two calls on nrow
and ncol
separately. In retrospect maybe it would be better to be checking columns and rows separately because then the error returned will specify which (rows or cols) is incorrect...digest
ing and testing "bigger" components (e.g. ggplot_object$layers[[1]] %>% digest
for geom_point
specifications)), but there is probably a way to go into finer resolution... But I think this is fine? @vincenzocoia please check question 2.3, I had to modify the answer in order to run 2.4 (because it's dependent). But based on the instruction I am not sure what the answer is supposed to be. (Either instruction needs to be clarified or the answer is wrong, probably both).
Thank you for this! This is a big help. Because I'm late with the feedback, I just went ahead and made the changes -- so, there's nothing else to do for this worksheet. But I still tried to leave detailed comments -- please do read through this so that you can provide feedback for Worksheet 3. (By the way -- we decided in our previous meeting that the worksheet leader will be the second reader for the following week's worksheet -- hope this is OK with you!)
In general I used digest(dim(tibble)) instead of two calls on nrow and ncol separately. In retrospect maybe it would be better to be checking columns and rows separately because then the error returned will specify which (rows or cols) is incorrect...
I see what you mean -- although, the error messages tend to not be all that informative, anyways.
# Is this ok? expect_equal(sum(pull(answer1.6, body_mass_g) < 3600), 0)
Yes! This is a creative way to check that the dataset was filtered to smaller penguins.
I wrote this expect_sorted function that checks if a vector is sorted, it's defined in-line (is there a way to reference line-numbers for .ipynb files on github?). This seems to work but someone else should check..
Neat, you wrote your own function to add to testthat
! I would have just wrote expect_false(is.unsorted(answer1.9$year))
, or even something crude like expect_equal(range(answer1.9$year), answer1.9$year[1:nrow(answer1.9)])
.
I tried digging into ggplot2 objects to see if I can pull out components and check each individually. I've never looked into this before but they are filled with unfamiliar objects like "quosures"? Anyways, I ended up just digesting and testing "bigger" components (e.g. ggplot_object$layers[[1]] %>% digest for geom_point specifications)), but there is probably a way to go into finer resolution... But I think this is fine?
This actually didn't always give me a success when I ran the tests. I ended up finding a better way to do it (found it in the commit history of the DSCI 100 repo). Please take a look at some examples. Note that we don't always need to use the digest()
function -- only for things that give away the answer, not for things like checking that the alpha transparency == 0.8.
Here are some other comments:
answer1.0
" cat("success!")
at the end of each test chunk, just so that we can be perfectly clear to students when they get the correct answer.### END SOLUTION
tag -- like print(answer2.7)
. Then, there's no need for some cells afterwards that say "print the plot".
worksheet_02.ipynb
under/content/source/worksheet_02a
using the .Rmd file + jupytextThere are still many answers/tests to write.
I will check again tomorrow morning to make sure all the cells are correctly assigned