Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Make seed = I(FALSE) escalate to an error if RNG was used

オープン
#831 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
r

調査の方向性

ファイルやテストは指定されていません。まず、future() の seed 引数と既存の future.rng.onMisuse の処理を追跡し、呼び出しごとの重大度を指定する提案された形式を比較して、seed=FALSE およびグローバルオプションとの互換性を定義してください。選択した動作が仕様化され、テストによって検証されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

RNG

Currently, the default behavior of declaring use of the random number generator (RNG) is seed = FALSE, which triggers a warning if it detects that the future did indeed use the RNG despite not declaring so;

library(future)
f <- future(sample.int(3))  ## defaults to seed = FALSE
v <- value(f)
v
#> [1] 3 2 1
#> Warning message:
#> UNRELIABLE VALUE: Future (<unnamed-1>) unexpectedly generated random numbers without specifying argument 'seed'. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced. To disable this check, use 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore". [future <unnamed-1> (54b70f088e2c65b835aea5f0cd100eff-1); on 54b70f088e2c65b835aea5f0cd100eff@hb-x1-2023<867157>] 

We can escalate these type of warnings to errors globally by setting R option future.rng.onMisuse as in:

library(future)
options(future.rng.onMisuse = "error")
f <- future(sample.int(3))
v <- value(f)
#> Error: UNRELIABLE VALUE: Future (<unnamed-2>) unexpectedly generated random numbers without specifying argument 'seed'. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced. To disable this check, use 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore". [future <unnamed-2> (54b70f088e2c65b835aea5f0cd100eff-2); on 54b70f088e2c65b835aea5f0cd100eff@hb-x1-2023<867157>]

The problem with this approach is that options are global and affects all codes, even where we don't want a strict check. Also,none of the future R options should be set developers - only end-users for troubleshooting etc. One can of course set options temporarily to control this, but it adds clutter and is error prone.

A better way to give the developer control of the severity of RNG misuse is via the seed argument itself. Here are a few approaches:

  • seed = structure(FALSE, onMisuse = "error")
  • seed = I(FALSE) - "as-is"

We could also move towards making seed = FALSE be strict and give an error, and seed = NA to be the current soft warning. However, such a migration is a much bigger task given that we'll break some existing code.

主要言語
R
スター
1k
フォーク
94
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

futureverse/future のほかの issue

futureverse/future の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。