samila/test/function_test.py

106 wiersze
2.6 KiB
Python
Czysty Zwykły widok Historia

2021-10-05 10:05:33 +00:00
# -*- coding: utf-8 -*-
"""
>>> import random
>>> import sys
2021-10-12 16:37:23 +00:00
>>> from samila.functions import *
>>> is_valid_color("blue")
True
>>> is_valid_color((0,0,0))
True
>>> is_valid_color((0.1,0.1,0,1))
True
>>> is_valid_color([1,1,1,1])
True
>>> is_valid_color("#FFFAAF")
True
>>> color_complement("#FFFFFF")
'#000000'
>>> color_complement("#FFAFBF")
'#005040'
>>> color_complement("#000000")
'#ffffff'
>>> select_color("blue")
'blue'
>>> select_color("#FFFFFA")
'#fffffa'
>>> select_color((0.1,0.1,0.1))
(0.1, 0.1, 0.1)
>>> select_color(None)
>>> select_color("complement")
'COMPLEMENT'
>>> select_color("transparent")
'TRANSPARENT'
2021-10-12 16:37:23 +00:00
>>> 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
>>> is_same_data(s,[1,1.1,1.2,1.3,1.4,1.5,1.6])
False
>>> is_same_data(s,[])
False
>>> filter_color("yellow", "blue")
('yellow', 'blue')
>>> filter_color((0.2,0.3,0.4), (0.2,0.3,0.4,1))
((0.2, 0.3, 0.4), (0.2, 0.3, 0.4, 1))
>>> filter_color("#FFFFFF", "#ffffe1")
('#ffffff', '#ffffe1')
>>> random.seed(2)
>>> color1, bgcolor1 = filter_color("random", "random")
>>> random.seed(3)
>>> color2, bgcolor2 = filter_color("RANDOM", "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
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
>>> filter_marker(3)
>>> filter_marker(Marker.POINT)
'.'
>>> random.seed(2)
>>> marker1 = filter_marker(Marker.RANDOM)
>>> random.seed(3)
>>> marker2 = filter_marker(Marker.RANDOM)
>>> marker1 == marker2
False
2021-10-12 16:37:23 +00:00
>>> distance_calc("test","test1")
1
>>> distance_calc("te1st","test")
1
>>> distance_calc("test12","test234")
3
>>> get_python_version() == '.'.join(sys.version.split()[0].split('.')[:2])
True
2021-10-12 16:37:23 +00:00
>>> 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>
Website : https://www.samila.site
2021-10-12 16:37:23 +00:00
Repo : https://github.com/sepandhaghighi/samila
2021-10-05 10:05:33 +00:00
"""