samila/test/function_test.py

64 wiersze
1.6 KiB
Python
Czysty Zwykły widok Historia

2021-10-05 10:05:33 +00:00
# -*- coding: utf-8 -*-
"""
>>> import random
2021-10-12 16:37:23 +00:00
>>> from samila.functions import *
>>> s = list(float_range(1,1.5,0.1))
>>> s
[1.0, 1.1, 1.2000000000000002, 1.3000000000000003, 1.4000000000000004]
>>> is_same_data(s,[1,1.1,1.2,1.3,1.4])
2021-10-05 10:05:33 +00:00
True
2021-10-12 16:37:23 +00:00
>>> is_same_data([1,1.1,1.2,1.3,1.4],[1,1.11,1.3,1.4,1.5])
2021-10-12 16:29:28 +00:00
False
2021-10-12 16:37:23 +00:00
>>> filter_color("yellow")
'yellow'
>>> filter_color((0.2,0.3,0.4))
(0.2, 0.3, 0.4)
>>> filter_color("#FFFFFF")
'#FFFFFF'
>>> random.seed(2)
>>> color1 = filter_color("random")
>>> random.seed(3)
>>> color2 = filter_color("RANDOM")
>>> color1 == color2
False
>>> random.seed(2)
>>> color1 = random_hex_color_gen()
>>> random.seed(3)
>>> color2 = random_hex_color_gen()
>>> color1 == color2
False
>>> len(color1)
7
>>> len(color2)
7
2021-10-12 16:37:23 +00:00
>>> filter_color(2)
>>> filter_color(4)
Config json Added (#80) * fix : typo fixed in docstring. * unifx : never mind :). * remove : extra lines removed from Magic section. * add : samilaConfigError added. * edit : DEFAULT_PROJECTION edited. * add : CONFIG_TYPE_ERROR added. * add : filter_float function added. * add : save_config_file function added. * add : load_config function added. * add : minor imports addded to functions.py. * add : some imports added to genimage.py. * fix : whitespace removed. * add : config parameter added. * add : save_config method added. * edit : minor edits in genimage.py. * edit : minor edits in save/load config. * edit: minor edits in save/load config. * add : filter_size added to functions. * update : minor updated due to last change. * edit : minor edit in filter_size. * add : plot_params_filter function added. * add : generate_params_filter added. * remove : unneccessary errors and warnings removed. * update : GenerativeImage __init__ updated due to last commit. * add : _GI_initializer added. * edit : make load_data structure similar to load_config. * fix : typo fixed in functions. * test : some tests added. * test : tests added for warning. * fix : minor bug fixed. * add : filter_size tests added. * add : error tests added. * add : save_config part added. * fix : typo fixed. * tests : minor tests added. * move : function[12]_str moved to __init__ root. * fix : typo fixed in errors.py. * fix : typo fixed in README.md. * fix : typo fixed in CHANGELOG.md. * add : matplotlib_version attribute added. * add : samilaPlotError added. * add : PLOT_DATA_ERROR added. * update : minor updates due to latest changes. * remove : extra tests removed. * edit : PLOT_DATA_ERROR edited. * test : tests added. * edit : minor edits in save_config/data. * add : new error messages added. * test : tests added. * fix : typo fixed. * replace : DATA_NO_DATA_ERROR -> SAVE_NO_DATA_ERROR. * edit : minor edits in plot_params_filter function. * add : two parameter added. * edit : __init__ docstring edited. * fix : typo fixed in genimage. * fix : typo fixed in params.py. * fix : typo fixed in tests. * fix : typo fixed in CHANGELOG.md.
2022-01-04 15:24:12 +00:00
>>> filter_size(2)
>>> filter_size((2, 'test'))
>>> filter_size((2, 3.5))
(2, 3.5)
>>> filter_projection(2)
>>> filter_projection(Projection.POLAR)
'polar'
>>> random.seed(2)
>>> projection1 = filter_projection(Projection.RANDOM)
>>> random.seed(3)
>>> projection2 = filter_projection(Projection.RANDOM)
>>> projection1 == projection2
False
2021-10-12 16:37:23 +00:00
>>> distance_calc("test","test1")
1
>>> distance_calc("te1st","test")
1
>>> distance_calc("test12","test234")
3
>>> samila_help()
<BLANKLINE>
Samila is a generative art generator written in Python, Samila let's you
create arts based on many thousand points. The position of every single
point is calculated by a formula, which has random parameters.
Because of the random numbers, every image looks different.
<BLANKLINE>
Repo : https://github.com/sepandhaghighi/samila
2021-10-05 10:05:33 +00:00
"""