Merge pull request #730 from py-why/fix/refuter_random_state

Check random_state type on placebo_treatment_refuter Fix #719
This commit is contained in:
Andres Morales 2022-11-01 09:25:32 -06:00 коммит произвёл GitHub
Родитель 68f5d2b1bc 6f721e5c1b
Коммит 656aa9964f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -88,7 +88,7 @@ def _refute_once(
treatment_names: List[str],
type_dict: Dict,
placebo_type: PlaceboType = PlaceboType.DEFAULT,
random_state: Optional[Union[int, np.random.RandomState]] = None,
random_state: Optional[np.random.RandomState] = None,
):
if placebo_type == PlaceboType.PERMUTE:
permuted_idx = None
@ -179,6 +179,10 @@ def refute_placebo_treatment(
:param n_jobs: The maximum number of concurrently running jobs. If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all (this is the default).
:param verbose: The verbosity level: if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level. If it more than 10, all iterations are reported. The default is 0.
"""
if isinstance(random_state, int):
random_state = np.random.RandomState(random_state)
# only permute is supported for iv methods
if target_estimand.identifier_method.startswith("iv"):
if placebo_type != PlaceboType.PERMUTE: