Skip to content

Commit

Permalink
Rename 'random_state' to 'seed' in generate_jigsaw_destinations()
Browse files Browse the repository at this point in the history
This patch renames the parameter `random_state` to `seed`
in `generate_jigsaw_destinations()` as that makes it more clear
that the parameter also accepts seed values, which is the
standard use case.
  • Loading branch information
aleju committed Jan 14, 2020
1 parent ed87741 commit 41d3dd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion checks/check_jigsaw.py
Expand Up @@ -26,7 +26,7 @@ def main():
)
print("Time to generate 128x dest:", gen_time)

destinations = iaa.generate_jigsaw_destinations(10, 10, 1, random_state=1)
destinations = iaa.generate_jigsaw_destinations(10, 10, 1, seed=1)
image_jig = iaa.apply_jigsaw(image, destinations)
ia.imshow(image_jig)

Expand Down
11 changes: 6 additions & 5 deletions imgaug/augmenters/geometric.py
Expand Up @@ -504,7 +504,7 @@ def apply_jigsaw_to_coords(coords, destinations, image_shape):
return result


def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, seed,
connectivity=4):
"""Generate a destination pattern for :func:`apply_jigsaw`.
Expand All @@ -519,8 +519,9 @@ def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
max_steps : int
Maximum number of cells that each cell may be moved.
random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState
RNG or seed to use. If ``None`` the global RNG will be used.
seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState
Seed value or alternatively RNG to use.
If ``None`` the global RNG will be used.
connectivity : int, optional
Whether a diagonal move of a cell counts as one step
Expand All @@ -535,7 +536,7 @@ def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
"""
assert connectivity in (4, 8), (
"Expected connectivity of 4 or 8, got %d." % (connectivity,))
random_state = iarandom.RNG(random_state)
random_state = iarandom.RNG(seed)
steps = random_state.integers(0, max_steps, size=(nb_rows, nb_cols),
endpoint=True)
directions = random_state.integers(0, connectivity,
Expand Down Expand Up @@ -5661,7 +5662,7 @@ def _draw_samples(self, batch, random_state):
destinations.append(
generate_jigsaw_destinations(
nb_rows[i], nb_cols[i], max_steps[i],
random_state=random_state)
seed=random_state)
)

samples = _JigsawSamples(nb_rows, nb_cols, max_steps, destinations)
Expand Down

0 comments on commit 41d3dd6

Please sign in to comment.