Coder Social home page Coder Social logo

Comments (2)

mayeulk avatar mayeulk commented on June 10, 2024

The following is an extended short example with three groups of rules, and a temporary workaround to help correct the bug:

library(pointblank)

c_agent <- create_agent( tbl= small_table) %>%
  col_vals_regex(columns = vars(b, f), 
                 #col_vals_regex(columns = vars(gnad_fin_url), # CORRECT          
                 regex = "[a-z]",
                 step_id = "my_regex",
                 label = "This is my regex",
                 brief = "The current field must have at least one letter"
  )  %>%
  col_vals_regex(columns = vars(b), 
                 #col_vals_regex(columns = vars(gnad_fin_url), # CORRECT          
                 regex = "\\d",
                 step_id = "anoter_regex_1_column",
                 label = "Another regex for just 1 column",
                 brief = "The b field must have at least one number"
  )  %>%
    col_vals_regex(columns = vars(b, f), 
                 #col_vals_regex(columns = vars(gnad_fin_url), # CORRECT          
                 regex = "\\d",
                 step_id = "anoter_regex",
                 label = "Another regex",
                 brief = "The current field must have at least one number"
  )  %>%
  interrogate()

c_agent # tooltip over "This is my regex" (first column in report table) is only visilbe for the first step of the series

c_agent$validation_set$step_id[1]
c_agent$validation_set$label[1]
c_agent$validation_set$brief[1] #!is.NA (this is correct)

c_agent$validation_set$step_id[2]
c_agent$validation_set$label[2]
c_agent$validation_set$brief[2] # is.NA (this is the bug)

get_agent_x_list(c_agent)$briefs # every second value is.NA for steps with several "sub-steps" (same bug)
c_agent$validation_set$brief # same bug

c_agent$validation_set$label # No NAs

# Start of the workaround
steps_labels_briefs <- data.frame(step_id = c_agent$validation_set$step_id, label=c_agent$validation_set$label, old_brief = c_agent$validation_set$brief, new_brief = NA)

steps_labels_briefs$step_group <- 
  sub(pattern = "^(.+)(\\.\\d{4})$", replacement ="\\1",  steps_labels_briefs$step_id, perl = T)

# First row (step) of each group of steps
steps_labels_briefs_0001 <- 
  steps_labels_briefs[grepl(pattern = "^(.+)(\\.0001)$", steps_labels_briefs$step_id),]

# Assign the correct brief value (workaround)
steps_labels_briefs$new_brief <- steps_labels_briefs$old_brief
for (c_step_group in steps_labels_briefs_0001$step_group){
  steps_labels_briefs$new_brief[steps_labels_briefs$step_group == c_step_group] <-
    steps_labels_briefs_0001$old_brief[steps_labels_briefs_0001$step_group  == c_step_group]
}
c_agent$validation_set$brief <- steps_labels_briefs$new_brief

# Check that the workaround worked
get_agent_x_list(c_agent)$briefs # correct
c_agent$validation_set$brief #  correct (side note: much faster than previous line of code)

from pointblank.

rich-iannone avatar rich-iannone commented on June 10, 2024

Thanks for catching this. This can definitely be fixed!

from pointblank.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.