-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add $variables()
#519
Add $variables()
#519
Conversation
Codecov Report
@@ Coverage Diff @@
## master #519 +/- ##
==========================================
- Coverage 92.77% 91.65% -1.13%
==========================================
Files 12 12
Lines 3047 3031 -16
==========================================
- Hits 2827 2778 -49
- Misses 220 253 +33
Continue to review full report at Codecov.
|
I like your current suggestion. Just a few thoughts:
And a few questions more related to CmdStan and stanc3 than CmdStanR:
|
could be yes.m, good call. Any other suggestions? Dimension_length? dims_length? Any other?
I like it!
That is missing yes. Thanks for the issue.
not at the moment, but we can definitely add stuff to what —info returns. |
Maybe Alternatively, we could keep |
# Conflicts: # NEWS.md
This is now ready for review finally. Changes:
|
) | ||
variables <- jsonlite::read_json(out_file, na = "null") | ||
variables$data <- variables$inputs | ||
variables$inputs <- NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think data
is a better name here than inputs
.
expect_equal(mod$variables()$parameters$theta$type, "real") | ||
expect_equal(mod$variables()$parameters$theta$dimensions, 0) | ||
expect_equal(length(mod$variables()[["transformed parameters"]]), 0) | ||
expect_equal(length(mod$variables()[["generated quantities"]]), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename these two to a name with an underscore?
regarding names - CmdStanPy and CmdStanR have somewhat diverged on the methods for the CmdStanMCMC object I would love to come up with a good and consistent set of names for these functions on both the CmdStanModel and CmdStanMCMC object. the difference in dimensionality may be confusing to users - a Stan variable as declared in Also, CmdStanMCMC object in CmdStanPy makes a distinction between |
I think its concise.
Yes, CmdStanMCMC does this similarly, just with
I agree that transformed data names are not relevant as they do not occur in the input nor the output, they are not present here. The purpose of |
right, this is good and useful. as it's a method on the CmdStanModel object, the name |
Sure, no issue in splitting, we discussed this in the issue I think as well. Options: Not a huge fan of the vars shorthand but seems that is where cmdstanpy is headed, so maybe we should as well. I dont have a strong preference though. @jgabry might have one? |
I'm happy to go with what whatever consensus we can find. discuss on forums? until we get to 1.0, we can change names - but only if it's for the better. |
Sorry for the delay on this! I totally missed these comments earlier. I think I prefer |
But neither preference is super super strong |
cmdstanpy has |
are |
Good point. I think this is true for CmdStanR too |
Not sure why availability is the question here? Maybe I am misunderstanding, which is always an option :) |
OK, now I understand - these are methods on the model class.
I think this is potentially confusing. it conflates the Stan language with
the current behavior of the Stan platform I/O.
also, given that the model code is available, why are these methods needed?
but if we report Stan program variables, it should be in terms of the Stan
block names - not `input` and `output`.
…On Fri, Aug 6, 2021 at 4:08 AM Rok Češnovar ***@***.***> wrote:
are data_variables always available?
mod$data_variables() and mod$output_variables() will only return the
information on all the input and output model variables, not the actual
values. So this will return names, dimensionalities and types. Given that
its part of the model class, its not possible to return anything else.
Not sure why availability is the question here? Maybe I am
misunderstanding, which is always an option :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#519 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJWT5BZKUQHJFI2K3NYTSDT3OJ7TANCNFSM466EOVAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
No you're right. In my haste I got confused, which tends to happen :) |
I'm not sure it's absolutely needed, but it can be helpful. For example, it would allow us to solve this: #513 |
how about |
Yes, this is basically what is currently implemented. I had the block arg initially, but I felt its redundant as one can simply do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just the one comment about the missing transformed parameters
.
```{r variable-type-dims} | ||
variables$data$J | ||
variables$data$sigma | ||
variables$transformed_parameters$theta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rok-cesnovar When I run this I get NULL
for the transformed parameters even though it should have theta
. Do you get that too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry, should have used
variables$`transformed parameters`
variables$`generated quantities`
variables[["generated quantities"]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was leftover from an earlier version when I replaced the space with underscore. I am not sure which one is better. Space is more similar to the actual block name in the Stan model, underscore is easier to use with $
. I am fine with either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
underscore is easier to use with
$
. I am fine with either.
I think I prefer the underscore if that's ok with you. Sorry for the extra work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem at all. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Changes look good. I'll go ahead and merge now.
Summary
This PR will attempt to add
$variables()
. First we need to settle what will be the args (if any) and what it will return.Current suggestion is:
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):
Rok Češnovar
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: