GithubHelp home page GithubHelp logo

Comments (4)

mjskay avatar mjskay commented on June 7, 2024 1

Thinking about how this relates to uses of variable names across the API, this seems related to the inconsistent handling of indices in variable names between draws_rvars and the other formats (see here: #208 (comment))

One thought is to fix the above-referenced issue so that something like variables(x, with_indices = TRUE) (default) returns names like x[1,1], x[1,2], ... and variables(x, with_indices = FALSE) returns names like x. Then have clear indications in the API of which functions take variable names with or without indices.

For this issue specifically, following the pattern of extract_variable_matrix() we could have an extract_variable_array(x, variable) that takes a variable name without indices and returns its array form. Then the solution in the above example would be extract_variable_array(x, "z_1")[1,,].

If we also want a solution specifically for getting one draw regardless of shape, then there is helper code used by for_each_draw that could be extracted and adapted for that purpose.

from posterior.

mjskay avatar mjskay commented on June 7, 2024 1

Cool, happy to take a stab at it.

from posterior.

avehtari avatar avehtari commented on June 7, 2024

I did also notice the index-inconsistency, and like the idea of with_indices

extract_variable_array would work for me (the first use case is stan-dev/cmdstanr#876)

from posterior.

paul-buerkner avatar paul-buerkner commented on June 7, 2024

I agree. Sounds like a good solution.

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.