Convention for output of tuples
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 198
- フォーク
- 82
- 平均マージ
- 4日 11時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stan-dev/cmdstanpy のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
laplace_sample: expose CmdStan's diagnostic_file (the Hessian at the mode)対応中かも @atarutin が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
-
Release 2.0オープン
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
-
feature
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
stan-dev/cmdstanpy の issue をすべて見る
似ている issue
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
python-version
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
bug javascript P2-medium python release:v3.1
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
adrirubio/claude-deck#546 ·
メンテナーはふだん 1 日以内に返信
-
area: desktop area: website priority: P2 type: feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
appandflow/stim#3411 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信