From 6728642a4fc07ec9c47db99efe12981c18f95ee5 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Wed, 1 Feb 2023 17:59:54 +0100 Subject: [PATCH] Refactoring: Move Mode random helper functions --- synthesis/random.py | 20 ++++++++++++++++++++ test/fixtures/page_generation/page.py | 14 +------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/synthesis/random.py b/synthesis/random.py index c28c206..761d695 100644 --- a/synthesis/random.py +++ b/synthesis/random.py @@ -3,6 +3,26 @@ import random from loguru import logger random_seed = random.randint(0, 2**32 - 1) +# random_seed = 2973413116 +# random_seed = 2212357755 + +# random_seed = 2987558464 # light green + +# random_seed = 1173898033 # strange bar plot + +# 2467967671 logger.info(f"Random seed: {random_seed}") rnd = random.Random(random_seed) + + +def maybe(): + return rnd.random() > 0.9 + + +def possibly(): + return rnd.random() > 0.5 + + +def probably(): + return rnd.random() > 0.4 diff --git a/test/fixtures/page_generation/page.py b/test/fixtures/page_generation/page.py index 2c48271..f0372dd 100644 --- a/test/fixtures/page_generation/page.py +++ b/test/fixtures/page_generation/page.py @@ -23,7 +23,7 @@ from cv_analysis.utils.merging import merge_related_rectangles from cv_analysis.utils.postprocessing import remove_overlapping, remove_included from cv_analysis.utils.spacial import area from synthesis.partitioner.two_column import TwoColumnPagePartitioner -from synthesis.random import rnd +from synthesis.random import rnd, maybe, possibly, probably from synthesis.segment.content_rectangle import ContentRectangle from synthesis.segment.random_content_rectangle import RandomContentRectangle from synthesis.segment.text_block.text_block import TextBlock @@ -816,18 +816,6 @@ class RandomPlot(RandomContentRectangle): self.content = image if not self.content else superimpose(self.content, image) -def maybe(): - return rnd.random() > 0.9 - - -def possibly(): - return rnd.random() > 0.5 - - -def probably(): - return rnd.random() > 0.4 - - def generate_random_text_block(rectangle: Rectangle, n_sentences=3000) -> ContentRectangle: block = TextBlock( *rectangle.coords,