ZTWHHH commited on
Commit
6f7a7d7
·
verified ·
1 Parent(s): e8e852c

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__init__.py +0 -0
  2. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__pycache__/__init__.cpython-310.pyc +0 -0
  3. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__pycache__/bench_matrix.cpython-310.pyc +0 -0
  4. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/bench_matrix.py +21 -0
  5. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/__init__.cpython-310.pyc +0 -0
  6. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/_shape.cpython-310.pyc +0 -0
  7. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/adjoint.cpython-310.pyc +0 -0
  8. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/applyfunc.cpython-310.pyc +0 -0
  9. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/blockmatrix.cpython-310.pyc +0 -0
  10. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/companion.cpython-310.pyc +0 -0
  11. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/determinant.cpython-310.pyc +0 -0
  12. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/diagonal.cpython-310.pyc +0 -0
  13. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/dotproduct.cpython-310.pyc +0 -0
  14. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/factorizations.cpython-310.pyc +0 -0
  15. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/fourier.cpython-310.pyc +0 -0
  16. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/funcmatrix.cpython-310.pyc +0 -0
  17. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/hadamard.cpython-310.pyc +0 -0
  18. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/inverse.cpython-310.pyc +0 -0
  19. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/kronecker.cpython-310.pyc +0 -0
  20. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matadd.cpython-310.pyc +0 -0
  21. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matexpr.cpython-310.pyc +0 -0
  22. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matpow.cpython-310.pyc +0 -0
  23. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/permutation.cpython-310.pyc +0 -0
  24. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/sets.cpython-310.pyc +0 -0
  25. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/slice.cpython-310.pyc +0 -0
  26. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/special.cpython-310.pyc +0 -0
  27. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/trace.cpython-310.pyc +0 -0
  28. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  29. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_diagonal.cpython-310.pyc +0 -0
  30. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_inverse.cpython-310.pyc +0 -0
  31. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_matadd.cpython-310.pyc +0 -0
  32. mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_transpose.cpython-310.pyc +0 -0
  33. mplug_owl2/lib/python3.10/site-packages/sympy/unify/__init__.py +15 -0
  34. mplug_owl2/lib/python3.10/site-packages/sympy/unify/core.py +234 -0
  35. mplug_owl2/lib/python3.10/site-packages/sympy/unify/rewrite.py +55 -0
  36. mplug_owl2/lib/python3.10/site-packages/sympy/unify/tests/__init__.py +0 -0
  37. mplug_owl2/lib/python3.10/site-packages/sympy/unify/tests/test_unify.py +88 -0
  38. mplug_owl2/lib/python3.10/site-packages/sympy/unify/usympy.py +124 -0
  39. pllava/share/terminfo/t/t1061 +0 -0
  40. pllava/share/terminfo/t/t1061f +0 -0
  41. pllava/share/terminfo/t/t653x +0 -0
  42. pllava/share/terminfo/t/tek4025ex +0 -0
  43. pllava/share/terminfo/t/tek4105-30 +0 -0
  44. pllava/share/terminfo/t/tek4109 +0 -0
  45. pllava/share/terminfo/t/tek4109brl +0 -0
  46. pllava/share/terminfo/t/tek4207 +0 -0
  47. pllava/share/terminfo/t/teken-2022 +0 -0
  48. pllava/share/terminfo/t/teleray +0 -0
  49. pllava/share/terminfo/t/terminet1200 +0 -0
  50. pllava/share/terminfo/t/terminet300 +0 -0
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__init__.py ADDED
File without changes
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (181 Bytes). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/__pycache__/bench_matrix.cpython-310.pyc ADDED
Binary file (889 Bytes). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/benchmarks/bench_matrix.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sympy.core.numbers import Integer
2
+ from sympy.matrices.dense import (eye, zeros)
3
+
4
+ i3 = Integer(3)
5
+ M = eye(100)
6
+
7
+
8
+ def timeit_Matrix__getitem_ii():
9
+ M[3, 3]
10
+
11
+
12
+ def timeit_Matrix__getitem_II():
13
+ M[i3, i3]
14
+
15
+
16
+ def timeit_Matrix__getslice():
17
+ M[:, :]
18
+
19
+
20
+ def timeit_Matrix_zeronm():
21
+ zeros(100, 100)
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.77 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/_shape.cpython-310.pyc ADDED
Binary file (4.25 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/adjoint.cpython-310.pyc ADDED
Binary file (2.41 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/applyfunc.cpython-310.pyc ADDED
Binary file (5.51 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/blockmatrix.cpython-310.pyc ADDED
Binary file (33.9 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/companion.cpython-310.pyc ADDED
Binary file (2.21 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/determinant.cpython-310.pyc ADDED
Binary file (4.09 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/diagonal.cpython-310.pyc ADDED
Binary file (7.06 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/dotproduct.cpython-310.pyc ADDED
Binary file (2.03 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/factorizations.cpython-310.pyc ADDED
Binary file (3.38 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/fourier.cpython-310.pyc ADDED
Binary file (3.07 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/funcmatrix.cpython-310.pyc ADDED
Binary file (4.23 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/hadamard.cpython-310.pyc ADDED
Binary file (14.2 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/inverse.cpython-310.pyc ADDED
Binary file (3.75 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/kronecker.cpython-310.pyc ADDED
Binary file (16.4 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matadd.cpython-310.pyc ADDED
Binary file (6.91 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matexpr.cpython-310.pyc ADDED
Binary file (30.1 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/matpow.cpython-310.pyc ADDED
Binary file (5.23 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/permutation.cpython-310.pyc ADDED
Binary file (7.66 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/sets.cpython-310.pyc ADDED
Binary file (2.83 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/slice.cpython-310.pyc ADDED
Binary file (3.55 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/special.cpython-310.pyc ADDED
Binary file (10.7 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/__pycache__/trace.cpython-310.pyc ADDED
Binary file (4.83 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (188 Bytes). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_diagonal.cpython-310.pyc ADDED
Binary file (4.37 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_inverse.cpython-310.pyc ADDED
Binary file (3.01 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_matadd.cpython-310.pyc ADDED
Binary file (3.13 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/matrices/expressions/tests/__pycache__/test_transpose.cpython-310.pyc ADDED
Binary file (2.65 kB). View file
 
mplug_owl2/lib/python3.10/site-packages/sympy/unify/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Unification in SymPy
2
+
3
+ See sympy.unify.core docstring for algorithmic details
4
+
5
+ See http://matthewrocklin.com/blog/work/2012/11/01/Unification/ for discussion
6
+ """
7
+
8
+ from .usympy import unify, rebuild
9
+ from .rewrite import rewriterule
10
+
11
+ __all__ = [
12
+ 'unify', 'rebuild',
13
+
14
+ 'rewriterule',
15
+ ]
mplug_owl2/lib/python3.10/site-packages/sympy/unify/core.py ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Generic Unification algorithm for expression trees with lists of children
2
+
3
+ This implementation is a direct translation of
4
+
5
+ Artificial Intelligence: A Modern Approach by Stuart Russel and Peter Norvig
6
+ Second edition, section 9.2, page 276
7
+
8
+ It is modified in the following ways:
9
+
10
+ 1. We allow associative and commutative Compound expressions. This results in
11
+ combinatorial blowup.
12
+ 2. We explore the tree lazily.
13
+ 3. We provide generic interfaces to symbolic algebra libraries in Python.
14
+
15
+ A more traditional version can be found here
16
+ http://aima.cs.berkeley.edu/python/logic.html
17
+ """
18
+
19
+ from sympy.utilities.iterables import kbins
20
+
21
+ class Compound:
22
+ """ A little class to represent an interior node in the tree
23
+
24
+ This is analogous to SymPy.Basic for non-Atoms
25
+ """
26
+ def __init__(self, op, args):
27
+ self.op = op
28
+ self.args = args
29
+
30
+ def __eq__(self, other):
31
+ return (type(self) is type(other) and self.op == other.op and
32
+ self.args == other.args)
33
+
34
+ def __hash__(self):
35
+ return hash((type(self), self.op, self.args))
36
+
37
+ def __str__(self):
38
+ return "%s[%s]" % (str(self.op), ', '.join(map(str, self.args)))
39
+
40
+ class Variable:
41
+ """ A Wild token """
42
+ def __init__(self, arg):
43
+ self.arg = arg
44
+
45
+ def __eq__(self, other):
46
+ return type(self) is type(other) and self.arg == other.arg
47
+
48
+ def __hash__(self):
49
+ return hash((type(self), self.arg))
50
+
51
+ def __str__(self):
52
+ return "Variable(%s)" % str(self.arg)
53
+
54
+ class CondVariable:
55
+ """ A wild token that matches conditionally.
56
+
57
+ arg - a wild token.
58
+ valid - an additional constraining function on a match.
59
+ """
60
+ def __init__(self, arg, valid):
61
+ self.arg = arg
62
+ self.valid = valid
63
+
64
+ def __eq__(self, other):
65
+ return (type(self) is type(other) and
66
+ self.arg == other.arg and
67
+ self.valid == other.valid)
68
+
69
+ def __hash__(self):
70
+ return hash((type(self), self.arg, self.valid))
71
+
72
+ def __str__(self):
73
+ return "CondVariable(%s)" % str(self.arg)
74
+
75
+ def unify(x, y, s=None, **fns):
76
+ """ Unify two expressions.
77
+
78
+ Parameters
79
+ ==========
80
+
81
+ x, y - expression trees containing leaves, Compounds and Variables.
82
+ s - a mapping of variables to subtrees.
83
+
84
+ Returns
85
+ =======
86
+
87
+ lazy sequence of mappings {Variable: subtree}
88
+
89
+ Examples
90
+ ========
91
+
92
+ >>> from sympy.unify.core import unify, Compound, Variable
93
+ >>> expr = Compound("Add", ("x", "y"))
94
+ >>> pattern = Compound("Add", ("x", Variable("a")))
95
+ >>> next(unify(expr, pattern, {}))
96
+ {Variable(a): 'y'}
97
+ """
98
+ s = s or {}
99
+
100
+ if x == y:
101
+ yield s
102
+ elif isinstance(x, (Variable, CondVariable)):
103
+ yield from unify_var(x, y, s, **fns)
104
+ elif isinstance(y, (Variable, CondVariable)):
105
+ yield from unify_var(y, x, s, **fns)
106
+ elif isinstance(x, Compound) and isinstance(y, Compound):
107
+ is_commutative = fns.get('is_commutative', lambda x: False)
108
+ is_associative = fns.get('is_associative', lambda x: False)
109
+ for sop in unify(x.op, y.op, s, **fns):
110
+ if is_associative(x) and is_associative(y):
111
+ a, b = (x, y) if len(x.args) < len(y.args) else (y, x)
112
+ if is_commutative(x) and is_commutative(y):
113
+ combs = allcombinations(a.args, b.args, 'commutative')
114
+ else:
115
+ combs = allcombinations(a.args, b.args, 'associative')
116
+ for aaargs, bbargs in combs:
117
+ aa = [unpack(Compound(a.op, arg)) for arg in aaargs]
118
+ bb = [unpack(Compound(b.op, arg)) for arg in bbargs]
119
+ yield from unify(aa, bb, sop, **fns)
120
+ elif len(x.args) == len(y.args):
121
+ yield from unify(x.args, y.args, sop, **fns)
122
+
123
+ elif is_args(x) and is_args(y) and len(x) == len(y):
124
+ if len(x) == 0:
125
+ yield s
126
+ else:
127
+ for shead in unify(x[0], y[0], s, **fns):
128
+ yield from unify(x[1:], y[1:], shead, **fns)
129
+
130
+ def unify_var(var, x, s, **fns):
131
+ if var in s:
132
+ yield from unify(s[var], x, s, **fns)
133
+ elif occur_check(var, x):
134
+ pass
135
+ elif isinstance(var, CondVariable) and var.valid(x):
136
+ yield assoc(s, var, x)
137
+ elif isinstance(var, Variable):
138
+ yield assoc(s, var, x)
139
+
140
+ def occur_check(var, x):
141
+ """ var occurs in subtree owned by x? """
142
+ if var == x:
143
+ return True
144
+ elif isinstance(x, Compound):
145
+ return occur_check(var, x.args)
146
+ elif is_args(x):
147
+ if any(occur_check(var, xi) for xi in x): return True
148
+ return False
149
+
150
+ def assoc(d, key, val):
151
+ """ Return copy of d with key associated to val """
152
+ d = d.copy()
153
+ d[key] = val
154
+ return d
155
+
156
+ def is_args(x):
157
+ """ Is x a traditional iterable? """
158
+ return type(x) in (tuple, list, set)
159
+
160
+ def unpack(x):
161
+ if isinstance(x, Compound) and len(x.args) == 1:
162
+ return x.args[0]
163
+ else:
164
+ return x
165
+
166
+ def allcombinations(A, B, ordered):
167
+ """
168
+ Restructure A and B to have the same number of elements.
169
+
170
+ Parameters
171
+ ==========
172
+
173
+ ordered must be either 'commutative' or 'associative'.
174
+
175
+ A and B can be rearranged so that the larger of the two lists is
176
+ reorganized into smaller sublists.
177
+
178
+ Examples
179
+ ========
180
+
181
+ >>> from sympy.unify.core import allcombinations
182
+ >>> for x in allcombinations((1, 2, 3), (5, 6), 'associative'): print(x)
183
+ (((1,), (2, 3)), ((5,), (6,)))
184
+ (((1, 2), (3,)), ((5,), (6,)))
185
+
186
+ >>> for x in allcombinations((1, 2, 3), (5, 6), 'commutative'): print(x)
187
+ (((1,), (2, 3)), ((5,), (6,)))
188
+ (((1, 2), (3,)), ((5,), (6,)))
189
+ (((1,), (3, 2)), ((5,), (6,)))
190
+ (((1, 3), (2,)), ((5,), (6,)))
191
+ (((2,), (1, 3)), ((5,), (6,)))
192
+ (((2, 1), (3,)), ((5,), (6,)))
193
+ (((2,), (3, 1)), ((5,), (6,)))
194
+ (((2, 3), (1,)), ((5,), (6,)))
195
+ (((3,), (1, 2)), ((5,), (6,)))
196
+ (((3, 1), (2,)), ((5,), (6,)))
197
+ (((3,), (2, 1)), ((5,), (6,)))
198
+ (((3, 2), (1,)), ((5,), (6,)))
199
+ """
200
+
201
+ if ordered == "commutative":
202
+ ordered = 11
203
+ if ordered == "associative":
204
+ ordered = None
205
+ sm, bg = (A, B) if len(A) < len(B) else (B, A)
206
+ for part in kbins(list(range(len(bg))), len(sm), ordered=ordered):
207
+ if bg == B:
208
+ yield tuple((a,) for a in A), partition(B, part)
209
+ else:
210
+ yield partition(A, part), tuple((b,) for b in B)
211
+
212
+ def partition(it, part):
213
+ """ Partition a tuple/list into pieces defined by indices.
214
+
215
+ Examples
216
+ ========
217
+
218
+ >>> from sympy.unify.core import partition
219
+ >>> partition((10, 20, 30, 40), [[0, 1, 2], [3]])
220
+ ((10, 20, 30), (40,))
221
+ """
222
+ return type(it)([index(it, ind) for ind in part])
223
+
224
+ def index(it, ind):
225
+ """ Fancy indexing into an indexable iterable (tuple, list).
226
+
227
+ Examples
228
+ ========
229
+
230
+ >>> from sympy.unify.core import index
231
+ >>> index([10, 20, 30], (1, 2, 0))
232
+ [20, 30, 10]
233
+ """
234
+ return type(it)([it[i] for i in ind])
mplug_owl2/lib/python3.10/site-packages/sympy/unify/rewrite.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Functions to support rewriting of SymPy expressions """
2
+
3
+ from sympy.core.expr import Expr
4
+ from sympy.assumptions import ask
5
+ from sympy.strategies.tools import subs
6
+ from sympy.unify.usympy import rebuild, unify
7
+
8
+ def rewriterule(source, target, variables=(), condition=None, assume=None):
9
+ """ Rewrite rule.
10
+
11
+ Transform expressions that match source into expressions that match target
12
+ treating all ``variables`` as wilds.
13
+
14
+ Examples
15
+ ========
16
+
17
+ >>> from sympy.abc import w, x, y, z
18
+ >>> from sympy.unify.rewrite import rewriterule
19
+ >>> from sympy import default_sort_key
20
+ >>> rl = rewriterule(x + y, x**y, [x, y])
21
+ >>> sorted(rl(z + 3), key=default_sort_key)
22
+ [3**z, z**3]
23
+
24
+ Use ``condition`` to specify additional requirements. Inputs are taken in
25
+ the same order as is found in variables.
26
+
27
+ >>> rl = rewriterule(x + y, x**y, [x, y], lambda x, y: x.is_integer)
28
+ >>> list(rl(z + 3))
29
+ [3**z]
30
+
31
+ Use ``assume`` to specify additional requirements using new assumptions.
32
+
33
+ >>> from sympy.assumptions import Q
34
+ >>> rl = rewriterule(x + y, x**y, [x, y], assume=Q.integer(x))
35
+ >>> list(rl(z + 3))
36
+ [3**z]
37
+
38
+ Assumptions for the local context are provided at rule runtime
39
+
40
+ >>> list(rl(w + z, Q.integer(z)))
41
+ [z**w]
42
+ """
43
+
44
+ def rewrite_rl(expr, assumptions=True):
45
+ for match in unify(source, expr, {}, variables=variables):
46
+ if (condition and
47
+ not condition(*[match.get(var, var) for var in variables])):
48
+ continue
49
+ if (assume and not ask(assume.xreplace(match), assumptions)):
50
+ continue
51
+ expr2 = subs(match)(target)
52
+ if isinstance(expr2, Expr):
53
+ expr2 = rebuild(expr2)
54
+ yield expr2
55
+ return rewrite_rl
mplug_owl2/lib/python3.10/site-packages/sympy/unify/tests/__init__.py ADDED
File without changes
mplug_owl2/lib/python3.10/site-packages/sympy/unify/tests/test_unify.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sympy.unify.core import Compound, Variable, CondVariable, allcombinations
2
+ from sympy.unify import core
3
+
4
+ a,b,c = 'a', 'b', 'c'
5
+ w,x,y,z = map(Variable, 'wxyz')
6
+
7
+ C = Compound
8
+
9
+ def is_associative(x):
10
+ return isinstance(x, Compound) and (x.op in ('Add', 'Mul', 'CAdd', 'CMul'))
11
+ def is_commutative(x):
12
+ return isinstance(x, Compound) and (x.op in ('CAdd', 'CMul'))
13
+
14
+
15
+ def unify(a, b, s={}):
16
+ return core.unify(a, b, s=s, is_associative=is_associative,
17
+ is_commutative=is_commutative)
18
+
19
+ def test_basic():
20
+ assert list(unify(a, x, {})) == [{x: a}]
21
+ assert list(unify(a, x, {x: 10})) == []
22
+ assert list(unify(1, x, {})) == [{x: 1}]
23
+ assert list(unify(a, a, {})) == [{}]
24
+ assert list(unify((w, x), (y, z), {})) == [{w: y, x: z}]
25
+ assert list(unify(x, (a, b), {})) == [{x: (a, b)}]
26
+
27
+ assert list(unify((a, b), (x, x), {})) == []
28
+ assert list(unify((y, z), (x, x), {}))!= []
29
+ assert list(unify((a, (b, c)), (a, (x, y)), {})) == [{x: b, y: c}]
30
+
31
+ def test_ops():
32
+ assert list(unify(C('Add', (a,b,c)), C('Add', (a,x,y)), {})) == \
33
+ [{x:b, y:c}]
34
+ assert list(unify(C('Add', (C('Mul', (1,2)), b,c)), C('Add', (x,y,c)), {})) == \
35
+ [{x: C('Mul', (1,2)), y:b}]
36
+
37
+ def test_associative():
38
+ c1 = C('Add', (1,2,3))
39
+ c2 = C('Add', (x,y))
40
+ assert tuple(unify(c1, c2, {})) == ({x: 1, y: C('Add', (2, 3))},
41
+ {x: C('Add', (1, 2)), y: 3})
42
+
43
+ def test_commutative():
44
+ c1 = C('CAdd', (1,2,3))
45
+ c2 = C('CAdd', (x,y))
46
+ result = list(unify(c1, c2, {}))
47
+ assert {x: 1, y: C('CAdd', (2, 3))} in result
48
+ assert ({x: 2, y: C('CAdd', (1, 3))} in result or
49
+ {x: 2, y: C('CAdd', (3, 1))} in result)
50
+
51
+ def _test_combinations_assoc():
52
+ assert set(allcombinations((1,2,3), (a,b), True)) == \
53
+ {(((1, 2), (3,)), (a, b)), (((1,), (2, 3)), (a, b))}
54
+
55
+ def _test_combinations_comm():
56
+ assert set(allcombinations((1,2,3), (a,b), None)) == \
57
+ {(((1,), (2, 3)), ('a', 'b')), (((2,), (3, 1)), ('a', 'b')),
58
+ (((3,), (1, 2)), ('a', 'b')), (((1, 2), (3,)), ('a', 'b')),
59
+ (((2, 3), (1,)), ('a', 'b')), (((3, 1), (2,)), ('a', 'b'))}
60
+
61
+ def test_allcombinations():
62
+ assert set(allcombinations((1,2), (1,2), 'commutative')) ==\
63
+ {(((1,),(2,)), ((1,),(2,))), (((1,),(2,)), ((2,),(1,)))}
64
+
65
+
66
+ def test_commutativity():
67
+ c1 = Compound('CAdd', (a, b))
68
+ c2 = Compound('CAdd', (x, y))
69
+ assert is_commutative(c1) and is_commutative(c2)
70
+ assert len(list(unify(c1, c2, {}))) == 2
71
+
72
+
73
+ def test_CondVariable():
74
+ expr = C('CAdd', (1, 2))
75
+ x = Variable('x')
76
+ y = CondVariable('y', lambda a: a % 2 == 0)
77
+ z = CondVariable('z', lambda a: a > 3)
78
+ pattern = C('CAdd', (x, y))
79
+ assert list(unify(expr, pattern, {})) == \
80
+ [{x: 1, y: 2}]
81
+
82
+ z = CondVariable('z', lambda a: a > 3)
83
+ pattern = C('CAdd', (z, y))
84
+
85
+ assert list(unify(expr, pattern, {})) == []
86
+
87
+ def test_defaultdict():
88
+ assert next(unify(Variable('x'), 'foo')) == {Variable('x'): 'foo'}
mplug_owl2/lib/python3.10/site-packages/sympy/unify/usympy.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ SymPy interface to Unification engine
2
+
3
+ See sympy.unify for module level docstring
4
+ See sympy.unify.core for algorithmic docstring """
5
+
6
+ from sympy.core import Basic, Add, Mul, Pow
7
+ from sympy.core.operations import AssocOp, LatticeOp
8
+ from sympy.matrices import MatAdd, MatMul, MatrixExpr
9
+ from sympy.sets.sets import Union, Intersection, FiniteSet
10
+ from sympy.unify.core import Compound, Variable, CondVariable
11
+ from sympy.unify import core
12
+
13
+ basic_new_legal = [MatrixExpr]
14
+ eval_false_legal = [AssocOp, Pow, FiniteSet]
15
+ illegal = [LatticeOp]
16
+
17
+ def sympy_associative(op):
18
+ assoc_ops = (AssocOp, MatAdd, MatMul, Union, Intersection, FiniteSet)
19
+ return any(issubclass(op, aop) for aop in assoc_ops)
20
+
21
+ def sympy_commutative(op):
22
+ comm_ops = (Add, MatAdd, Union, Intersection, FiniteSet)
23
+ return any(issubclass(op, cop) for cop in comm_ops)
24
+
25
+ def is_associative(x):
26
+ return isinstance(x, Compound) and sympy_associative(x.op)
27
+
28
+ def is_commutative(x):
29
+ if not isinstance(x, Compound):
30
+ return False
31
+ if sympy_commutative(x.op):
32
+ return True
33
+ if issubclass(x.op, Mul):
34
+ return all(construct(arg).is_commutative for arg in x.args)
35
+
36
+ def mk_matchtype(typ):
37
+ def matchtype(x):
38
+ return (isinstance(x, typ) or
39
+ isinstance(x, Compound) and issubclass(x.op, typ))
40
+ return matchtype
41
+
42
+ def deconstruct(s, variables=()):
43
+ """ Turn a SymPy object into a Compound """
44
+ if s in variables:
45
+ return Variable(s)
46
+ if isinstance(s, (Variable, CondVariable)):
47
+ return s
48
+ if not isinstance(s, Basic) or s.is_Atom:
49
+ return s
50
+ return Compound(s.__class__,
51
+ tuple(deconstruct(arg, variables) for arg in s.args))
52
+
53
+ def construct(t):
54
+ """ Turn a Compound into a SymPy object """
55
+ if isinstance(t, (Variable, CondVariable)):
56
+ return t.arg
57
+ if not isinstance(t, Compound):
58
+ return t
59
+ if any(issubclass(t.op, cls) for cls in eval_false_legal):
60
+ return t.op(*map(construct, t.args), evaluate=False)
61
+ elif any(issubclass(t.op, cls) for cls in basic_new_legal):
62
+ return Basic.__new__(t.op, *map(construct, t.args))
63
+ else:
64
+ return t.op(*map(construct, t.args))
65
+
66
+ def rebuild(s):
67
+ """ Rebuild a SymPy expression.
68
+
69
+ This removes harm caused by Expr-Rules interactions.
70
+ """
71
+ return construct(deconstruct(s))
72
+
73
+ def unify(x, y, s=None, variables=(), **kwargs):
74
+ """ Structural unification of two expressions/patterns.
75
+
76
+ Examples
77
+ ========
78
+
79
+ >>> from sympy.unify.usympy import unify
80
+ >>> from sympy import Basic, S
81
+ >>> from sympy.abc import x, y, z, p, q
82
+
83
+ >>> next(unify(Basic(S(1), S(2)), Basic(S(1), x), variables=[x]))
84
+ {x: 2}
85
+
86
+ >>> expr = 2*x + y + z
87
+ >>> pattern = 2*p + q
88
+ >>> next(unify(expr, pattern, {}, variables=(p, q)))
89
+ {p: x, q: y + z}
90
+
91
+ Unification supports commutative and associative matching
92
+
93
+ >>> expr = x + y + z
94
+ >>> pattern = p + q
95
+ >>> len(list(unify(expr, pattern, {}, variables=(p, q))))
96
+ 12
97
+
98
+ Symbols not indicated to be variables are treated as literal,
99
+ else they are wild-like and match anything in a sub-expression.
100
+
101
+ >>> expr = x*y*z + 3
102
+ >>> pattern = x*y + 3
103
+ >>> next(unify(expr, pattern, {}, variables=[x, y]))
104
+ {x: y, y: x*z}
105
+
106
+ The x and y of the pattern above were in a Mul and matched factors
107
+ in the Mul of expr. Here, a single symbol matches an entire term:
108
+
109
+ >>> expr = x*y + 3
110
+ >>> pattern = p + 3
111
+ >>> next(unify(expr, pattern, {}, variables=[p]))
112
+ {p: x*y}
113
+
114
+ """
115
+ decons = lambda x: deconstruct(x, variables)
116
+ s = s or {}
117
+ s = {decons(k): decons(v) for k, v in s.items()}
118
+
119
+ ds = core.unify(decons(x), decons(y), s,
120
+ is_associative=is_associative,
121
+ is_commutative=is_commutative,
122
+ **kwargs)
123
+ for d in ds:
124
+ yield {construct(k): construct(v) for k, v in d.items()}
pllava/share/terminfo/t/t1061 ADDED
Binary file (566 Bytes). View file
 
pllava/share/terminfo/t/t1061f ADDED
Binary file (556 Bytes). View file
 
pllava/share/terminfo/t/t653x ADDED
Binary file (467 Bytes). View file
 
pllava/share/terminfo/t/tek4025ex ADDED
Binary file (681 Bytes). View file
 
pllava/share/terminfo/t/tek4105-30 ADDED
Binary file (1.16 kB). View file
 
pllava/share/terminfo/t/tek4109 ADDED
Binary file (691 Bytes). View file
 
pllava/share/terminfo/t/tek4109brl ADDED
Binary file (920 Bytes). View file
 
pllava/share/terminfo/t/tek4207 ADDED
Binary file (657 Bytes). View file
 
pllava/share/terminfo/t/teken-2022 ADDED
Binary file (1.25 kB). View file
 
pllava/share/terminfo/t/teleray ADDED
Binary file (566 Bytes). View file
 
pllava/share/terminfo/t/terminet1200 ADDED
Binary file (384 Bytes). View file
 
pllava/share/terminfo/t/terminet300 ADDED
Binary file (384 Bytes). View file