GithubHelp home page GithubHelp logo

Comments (4)

paul-buerkner avatar paul-buerkner commented on June 2, 2024 1

I think we can export the generic and thus the methods actually. However, then we would have to add all kinds of validity checks, which we currently don't have in place there. I like the idea of adding an exclude option to subset_draws.
This could internally call remove_variables then.

BTW: the fact that the remove_variables methods are exported just ensures that they are registered as S3 methods to the generic. They won't actually be exported this way.

from posterior.

paul-buerkner avatar paul-buerkner commented on June 2, 2024 1

Yes, that looks sensible to me. Thank you!

from posterior.

n-kall avatar n-kall commented on June 2, 2024

I think an exclude option for subset_draws could be implemented with setdiff like this. If this seems ok, I can make a PR

subset_draws.draws_array <- function(x, variable = NULL, iteration = NULL,
                                     chain = NULL, draw = NULL, regex = FALSE,
                                     unique = TRUE, exclude = FALSE, ...) {
  if (all_null(variable, iteration, chain, draw)) {
    return(x)
  }

  x <- repair_draws(x)
  variable <- check_existing_variables(variable, x, regex = regex)
  iteration <- check_iteration_ids(iteration, x, unique = unique)
  chain <- check_chain_ids(chain, x, unique = unique)
  draw <- check_draw_ids(draw, x, unique = unique)

 ########## code for exclude option
  if (exclude) {
    if (!is.null(variable)) {
      variable <- setdiff(variables(x), variable)
    }
    if (!is.null(iteration)) {
      iteration <- setdiff(iteration_ids(x), iteration)
    }
    if (!is.null(chain)) {
      chain <- setdiff(chain_ids(x), chain)
    }
    if (!is.null(draw)) {
      draw <- setdiff(draw_ids(x), draw)
    }
  }
 #############

  x <- prepare_subsetting(x, iteration, chain, draw)
  if (!is.null(draw)) {
    iteration <- draw
  }
  x <- .subset_draws(x, iteration, chain, variable, reserved = TRUE)
  if (!is.null(chain) || !is.null(iteration)) {
    x <- repair_draws(x, order = FALSE)
  }
  x
}

from posterior.

n-kall avatar n-kall commented on June 2, 2024

Closed by #336

from posterior.

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.