2021-09-20 19:58:52 +00:00
# -*- coding: utf-8 -*-
""" Samila params. """
2021-09-26 20:40:20 +00:00
import math
2021-09-28 11:46:15 +00:00
from enum import Enum
2021-09-28 06:51:16 +00:00
from matplotlib import colors as mcolors
2022-08-27 19:57:20 +00:00
from matplotlib import cm
2021-09-26 20:40:20 +00:00
2022-12-09 14:15:56 +00:00
SAMILA_VERSION = " 1.0 " # pragma: no cover
2021-09-29 15:32:44 +00:00
2021-10-05 09:59:53 +00:00
OVERVIEW = '''
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 .
'''
2021-09-26 20:40:20 +00:00
DEFAULT_START = - 1 * math . pi
DEFAULT_STOP = math . pi
DEFAULT_STEP = 0.01
DEFAULT_COLOR = " black "
2021-09-28 06:21:31 +00:00
DEFAULT_BACKGROUND_COLOR = " white "
2022-08-27 19:57:20 +00:00
DEFAULT_CMAP = cm . get_cmap ( " viridis " , 256 )
DEFAULT_CMAP_RANGE = 256
2021-09-28 06:23:41 +00:00
DEFAULT_ALPHA = 0.1
2022-03-25 12:55:01 +00:00
DEFAULT_LINEWIDTH = 1.5
2021-09-27 07:18:06 +00:00
DEFAULT_IMAGE_SIZE = ( 10 , 10 )
2021-09-26 20:40:20 +00:00
DEFAULT_SPOT_SIZE = 0.01
2022-01-29 13:05:02 +00:00
DEFAULT_DEPTH = 1
2023-03-26 15:00:40 +00:00
DEFAULT_ROTATION = 0.0
2022-01-04 15:24:12 +00:00
DEFAULT_PROJECTION = " rectilinear "
2022-11-05 22:16:28 +00:00
DEFAULT_MARKER = " . "
2022-01-04 15:24:12 +00:00
SEED_LOWER_BOUND = 0
SEED_UPPER_BOUND = 2 * * 20
2021-09-28 06:51:16 +00:00
VALID_COLORS = list ( dict ( mcolors . BASE_COLORS , * * mcolors . CSS4_COLORS ) . keys ( ) )
2022-04-20 08:25:33 +00:00
HEX_COLOR_PATTERN = r ' ^#(?:[0-9a-fA-F] {3} ) { 1,2}$ '
2021-09-30 01:10:54 +00:00
NFT_STORAGE_API = " https://api.nft.storage/upload "
2022-04-06 11:06:45 +00:00
NFT_STORAGE_LINK = " https://ipfs.io/ipfs/ {} "
2021-10-11 22:07:21 +00:00
NFT_STORAGE_SUCCESS_MESSAGE = " Everything seems good. "
2021-10-12 12:50:50 +00:00
FIG_SAVE_SUCCESS_MESSAGE = " Everything seems good. "
2021-10-22 09:28:52 +00:00
DATA_SAVE_SUCCESS_MESSAGE = " Everything seems good. "
2021-10-12 12:50:13 +00:00
NO_FIG_ERROR_MESSAGE = " No figure was found. First run `generate` and `plot` methods. "
2021-10-22 09:19:40 +00:00
DATA_TYPE_ERROR = " Provided data file is not supported. It should be either file or io.IOBase. "
2022-09-15 09:22:24 +00:00
DATA_FORMAT_ERROR = " Provided data file is not supported. It should include data1 and data2. "
2022-01-04 15:24:12 +00:00
CONFIG_TYPE_ERROR = " Provided config file is not supported. It should be either file or io.IOBase. "
2022-09-15 09:22:24 +00:00
CONFIG_FORMAT_ERROR = " Provided config file is not supported. It should include f1 and f2. "
2022-01-04 15:24:12 +00:00
CONFIG_NO_STR_FUNCTION_ERROR = " Config file can ' t be saved. At least one of the function1_str or function2_str is None. "
PLOT_DATA_ERROR = " Plotting process can ' t be Done because data {0} is empty. Use generate method first. "
2022-08-27 19:57:20 +00:00
COLOR_SIZE_ERROR = " Color list size is not equal to the data size. "
2022-01-04 15:24:12 +00:00
SAVE_NO_DATA_ERROR = " Data file can ' t be saved. At least one of the data1 or data2 is None. "
2022-05-28 11:54:18 +00:00
INVALID_COLOR_TYPE_ERROR = " Given color/bgcolor type is not supported. "
2023-03-31 14:07:17 +00:00
VERSION_WARNING = " Your plots may differ as the version of matplotlib ( {0} ), Python ( {1} ), or Samila ( {2} ) that you are using is not the same as the source. "
2022-04-30 14:19:40 +00:00
CALCULATION_EXCEPTION_WARNING = " The given functions are undefined at some points. Your plot may not be complete. "
2022-05-28 11:54:18 +00:00
BOTH_COLOR_COMPLEMENT_WARNING = " It is not possible to set color and bgcolor to ' complement ' at the same time! Both are automatically set to the previous or default selection. "
COLOR_NOT_FOUND_WARNING = " color ' {0} ' not found. Replacing it with ' {1} ' "
2021-10-22 10:19:21 +00:00
2021-09-28 11:46:15 +00:00
class Projection ( Enum ) :
2021-09-29 05:50:46 +00:00
"""
Samila Projection type class .
>> > projection = samila . Projection . POLAR
"""
2021-09-29 05:54:36 +00:00
2021-09-28 11:46:15 +00:00
DEFAULT = DEFAULT_PROJECTION
POLAR = " polar "
AITOFF = " aitoff "
HAMMER = " hammer "
LAMBERT = " lambert "
MOLLWEIDE = " mollweide "
2021-09-28 12:57:57 +00:00
RECTILINEAR = " rectilinear "
2022-04-26 13:06:19 +00:00
RANDOM = " random "
2021-12-14 15:13:34 +00:00
2022-11-05 22:16:28 +00:00
class Marker ( Enum ) :
"""
Samila Marker type class .
>> > marker = samila . Marker . POINT
"""
DEFAULT = DEFAULT_MARKER
POINT = " . "
PIXEL = " , "
CIRCLE = " o "
TRIANGLE_DOWN = " v "
TRIANGLE_UP = " ^ "
TRIANGLE_LEFT = " < "
TRIANGLE_RIGHT = " > "
TRI_DOWN = " 1 "
TRI_UP = " 2 "
TRI_LEFT = " 3 "
TRI_RIGHT = " 4 "
OCTAGON = " 8 "
SQUARE = " s "
PENTAGON = " p "
PLUS = " + "
PLUS_FILLED = " P "
STAR = " * "
HEXAGON_VERTICAL = " h "
HEXAGON_HORIZONTAL = " H "
X = " x "
X_FILLED = " X "
DIAMOND = " D "
DIAMON_THIN = " d "
VLINE = " | "
HLINE = " _ "
RANDOM = " random "
2022-04-17 05:42:49 +00:00
RANDOM_COEF_LIST = [
" random.uniform(-1,1) " ,
" random.gauss(0,1) " ,
" random.betavariate(1,1) " ,
" random.gammavariate(1,1) " ,
" random.lognormvariate(0,1) " ]
2021-12-18 19:08:31 +00:00
ELEMENTS_LIST = [
2023-01-19 08:39:33 +00:00
" {0} *math.exp( {1} ) " ,
2022-05-08 19:46:45 +00:00
" {0} *math.atan( {1} ) " ,
2022-04-17 05:42:49 +00:00
" {0} *math.asinh( {1} ) " ,
" {0} *math.acosh(abs( {1} )+1) " ,
" {0} *math.erf( {1} ) " ,
2022-01-25 08:09:40 +00:00
" {0} *math.sqrt(abs( {1} )) " ,
2022-01-25 08:38:07 +00:00
" {0} *math.log(abs( {1} )+1) " ,
2022-04-06 15:25:13 +00:00
" {0} *math.tanh( {1} ) " ,
2021-12-18 19:08:31 +00:00
" {0} *math.cos( {1} ) " ,
" {0} *math.sin( {1} ) " ,
2022-12-09 13:58:44 +00:00
" {0} *math.tan( {1} ) " ,
2021-12-18 19:08:31 +00:00
" {0} * {1} " ,
2023-01-19 08:39:33 +00:00
" {0} / {1} " ,
2021-12-18 19:08:31 +00:00
" {0} *abs( {1} ) " ,
" {0} *math.ceil( {1} ) " ,
" {0} *math.floor( {1} ) " ]
2021-12-14 15:13:34 +00:00
2021-12-18 19:08:31 +00:00
ARGUMENTS_LIST = [
" x*y " ,
" x " ,
" y " ,
2023-01-19 08:39:33 +00:00
" 1/x " ,
" 1/y " ,
" x/y " ,
2021-12-18 19:08:31 +00:00
" y-x " ,
" x-y " ,
" x+y " ,
2022-05-08 19:46:45 +00:00
" x**3 " ,
" y**3 " ,
2021-12-18 19:08:31 +00:00
" x**2 " ,
" y**2 " ,
" (x**2)*y " ,
" (y**2)*x " ,
2022-06-19 13:39:17 +00:00
" (y**2)+(x**2) " ,
" (y**2)-(x**2) " ,
2021-12-18 19:08:31 +00:00
" (x**2)*(y**3) " ,
" (x**3)*(y**2) " ,
" x*(y**3) " ,
" y*(x**3) " ]
2021-12-14 15:13:34 +00:00
2022-05-08 19:46:45 +00:00
OPERATORS_LIST = [ " + " , " - " , " * " , " / " ]
2022-12-09 13:58:44 +00:00
2023-01-19 08:39:33 +00:00
RANDOM_EQUATION_MAX_COMPLEXITY = len ( ELEMENTS_LIST ) + 1
RANDOM_EQUATION_MIN_COMPLEXITY = 1
RANDOM_EQUATION_FOF_MAX_DEPTH = 3
RANDOM_EQUATION_FOF_MIN_DEPTH = 1