Convention for output of tuples
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start with the tuple_out.stan example and the test_tuple_out test shown in the issue, then inspect fit.stan_variable("c") and fit.c behavior. Compare array-of-tuples and tuple-of-arrays layouts, and define the resulting sample indexing convention before updating the relevant tests and documentation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In the develop branch, tuples generated by Stan programs are one-dimensional arrays of tuples. This can make it difficult to access elements of tuples. For example, consider the following test.
def test_tuple_out() -> None:
stan = os.path.join(DATAFILES_PATH, 'tuple_out.stan')
model = CmdStanModel(stan_file=stan)
a = np.random.normal(0, 1, (5, 5))
b = np.random.normal(0, 1, 3)
fit = model.sample({"a": a, "b": b}, fixed_param=True, chains=1,
iter_sampling=20, iter_warmup=1, sig_figs=18)
np.testing.assert_allclose(a, fit.stan_variable("c")[0][0])
np.testing.assert_allclose(b, fit.stan_variable("c")[0][1])
// tuple_out.stan
data {
matrix [5, 5] a;
vector [3] b;
}
generated quantities {
tuple(matrix[5, 5], vector[3]) c;
c.1 = a;
c.2 = b;
}
Then accessing c.1 samples is only possible through list comprehension (there may be some fancy indexing I'm not familiar with).
>>> fit.c.shape
(20,)
>>> fit.c[:, 0]
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
Would it make sense to return a tuple of arrays rather than an array of tuples? This would allow accessing samples more easily, e.g., in the above example we'd get
>>> fit.c[0].shape
(20, 5, 5)
This would however go against the convention that the first index refers to samples.
- Lenguaje dominante
- Python
- Estrellas
- 198
- Forks
- 82
- Merge medio
- 4 d 11 h
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stan-dev/cmdstanpy
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
laplace_sample: expose CmdStan's diagnostic_file (the Hessian at the mode)Posiblemente ocupada @atarutin la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
-
Release 2.0Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
-
feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Todos los issues de stan-dev/cmdstanpy
Issues similares
-
Claiming namespace `jft63`Abiertonamespace operations
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
EclipseFdn/open-vsx.org#14043 ·
Los mantenedores suelen responder en 1 día
-
netbox status: needs triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
netbox-community/netbox#23376 ·
Los mantenedores suelen responder en 1 día
-
feedback simulation workshop
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
githubnext/gh-aw-workshop#4455 ·
Los mantenedores suelen responder en 1 día
-
Triage 🩺
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitAbiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
krkn-chaos/krkn#1627 · 1 comentario ·
Los mantenedores suelen responder en 1 día