Checking functions list/API
Opened this issue · 0 comments
nischalshrestha commented
Description
Problem: We have to result check a TON of things and we need some sorta API/pattern to do checks.
Working solution: We write low-level getters/checkers that help get/check different aspects of Python types, and high-level checkers that might compose the low-level ones to do one larger check.
Here's a basic API:
Tables
- DataFrame
py_check_dataframe()
- tests
- Series
py_check_series()
- tests
- index,
py_check_index()
(Index/MultiIndex/<>Index
)- tests
- columns
py_check_columns()
(consists ofindex
)- tests
- values
py_check_values()
- tests
(add more as needed)
How the -check
chunk currently looks like:
# simplest is to use grading functions that directly provide default feedback
```{r, py-ex-check}
gradethis::grade_this({
# one grading function that returns fail() if any of these fail() in order:
# - py_grade_index()
# - py_grade_columns()
# - py_grade_values()
py_grade_dataframe()
pass("Hooray! You got the DataFrame.")
})
```
# however, you can do lower level checks
```{r, py-ex-check}
gradethis::grade_this({
# check index
index_problem <- py_check_index()
if (!is.null(index_problem)) {
fail("Wrong index!")
}
# check columns
column_problem <- py_check_index()
if (!is.null(column_problem)) {
fail("Wrong columns!")
}
# check values
values_problem <- py_check_values()
if (!is.null(values_problem)) {
fail("Wrong values!")
}
# check dataframe
dataframe_problem <- py_check_dataframe()
if (!is.null(dataframe_problem)) {
fail("Wrong dataframe!")
}
pass("Hooray! You got the DataFrame.")
})
```
Grading functions:
- DataFrame
py_grade_dataframe()
- tests
- Series
py_grade_series()
- tests
- index,
py_grade_index()
(Index/MultiIndex/<>Index
)- tests
- columns
py_grade_columns()
(consists ofindex
)- tests
- values
py_grade_values()
- tests