Convention for output of tuples
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 198
- Fork
- 81
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di stan-dev/cmdstanpy
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
-
feature method outputs
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Tutte le issue di stan-dev/cmdstanpy
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
huggingface/Repo2RLEnv#163 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NousResearch/hermes-agent#121143 ·