stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.02k stars 264 forks source link

Lookup function doesn't return Stan function names #1110

Closed ian-coccimiglio closed 4 months ago

ian-coccimiglio commented 5 months ago

Summary:

The lookup function in R does not return Stan function names anymore, instead it only returns the name of the input R function.

Description

I think the issue is either in the rosetta formatting or the matching of the lookup function. The function uses rosetta[matches, -1, drop = FALSE] and drops the first column of the output, which are the Stan function names, rather than dropping the second column of R function names.

Reproducible Steps:

Use lookup(dnorm) or lookup("dnorm") using rstan v2.32.5 (or any other R function).

Current Output:

> lookup(dnorm)
    RFunction                                                                    Arguments ReturnType
415     dnorm (real, matrix, real, vector, T);(vector, row_vector, vector, vector, vector)     T;real
418     dnorm                                     (real, real, T);(vector, vector, vector)     T;real
419     dnorm                                     (real, real, T);(vector, vector, vector)     T;real
553     dnorm                                                                 (T);(vector)     T;real

Expected Output:

See here for the original return value of the function.

image

RStan Version:

Rstan v2.32.5

R Version:

R version 4.3.0

Operating System:

Both macOSX and Manjaro linux.

jgabry commented 4 months ago

I think the issue is either in the rosetta formatting or the matching of the lookup function. The function uses rosetta[matches, -1, drop = FALSE] and drops the first column of the output, which are the Stan function names, rather than dropping the second column of R function names.

@ian-coccimiglio thanks for bringing this to our attention. That's strange! @bgoodri I guess the columns in rosetta changed order by mistake at some point? Simplest solution seems to be to just change to rosetta[matches, -2, drop = FALSE] (or better yet, drop using the column name).

jgabry commented 4 months ago

I made a PR: https://github.com/stan-dev/rstan/pull/1113