Skip to content

Test suite error? #16

Description

@MansMeg

This should probably not give an warning and this should be fixed in the test suite instead?.

Hi Mans,
So the problem was noticed by the students in lab2 with the function
while_mult_table()

Example code:
while_mult_table <- function(from, to) {
i <- 0
vect <- from:to
temp <- c()
range <- length(vect)
while (i < range) {
i <- i + 1
start_pos <- range * (i - 1) + 1
end_pos <- range * i
temp[start_pos:end_pos] <-
vect * sort(vect[i], decreasing = FALSE)
}
mat_final <- matrix(temp, nrow = range, ncol = range)
colnames(mat_final) <- sort(vect, decreasing = FALSE)
rownames(mat_final) <- sort(vect, decreasing = FALSE)
return(mat_final)
}
When I run mark_my_assignment on this I get the warnings:
Warnings

  1. Assignment: while_mult_table() (@test-while_mult_table-1.R#39) -
    numerical expression has 3 elements: only the first used
  2. Assignment: while_mult_table() (@test-while_mult_table-1.R#39) - NAs
    introduced by coercion
    Failed

as it should. Students who installed the latest version (next to me by
install.packages(), so I guess from CRAN) do not observe this warning at
all.

What is also interesting is that if from:to is replaced by seq(from,to)
then students' code throws an error that markmyassignment correctly
considers as an error thrown (but I do not know if there is any way of
automatically making sure input is checked)?

Cheers
Krzysztof

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions