mathai 0.6.1__py3-none-any.whl → 0.6.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mathai/base.py CHANGED
@@ -8,7 +8,7 @@ def contains_list_or_neg(node):
8
8
  return True
9
9
  return False
10
10
  class TreeNode:
11
- matmul = True
11
+ matmul = None
12
12
 
13
13
  def __init__(self, name, children=None):
14
14
  if children is None:
@@ -18,11 +18,11 @@ class TreeNode:
18
18
  children = copy.deepcopy(children)
19
19
  self.name = name
20
20
 
21
- if name == "f_add" or (name == "f_mul" and TreeNode.matmul):
21
+ if name == "f_add" or (name == "f_mul" and (TreeNode.matmul == True or TreeNode.matmul is None)):
22
22
  keyed = [(str_form(c), c) for c in children]
23
23
  self.children = [c for _, c in sorted(keyed)]
24
24
 
25
- elif name == "f_mul":
25
+ elif name == "f_mul" and TreeNode.matmul == False:
26
26
  sortable = []
27
27
  fixed = []
28
28
  for c in children:
@@ -291,7 +291,7 @@ def compute(eq):
291
291
  return values[0] - values[1]
292
292
  elif eq.name == "f_rad":
293
293
  return values[0] * math.pi / 180
294
- elif eq.name == "f_mul":
294
+ elif eq.name in ["f_wmul", "f_mul"]:
295
295
  result = 1.0
296
296
  for v in values:
297
297
  result *= v
mathai/matrix.py CHANGED
@@ -93,4 +93,9 @@ def fold_wmul(eq):
93
93
  def flat(eq):
94
94
  return flatten_tree(tree_form(str_form(eq).replace("f_w","f_")))
95
95
  def matrix_solve(eq):
96
- return flat(dowhile(eq, lambda x: fold_wmul(flat(x))))
96
+ if TreeNode.matmul == True:
97
+ TreeNode.matmul = False
98
+ eq = simplify(eq)
99
+ eq = flat(dowhile(eq, lambda x: fold_wmul(flat(x))))
100
+ TreeNode.matmul = True
101
+ return eq
mathai/parser.py CHANGED
@@ -33,7 +33,7 @@ grammar = """
33
33
  | comparison "<=" arithmetic -> le
34
34
  | comparison ">=" arithmetic -> ge
35
35
 
36
- ?arithmetic: arithmetic "+" term -> wadd
36
+ ?arithmetic: arithmetic "+" term -> add
37
37
  | arithmetic "-" term -> sub
38
38
  | term
39
39
 
@@ -130,7 +130,7 @@ def parse(equation, funclist=None):
130
130
  if tree_node.name == "pass_through":
131
131
  return fxchange(tree_node.children[0])
132
132
  return TreeNode(
133
- "f_" + tree_node.name if tree_node.name in tmp3 + ["limitpinf", "limit", "try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","wadd","sin","cos","tan","wmul","integrate","dif","pow","div","log","abs"] else "d_" + tree_node.name,
133
+ "f_" + tree_node.name if tree_node.name in tmp3 + ["limitpinf", "limit", "try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","add","sin","cos","tan","wmul","integrate","dif","pow","div","log","abs"] else "d_" + tree_node.name,
134
134
  [fxchange(child) for child in tree_node.children]
135
135
  )
136
136
 
@@ -153,6 +153,9 @@ def parse(equation, funclist=None):
153
153
  tree_node.children = [rfx(child) for child in tree_node.children]
154
154
  return tree_node
155
155
  tree_node = rfx(tree_node)
156
- tree_node = flatten_tree(tree_node, ["f_wmul","f_wadd"])
157
- tree_node = tree_form(str_form(tree_node).replace("f_w","f_"))
156
+ tree_node = flatten_tree(tree_node, ["f_wmul"])
157
+ if TreeNode.matmul == True:
158
+ TreeNode.matmul = False
159
+ tree_node = tree_form(str_form(tree_node).replace("f_w","f_"))
160
+ TreeNode.matmul = True
158
161
  return tree_node
mathai/simplify.py CHANGED
@@ -20,6 +20,7 @@ def clear_div(eq, denom):
20
20
  return tree_form("d_0"), True
21
21
  lst3 = []
22
22
  for item in lst:
23
+ print(str_form(item))
23
24
  if "v_" not in str_form(item) and compute(item) < 0:
24
25
  lst3.append(item)
25
26
  sign = denom
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.6.1
3
+ Version: 0.6.3
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -1,6 +1,6 @@
1
1
  mathai/__init__.py,sha256=gzddzgNCG3Bg5BnqrDYvO71SzK4hu9fbo4nGEaDaG5Q,1554
2
2
  mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
3
- mathai/base.py,sha256=MUkx3hdM6W6CYYrGMxKYbchxXlll0_7Q8e6SeoDWnGc,15474
3
+ mathai/base.py,sha256=_VIVHzJ2wYAJjPn7asNvrhlHOqTtOwUgmohvmA9pUso,15552
4
4
  mathai/bivariate_inequality.py,sha256=Da-A1kqVynR0tNOlEI7GSTf5T2vNkcF4etL9-EoyPJg,11415
5
5
  mathai/console.py,sha256=Sn58iwYE79MLEh67s8X3q6vZjw6g7f9XM1T8_dBBR2o,3048
6
6
  mathai/diff.py,sha256=RSTwlfeddvYXUDShCeRdcPjsmAS8Vf5OkYJAaUBPaiM,3060
@@ -12,17 +12,17 @@ mathai/inverse.py,sha256=ya7P8WjzfaAL3UXL7xqOh5GaIsXLDZ-F6lZFy3IEgaQ,2931
12
12
  mathai/limit.py,sha256=9F8i9UZh2xb-V8A5Sd1gdhDf9c2RFgpE1GdNn9MvbWI,5703
13
13
  mathai/linear.py,sha256=viGlPU8BPrjLWHlyNUvnfPHNH5d4ZBImiQMdyXaKGg0,5702
14
14
  mathai/logic.py,sha256=Ndz4Fd6aNCmzFlqoPyyIpSmV_BXmYHsurePjLyZJoNc,9809
15
- mathai/matrix.py,sha256=wp2EZ8Q-HmiyfH6OCUkXtTuWD4GM8kaKsUmypgubhtM,3182
15
+ mathai/matrix.py,sha256=atXZlgiDgqI3cRyQ78GrDCWiy7oWWelq-XHvC_kH_DE,3324
16
16
  mathai/ode.py,sha256=zxxTXAOpt7oSsfpgI4vHsCWKXevmM96ZOBZWWs-vj8Y,4801
17
- mathai/parser.py,sha256=wP3YMyRL_25ccfxudHdg0ebjsUFc6YBvYBGdxDBkZ6k,7129
17
+ mathai/parser.py,sha256=dhI4hRiYDdmSAOrhIWkBs_Boo2BFzC1m5cbAOOfHUas,7220
18
18
  mathai/parsetab.py,sha256=TL-4jvRM_Tx6ipwet8CFJc2DkjR4tGsbrGF_r4IC8xI,9651
19
19
  mathai/printeq.py,sha256=MKsR6-qXig80R07vLnFPYHQMeS41FrMVj3n3arrhJpQ,1329
20
- mathai/simplify.py,sha256=nvpwTLEgnGeXgc9NGGmQLAjKZ9c4XTdEVqAuo04oSrw,19588
20
+ mathai/simplify.py,sha256=HeZqQbB9SD7CAduvotQOiv4hFqGe68ZmNLl9LLJ7sAo,19619
21
21
  mathai/structure.py,sha256=wrU7kqphSN7CqaVffyHHXD2-3t5My_Z_TtYFoUe_lTU,4099
22
22
  mathai/tool.py,sha256=ozcXTXLbKUnyPM9r9kz9M43YA2CBcWezcqLZfEs8rpc,6051
23
23
  mathai/trig.py,sha256=fnBbfiopcQzFg4ya1BoO5M0X_aCBnse2bjnKh1juw4I,11223
24
24
  mathai/univariate_inequality.py,sha256=LPFdWgC1y5zBwnsy1wwZxj-yP_SbqFDhCmTTzhuwoiY,16469
25
- mathai-0.6.1.dist-info/METADATA,sha256=IhnedME2qfzhx0lg1z72oefVQKFjcHRYGJON58qwa_Q,7103
26
- mathai-0.6.1.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
27
- mathai-0.6.1.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
28
- mathai-0.6.1.dist-info/RECORD,,
25
+ mathai-0.6.3.dist-info/METADATA,sha256=ecYnPYus3Nd-KLLG3JOi3YCocVvzqff3iZwgecdebiM,7103
26
+ mathai-0.6.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
27
+ mathai-0.6.3.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
28
+ mathai-0.6.3.dist-info/RECORD,,
File without changes