Skip to content

Expose unhelpful error#104

Open
richelbilderbeek wants to merge 9 commits intoGiappo:developfrom
richelbilderbeek:master
Open

Expose unhelpful error#104
richelbilderbeek wants to merge 9 commits intoGiappo:developfrom
richelbilderbeek:master

Conversation

@richelbilderbeek
Copy link
Collaborator

Hi @Giappo,

A couple of days ago, my becosys package build broke. The reason is that this code gives an unhelpful error message, since four days. Here is the reprex:

library(mbd)
set.seed(44)
mbd_ml(
  brts = c(3.0, 2.0),
  start_pars = c(0.3, 0.1, 0.0, 0.0),
  true_pars = c(0.3, 0.1, 0.0, 0.0),
  optim_ids = c(TRUE, TRUE, FALSE, FALSE),
  cond = 1,
  n_0 = 2
)

In this Pull Request, I've added a test that will break the build, to verify this is indeed an error. I put the test below one of your tests, that test in a very similar parameter setting.

What I would expect, is that this test either works, or gives a helpful error message.

I hope this extra test helps to improve mbd.

For more details (e.g. which mbd commit broke the becosys build), see this Issue.

Good luck 👍

@lintr-bot
Copy link

R/mbd_main_utils.R:13:3: warning: local variable ‘pkg_name’ assigned but may not be used

pkg_name <- get_pkg_name() # nolint internal function
  ^~~~~~~~

R/mbd_main_utils.R:13:15: warning: no visible global function definition for ‘get_pkg_name’

pkg_name <- get_pkg_name() # nolint internal function
              ^~~~~~~~~~~~

@richelbilderbeek
Copy link
Collaborator Author

Instead of waiting, the error can already be viewed here

@lintr-bot
Copy link

R/mbd_loglik_utils.R:39:1: style: Lines should not be more than 80 characters.

matrix_a[s + 2, dst] <- matrix_a[s, src] + matrix_a[s + 1, src] # check here! TODO
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/mbd_loglik_utils.R:150:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

create_a_slow <- function(
^

R/mbd_loglik_utils.R:181:1: style: Lines should not be more than 80 characters.

if (is.nan(a_matrix_mn) || a_matrix_mn == 0 || is.infinite(a_matrix_mn)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbd_matrices.R:238:1: style: functions should have cyclomatic complexity of less than 15, this has 17.

​test_that("a_matrix: hardcore case", {
^

tests/testthat/test-mbd_matrices.R:254:13: warning: Avoid 1:nrow(...) expressions, use seq_len.

for (i in 1:nrow(coords)) {
            ^

tests/testthat/test-mbd_matrices.R:261:7: style: Commented code should be removed.

# sum(2 ^ j * choose(k, j) * choose(n, m - n - j))
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbd_matrices.R:292:7: style: Commented code should be removed.

# sum(2 ^ j * choose(k, j) * choose(n, m - n - j))
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

R/mbd_loglik_utils.R:39:1: style: Lines should not be more than 80 characters.

matrix_a[s + 2, dst] <- matrix_a[s, src] + matrix_a[s + 1, src] # check here! TODO
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/mbd_loglik_utils.R:150:1: style: functions should have cyclomatic complexity of less than 15, this has 16.

create_a_slow <- function(
^

R/mbd_loglik_utils.R:181:1: style: Lines should not be more than 80 characters.

if (is.nan(a_matrix_mn) || a_matrix_mn == 0 || is.infinite(a_matrix_mn)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/mbd_main_utils.R:13:3: warning: local variable ‘pkg_name’ assigned but may not be used

pkg_name <- get_pkg_name() # nolint internal function
  ^~~~~~~~

R/mbd_main_utils.R:13:15: warning: no visible global function definition for ‘get_pkg_name’

pkg_name <- get_pkg_name() # nolint internal function
              ^~~~~~~~~~~~

tests/testthat/test-mbd_matrices.R:238:1: style: functions should have cyclomatic complexity of less than 15, this has 17.

​test_that("a_matrix: hardcore case", {
^

tests/testthat/test-mbd_matrices.R:254:13: warning: Avoid 1:nrow(...) expressions, use seq_len.

for (i in 1:nrow(coords)) {
            ^

tests/testthat/test-mbd_matrices.R:261:7: style: Commented code should be removed.

# sum(2 ^ j * choose(k, j) * choose(n, m - n - j))
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbd_matrices.R:292:7: style: Commented code should be removed.

# sum(2 ^ j * choose(k, j) * choose(n, m - n - j))
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

3 participants