-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.py
148 lines (116 loc) · 5.01 KB
/
library.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import readline
#LIBRARY OF FUNCTIONS AND INPUT ALIAS
#ALPHABET
A=""
B="x=sqrt((6-((y-3.85)3/2)^2)2/3)+1.25#2.6<y<5,x=sqrt(2/3(6-((y-1.2)3/2)^2))+1.5#0<y<2.6,y=0#0<x<2.82,y=5#0<x<2.65,x=0#0<y<5,x=1#1<y<2,x=1#3<y<4,x=2#1<y<2,x=2#3<y<4,y=4#1<x<2,y=3#1<x<2,y=2#1<x<2,y=1#1<x<2"
C="x=0#0<y<5,x=1#1<y<4,x=4#0<y<1,x=4#4<y<5,y=5#0<x<4,y=4#1<x<4,y=1#<1x<4,y=0#0<x<4"
D=""
E="y=5#0<x<4,y=4#1<x<4,y=3#1<x<3,y=2#1<x<3,y=1#1<x<4,y=0#0<x<4,x=0#0<y<5,x=1#3<y<4,x=1#1<y<2,x=3#2<y<3,x=4#4<y<5,x=4#0<y<1"
F="y=5#0<x<4,y=4#1<x<4,y=3#1<x<3,y=2#1<x<3,y=0#0<x<1,x=0#0<y<5,x=1#03<y<4,x=1#0<y<2,x=3#2<y<3,x=4#4<y<5"
G=""
H="y=5#0<x<1,y=5#3<x<4,y=3#1<x<3,y=2#1<x<3,y=0#0<x<1,y=0#3<x<4,x=0#0<y<5,x=1#3<y<5,x=1#0<y<2,x=3#3<y<5,x=3#0<y<2,x=4#0<y<5"
I=""
J=""
K=""
L="y=0#0<x<4,y=1#1<x<4,x=0#0<y<5,y=5#0<x<1,x=4#0<y<1,x=1#1<y<5"
M=""
N="y=5#0<x<1,y=5#3<x<4,y=0#3<x<4,y=0#0<x<1,x=0#0<y<5,x=4#0<y<5,x=1#0<y<4,x=3#1<y<5,y=-(2)x+7#1<x<3,y=-(2)x+6#1<x<3"
O=""
P=""
Q=""
R=""
S=""
T="y=5#0<x<4,y=4#0<x<1.5,y=4#2.5<x<4,x=1.5#0<y<4,x=2.5#0<y<4,y=0#1.5<x<2.5,x=0#4<y<5,x=4#4<y<5"
V=""
W=""
X=""
Y=""
Z="y=0#0<x<4,y=5#0<x<4,y=1#1<x<4,y=4#0<x<3,x=0#0<y<1,x=0#4<y<5,x=4#0<y<1,x=4#4<y<5,y=x+1#0<x<3,y=x#1<x<4"
letters = ['B','C','E','F','H','L','N','T','Z']
# # # # # # # # # # #
#LOGOS
batman="y=1.5sqrt((-abs(abs(x)-1))abs(3-abs(x))/((abs(x)-1)(3-abs(x))))(1+abs(abs(x)-3)/(abs(x)-3))sqrt(1-(x/7)^2)+(4.5+0.75(abs(x-0.5)+abs(x+0.5))-2.75(abs(x-0.75)+abs(x+0.75)))(1+abs(1-abs(x))/(1-abs(x))),y=(-3)sqrt(1-(x/7)^2)sqrt(abs(abs(x)-4)/(abs(x)-4)),y=abs(x/2)-0.0913722x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2),y=(2.71052+1.5-0.5abs(x)-1.35526sqrt(4-(abs(x)-1)^2))sqrt(abs(abs(x)-1)/(abs(x)-1))"
heart="y=sqrt(1-(abs(x)-1)^2)#-2<x<2,y=-3sqrt(1-(sqrt(abs(x)/2)))#-2<x<2"
logos = ['batman','heart']
# # # # # # # # # # #
def md_lib_updater(letters,logos):
""" auto update for markdown"""
letterstr = '`' + "`, `".join(letters) + '`'
logostr = '`' + "`, `".join(logos) + '`'
file = 'README.md'
with open(file, 'r') as f:
cont = f.read()
# print(cont)
newcont = ''
for line in cont.split('\n'):
if " - Letters: " in line:
line = " - Letters: {}".format(letterstr)
if " - Logos: " in line:
line = " - Logos: {}".format(logostr)
# print(line)
newcont = newcont+line+'\n'
with open(file, 'w') as f:
f.write(newcont)
md_lib_updater(letters,logos)
library_contents = letters + logos2
norm_func_tab_list = ['sin(','cos(','tan(','sqrt(','log(','log10(','arctan(','arccos(','arcsin(','abs(']
#############################################################
def set_tab_complete_options(options):
"""
allows user to tab complete inputs
"""
readline.parse_and_bind("tab: complete")
def complete(text,state):
if text:
results = [s for s in options if s and s.startswith(text)]
else:
results = results[:]
return results[state]
readline.set_completer(complete)
#############################################################
def alias_check(func_string):
"""allows user to put alias command, can defo smarten"""
#################################
mult_checks = [')(',
'0(','1(','2(','3(','4(','5(','6(','7(','8(','9(',
')0',')1',')2',')3',')4',')5',')6',')7',')8',')9',
')a',')c',')s']
import string
for letter in list(string.ascii_lowercase):
mult_checks.append('0'+letter)
mult_checks.append('1'+letter)
mult_checks.append('2'+letter)
mult_checks.append('3'+letter)
mult_checks.append('4'+letter)
mult_checks.append('5'+letter)
mult_checks.append('6'+letter)
mult_checks.append('7'+letter)
mult_checks.append('8'+letter)
mult_checks.append('9'+letter)
mult_checks.append(')'+letter)
for check in mult_checks:
if check in func_string:
func_string = func_string.replace(check,check[0]+'*'+check[1])
#################################
# currently breaks batman funciton?
# neg_checks = []
# for letter in list(string.ascii_lowercase):
# neg_checks.append('-'+letter)
# for check in neg_checks:
# if check in func_string:
# func_string = func_string.replace(check,check[0]+'-1*'+check[1])
log10_checks=['log10_']
for check in log10_checks:
if check in func_string:
func_string = func_string.replace(check,'log10')
#################################
power_checks = ['^']
for check in power_checks:
if check in func_string:
func_string = func_string.replace(check,'**')
#################################
comp_checks = [' i','i ','+i','i+','*i','i*','/i','i/','-i','i-']
for check in comp_checks:
if check in func_string:
func_string = func_string.replace(check,'1j')
return func_string