Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print line numbers #967

Merged
merged 5 commits into from
May 13, 2024
Merged

print line numbers #967

merged 5 commits into from
May 13, 2024

Conversation

sbfnk
Copy link
Contributor

@sbfnk sbfnk commented May 10, 2024

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

Closes #966.

Here's an example outcome of the suggested approach:

library("cmdstanr")
#> This is cmdstanr version 0.7.1
#> - CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
#> - CmdStan path: /Users/eidesfun/.cmdstan/cmdstan-2.34.1
#> - CmdStan version: 2.34.1
file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
mod <- cmdstan_model(file)
mod
#>  1: data {
#>  2:   int<lower=0> N;
#>  3:   array[N] int<lower=0,upper=1> y;
#>  4: }
#>  5: parameters {
#>  6:   real<lower=0,upper=1> theta;
#>  7: }
#>  8: model {
#>  9:   theta ~ beta(1,1);  // uniform prior on interval 0,1
#> 10:   y ~ bernoulli(theta);
#> 11: }

Created on 2024-05-10 with reprex v2.1.0

The print() method could get an argument (e.g. line_numbers) with a default one way or the other if going ahead with the suggestion.

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Sebastian Funk

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

@andrjohns
Copy link
Collaborator

I'd rather this not be the default behaviour, instead could you add an argument to the print() method:

line_numbers = getOption("cmdstanr.print_line_numbers", FALSE)

So that the default behaviour doesn't change, but users can also set it for all models.

@sbfnk
Copy link
Contributor Author

sbfnk commented May 13, 2024

Thanks, I've followed that suggestion except naming it cmdstanr_print_line_numbers (underscore) to be in line with other options used by the package.

Copy link
Collaborator

@andrjohns andrjohns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The windows CI failures are unrelated

@andrjohns andrjohns merged commit 1f4efad into stan-dev:master May 13, 2024
6 of 10 checks passed
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.

Print line numbers
2 participants