Skip to content

Commit b5d0d1f

Browse files
authored
Merge pull request #1796 from clane9/bugfix/random_seed
🐛 fix type handling in `set_up_random_state`
2 parents 7f50838 + dc3f113 commit b5d0d1f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Updated `rbc-options` preconfig to use `fmriprep-options` preprocessing
3434

3535
### Fixed
36+
- Fixed [bug](https://github.com/FCP-INDI/C-PAC/issues/1795) that was causing `cpac run` to fail when passing a manual random seed via `--random_seed`.
3637
- Replaces ``DwellTime`` with ``EffectiveEchoSpacing`` for FSL usage of the term
3738

3839
## [v1.8.4] - 2022-06-27

CPAC/pipeline/random_state/seed.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,15 @@ def set_up_random_state(seed):
166166
if seed is not None:
167167
if seed == 'random':
168168
seed = random_random_seed()
169-
if (seed != 'random' and not (
170-
isinstance(seed, int) and
171-
(0 < int(seed) <= np.iinfo(np.int32).max)
172-
)):
173-
raise ValueError('Valid random seeds are positive integers up to '
174-
f'2147483647, "random", or None, not {seed}')
175-
try:
176-
_seed['seed'] = int(seed)
177-
except (TypeError, ValueError):
178-
_seed['seed'] = seed
169+
else:
170+
try:
171+
seed = int(seed)
172+
assert 0 < seed <= np.iinfo(np.int32).max
173+
except(ValueError, TypeError, AssertionError):
174+
raise ValueError('Valid random seeds are positive integers up to '
175+
f'2147483647, "random", or None, not {seed}')
176+
177+
_seed['seed'] = seed
179178
return random_seed()
180179

181180

0 commit comments

Comments
 (0)