stan-dev / stan-dev/posterior

Add a `repair_variable_names` function

Open
#317 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
R
Stars
171
Forks
26
Avg merge
2d 18h
Merged PRs (30d)
3

Description

This allows you to translate from the names Stan uses (like theta.1) to those Posterior wants (theta[1]).

This function exists (privately) in cmdstanr, and is currently very simple:

repair_variable_names <- function(names) {
    names <- sub("\\.", "[", names)
    names <- gsub("\\.", ",", names)
    names[grep("\\[", names)] <- paste0(names[grep("\\[", names)], "]")
    names
}

This doesn't work for complex numbers or tuples, but since posterior doesn't seem to support those either I think this is fine

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no target file or test. Start by locating the package entry point for variable-name utilities and the existing tests around Stan variable names, then compare the function's behavior with the shown examples. Done means the public function translates names such as theta.1 to theta[1] and has coverage for the supported naming cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.