From 05eeeba84b44ca377492bed42787a8c0cb20be43 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Fri, 1 Dec 2023 15:38:38 -0800 Subject: [PATCH 1/5] add : `func_seed` added to GenerativeImage.__init__ --- test/overall_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/overall_test.py b/test/overall_test.py index 8ae3ecae..7ca08c14 100644 --- a/test/overall_test.py +++ b/test/overall_test.py @@ -361,6 +361,15 @@ True >>> del(g1) >>> del(g2) +>>> random.seed(22) +>>> g = GenerativeImage() +>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2) +>>> g_ = GenerativeImage(func_seed=22) +>>> g_.generate(start=-2*math.pi, step=0.1, stop=math.pi/2) +>>> g.function1_str == g_.function1_str +True +>>> g.function2_str == g_.function2_str +True >>> os.remove("test.png") >>> os.remove("test2.png") >>> os.remove("data.json") From 2d0c9eadeaae724b8bbe3165c3a5ad6ce04d990a Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Fri, 1 Dec 2023 15:38:53 -0800 Subject: [PATCH 2/5] add : " --- samila/genimage.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/samila/genimage.py b/samila/genimage.py index 14c884f6..602d930e 100644 --- a/samila/genimage.py +++ b/samila/genimage.py @@ -26,7 +26,13 @@ class GenerativeImage: >>> GI = GenerativeImage(f1, f2) """ - def __init__(self, function1=None, function2=None, data=None, config=None): + def __init__( + self, + function1=None, + function2=None, + data=None, + config=None, + func_seed=None): """ Init method. @@ -38,7 +44,10 @@ def __init__(self, function1=None, function2=None, data=None, config=None): :type data: (io.IOBase & file) :param config: generative image config :type config: (io.IOBase & file) + :param func_seed: random seed for function generation + :type func_seed: Any """ + random.seed(func_seed) _GI_initializer(self, function1, function2) if config is not None: load_config(self, config) From 2911133b1d35882596afb9a8c1a956992c96544b Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Fri, 1 Dec 2023 15:39:00 -0800 Subject: [PATCH 3/5] log : changes logged. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2cba72..3ec5cddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `get_cmap` function - `Gateway` enum ### Changed +- `func_seed` parameter added to GenerativeImage `__init__` - minor edits in `functions.py` - `DEFAULT_CMAP` renamed to `DEFAULT_CMAP_NAME` - `pillow` added to conda dependencies From 8c2960786677c07ce243e6deebc9d06a0a02a495 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Mon, 4 Dec 2023 21:55:14 -0800 Subject: [PATCH 4/5] readme : readme updated. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a973afe1..91f9c3ec 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ Samila is a generative art generator written in Python, Samila lets you create i ``` +* You can change function generation seed by `func_seed` parameter in `GenerativeImage` + ### Basic ```pycon >>> import random From 0b77d3f33043ee84261fac077f69a2d80d1d7b6c Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Mon, 4 Dec 2023 21:55:29 -0800 Subject: [PATCH 5/5] fix : random seed problem fixed. --- samila/genimage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samila/genimage.py b/samila/genimage.py index 602d930e..48004dbd 100644 --- a/samila/genimage.py +++ b/samila/genimage.py @@ -47,7 +47,6 @@ def __init__( :param func_seed: random seed for function generation :type func_seed: Any """ - random.seed(func_seed) _GI_initializer(self, function1, function2) if config is not None: load_config(self, config) @@ -62,6 +61,8 @@ def __init__( self.python_version, self.__version__), RuntimeWarning) + if func_seed is not None: + random.seed(func_seed) if self.function1 is None: if self.function1_str is None: self.function1_str = random_equation_gen()