mathjson-solver 1.6.0__tar.gz → 1.7.0__tar.gz
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.
- {mathjson-solver-1.6.0/src/mathjson_solver.egg-info → mathjson_solver-1.7.0}/PKG-INFO +24 -1
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/README.md +23 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/setup.cfg +1 -1
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/setup.py +1 -1
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver/__main__.py +21 -2
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0/src/mathjson_solver.egg-info}/PKG-INFO +24 -1
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/tests/test_with_pytest.py +8 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/LICENSE +0 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/pyproject.toml +0 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver/__init__.py +0 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver.egg-info/SOURCES.txt +0 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver.egg-info/dependency_links.txt +0 -0
- {mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mathjson-solver
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Utilities for MathJSON evaluation
|
|
5
5
|
Home-page: https://github.com/LongenesisLtd/mathjson-solver
|
|
6
6
|
Author: Martins Mednis
|
|
@@ -97,9 +97,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
97
97
|
* `LessEqual`
|
|
98
98
|
* `NotEqual`
|
|
99
99
|
|
|
100
|
+
### Membership operators
|
|
101
|
+
* `In`
|
|
102
|
+
* `NotIn`
|
|
103
|
+
* `ContainsAnyOf`
|
|
104
|
+
* `ContainsAllOf`
|
|
105
|
+
* `ContainsNoneOf`
|
|
106
|
+
|
|
100
107
|
### Typecasting
|
|
108
|
+
* `Str`
|
|
101
109
|
* `Int`
|
|
102
110
|
* `Float`
|
|
111
|
+
* `Not`
|
|
103
112
|
|
|
104
113
|
### Additional constructs
|
|
105
114
|
* `Constants`
|
|
@@ -135,6 +144,8 @@ We welcome your contributions in the form of pull requests.
|
|
|
135
144
|
["Max", ["Array", 1, 2, ["Sum", 2, 4, 3], 5, 2]] # 9
|
|
136
145
|
["Median", ["Array", 1, 2, 3, 5, 2]] # 2
|
|
137
146
|
["Average", ["Array", 1, 2, 3, 5, 2]] # 2.6
|
|
147
|
+
["Average", ["Array"]] # None
|
|
148
|
+
|
|
138
149
|
["Length", ["Array", 1, 2, 3, 5, 2, 9]] # 6
|
|
139
150
|
["Length", ["Array"]] # 0
|
|
140
151
|
["Any", ["Array", 0, 0, False, 0, 0]] # False
|
|
@@ -145,6 +156,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
145
156
|
["Int", "12"] # 12
|
|
146
157
|
["Int", "12.2"] # 12
|
|
147
158
|
["Float", "12.2"] # 12.2
|
|
159
|
+
["Str", 12] # "12"
|
|
160
|
+
["Str", "12"] # "12"
|
|
161
|
+
["Str", "aabb"] # "aabb"
|
|
162
|
+
["Not", True] # False
|
|
163
|
+
["Not", 0] # True
|
|
164
|
+
|
|
165
|
+
["In", 2, ["Array", 1, 2, 3]] # True
|
|
166
|
+
["In", 4, ["Array", 1, 2, 3]] # False
|
|
167
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 3, 4, 5, 6]] # True
|
|
168
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 4, 5, 6]] # False
|
|
169
|
+
["ContainsAllOf", ["Array", 1, 2, 3], ["Array", 1, 2, 3]] # True
|
|
170
|
+
["ContainsAllOf", ["Array", 1, 2], ["Array", 1, 2, 3]] # False
|
|
148
171
|
```
|
|
149
172
|
|
|
150
173
|
### Constants
|
|
@@ -82,9 +82,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
82
82
|
* `LessEqual`
|
|
83
83
|
* `NotEqual`
|
|
84
84
|
|
|
85
|
+
### Membership operators
|
|
86
|
+
* `In`
|
|
87
|
+
* `NotIn`
|
|
88
|
+
* `ContainsAnyOf`
|
|
89
|
+
* `ContainsAllOf`
|
|
90
|
+
* `ContainsNoneOf`
|
|
91
|
+
|
|
85
92
|
### Typecasting
|
|
93
|
+
* `Str`
|
|
86
94
|
* `Int`
|
|
87
95
|
* `Float`
|
|
96
|
+
* `Not`
|
|
88
97
|
|
|
89
98
|
### Additional constructs
|
|
90
99
|
* `Constants`
|
|
@@ -120,6 +129,8 @@ We welcome your contributions in the form of pull requests.
|
|
|
120
129
|
["Max", ["Array", 1, 2, ["Sum", 2, 4, 3], 5, 2]] # 9
|
|
121
130
|
["Median", ["Array", 1, 2, 3, 5, 2]] # 2
|
|
122
131
|
["Average", ["Array", 1, 2, 3, 5, 2]] # 2.6
|
|
132
|
+
["Average", ["Array"]] # None
|
|
133
|
+
|
|
123
134
|
["Length", ["Array", 1, 2, 3, 5, 2, 9]] # 6
|
|
124
135
|
["Length", ["Array"]] # 0
|
|
125
136
|
["Any", ["Array", 0, 0, False, 0, 0]] # False
|
|
@@ -130,6 +141,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
130
141
|
["Int", "12"] # 12
|
|
131
142
|
["Int", "12.2"] # 12
|
|
132
143
|
["Float", "12.2"] # 12.2
|
|
144
|
+
["Str", 12] # "12"
|
|
145
|
+
["Str", "12"] # "12"
|
|
146
|
+
["Str", "aabb"] # "aabb"
|
|
147
|
+
["Not", True] # False
|
|
148
|
+
["Not", 0] # True
|
|
149
|
+
|
|
150
|
+
["In", 2, ["Array", 1, 2, 3]] # True
|
|
151
|
+
["In", 4, ["Array", 1, 2, 3]] # False
|
|
152
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 3, 4, 5, 6]] # True
|
|
153
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 4, 5, 6]] # False
|
|
154
|
+
["ContainsAllOf", ["Array", 1, 2, 3], ["Array", 1, 2, 3]] # True
|
|
155
|
+
["ContainsAllOf", ["Array", 1, 2], ["Array", 1, 2, 3]] # False
|
|
133
156
|
```
|
|
134
157
|
|
|
135
158
|
### Constants
|
|
@@ -3,6 +3,8 @@ from functools import reduce
|
|
|
3
3
|
import math
|
|
4
4
|
from copy import deepcopy
|
|
5
5
|
from statistics import median
|
|
6
|
+
import logging
|
|
7
|
+
import traceback
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class MathJSONException(Exception):
|
|
@@ -123,8 +125,19 @@ def create_mathjson_solver(solver_parameters):
|
|
|
123
125
|
for x in s[1:-1]:
|
|
124
126
|
if len(x) != 2:
|
|
125
127
|
raise ValueError(f"Wrong if or elif in 'If'")
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
try:
|
|
129
|
+
if f(x[0], c):
|
|
130
|
+
try:
|
|
131
|
+
return f(x[1], c)
|
|
132
|
+
except MathJSONException as e:
|
|
133
|
+
logging.error(
|
|
134
|
+
"MathJSONException: %s", traceback.format_exc()
|
|
135
|
+
)
|
|
136
|
+
continue
|
|
137
|
+
except MathJSONException as e:
|
|
138
|
+
logging.error("MathJSONException: %s", traceback.format_exc())
|
|
139
|
+
return f(s[-1], c) # return default value (else)
|
|
140
|
+
|
|
128
141
|
return f(s[-1], c)
|
|
129
142
|
|
|
130
143
|
def In(s):
|
|
@@ -229,10 +242,15 @@ def create_mathjson_solver(solver_parameters):
|
|
|
229
242
|
"Contains_any_of": Contains_any_of,
|
|
230
243
|
"Contains_all_of": Contains_all_of,
|
|
231
244
|
"Contains_none_of": Contains_none_of,
|
|
245
|
+
"NotIn": Not_in,
|
|
246
|
+
"ContainsAnyOf": Contains_any_of,
|
|
247
|
+
"ContainsAllOf": Contains_all_of,
|
|
248
|
+
"ContainsNoneOf": Contains_none_of,
|
|
232
249
|
"Int": Int,
|
|
233
250
|
"Float": Float,
|
|
234
251
|
"Str": Str,
|
|
235
252
|
"Not": Not,
|
|
253
|
+
"IsDefined": lambda s: s[1] in c,
|
|
236
254
|
}
|
|
237
255
|
if s[0] in constructs:
|
|
238
256
|
try:
|
|
@@ -249,6 +267,7 @@ def create_mathjson_solver(solver_parameters):
|
|
|
249
267
|
elif s in c:
|
|
250
268
|
return f(c[s], c)
|
|
251
269
|
else:
|
|
270
|
+
# raise KeyError(f"Parameter '{s}' is not defined")
|
|
252
271
|
return s
|
|
253
272
|
|
|
254
273
|
return f
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mathjson-solver
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Utilities for MathJSON evaluation
|
|
5
5
|
Home-page: https://github.com/LongenesisLtd/mathjson-solver
|
|
6
6
|
Author: Martins Mednis
|
|
@@ -97,9 +97,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
97
97
|
* `LessEqual`
|
|
98
98
|
* `NotEqual`
|
|
99
99
|
|
|
100
|
+
### Membership operators
|
|
101
|
+
* `In`
|
|
102
|
+
* `NotIn`
|
|
103
|
+
* `ContainsAnyOf`
|
|
104
|
+
* `ContainsAllOf`
|
|
105
|
+
* `ContainsNoneOf`
|
|
106
|
+
|
|
100
107
|
### Typecasting
|
|
108
|
+
* `Str`
|
|
101
109
|
* `Int`
|
|
102
110
|
* `Float`
|
|
111
|
+
* `Not`
|
|
103
112
|
|
|
104
113
|
### Additional constructs
|
|
105
114
|
* `Constants`
|
|
@@ -135,6 +144,8 @@ We welcome your contributions in the form of pull requests.
|
|
|
135
144
|
["Max", ["Array", 1, 2, ["Sum", 2, 4, 3], 5, 2]] # 9
|
|
136
145
|
["Median", ["Array", 1, 2, 3, 5, 2]] # 2
|
|
137
146
|
["Average", ["Array", 1, 2, 3, 5, 2]] # 2.6
|
|
147
|
+
["Average", ["Array"]] # None
|
|
148
|
+
|
|
138
149
|
["Length", ["Array", 1, 2, 3, 5, 2, 9]] # 6
|
|
139
150
|
["Length", ["Array"]] # 0
|
|
140
151
|
["Any", ["Array", 0, 0, False, 0, 0]] # False
|
|
@@ -145,6 +156,18 @@ We welcome your contributions in the form of pull requests.
|
|
|
145
156
|
["Int", "12"] # 12
|
|
146
157
|
["Int", "12.2"] # 12
|
|
147
158
|
["Float", "12.2"] # 12.2
|
|
159
|
+
["Str", 12] # "12"
|
|
160
|
+
["Str", "12"] # "12"
|
|
161
|
+
["Str", "aabb"] # "aabb"
|
|
162
|
+
["Not", True] # False
|
|
163
|
+
["Not", 0] # True
|
|
164
|
+
|
|
165
|
+
["In", 2, ["Array", 1, 2, 3]] # True
|
|
166
|
+
["In", 4, ["Array", 1, 2, 3]] # False
|
|
167
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 3, 4, 5, 6]] # True
|
|
168
|
+
["ContainsAnyOf", ["Array", 1, 2, 3], ["Array", 4, 5, 6]] # False
|
|
169
|
+
["ContainsAllOf", ["Array", 1, 2, 3], ["Array", 1, 2, 3]] # True
|
|
170
|
+
["ContainsAllOf", ["Array", 1, 2], ["Array", 1, 2, 3]] # False
|
|
148
171
|
```
|
|
149
172
|
|
|
150
173
|
### Constants
|
|
@@ -45,6 +45,10 @@ from mathjson_solver import create_solver, MathJSONException
|
|
|
45
45
|
({"color": "green"}, ["Switch", "color", 0, ["blue", 10], ["red", 30]], 0),
|
|
46
46
|
({"color": "green"}, ["Switch", "undefined", 0, ["blue", 10], ["red", 30]], 0),
|
|
47
47
|
({}, ["If", [["Equal", 1, 0], 10], [["Equal", 2, 2], 20], 9000], 20),
|
|
48
|
+
({"a": 10, "b": 10}, ["If", [["Equal", "a", "b"], 10], 9000], 10),
|
|
49
|
+
({"a": 10, "b": 20}, ["If", [["Equal", "a", "b"], 10], 9000], 9000),
|
|
50
|
+
({"a": 10}, ["If", [["Equal", "a", "b"], 10], 9000], 9000),
|
|
51
|
+
({"a": 10}, ["If", [["Equal", "a", ["Sum", 1, "b"]], 10], 9000], 9000),
|
|
48
52
|
({}, ["Array", 1, 2, 3, 5, 2], ["Array", 1, 2, 3, 5, 2]),
|
|
49
53
|
({}, ["Max", ["Array", 1, 2, 3, 5, 2]], 5),
|
|
50
54
|
({}, ["Max", ["Array", 1, 2, ["Sum", 2, 4, 3], 5, 2]], 9),
|
|
@@ -114,6 +118,7 @@ from mathjson_solver import create_solver, MathJSONException
|
|
|
114
118
|
({"a": [10, 20, 30]}, ["In", 21, "a"], False),
|
|
115
119
|
({}, ["Not_in", 2, ["Array", 1, 2, 3]], False),
|
|
116
120
|
({}, ["Not_in", 4, ["Array", 1, 2, 3]], True),
|
|
121
|
+
({}, ["NotIn", 4, ["Array", 1, 2, 3]], True),
|
|
117
122
|
({"a": [10, 20, 30]}, ["Not_in", 20, "a"], False),
|
|
118
123
|
({"a": [10, 20, 30]}, ["Not_in", 21, "a"], True),
|
|
119
124
|
({}, ["Contains_any_of", ["Array", 1, 2, 3], ["Array", 1, 2, 3]], True),
|
|
@@ -140,16 +145,19 @@ from mathjson_solver import create_solver, MathJSONException
|
|
|
140
145
|
),
|
|
141
146
|
({"a": [10, 20, 30]}, ["Contains_any_of", "a", ["Array", 1, 20, 3]], True),
|
|
142
147
|
({"b": [1, 20, 3]}, ["Contains_any_of", ["Array", 1, 2, 3], "b"], True),
|
|
148
|
+
({"b": [1, 20, 3]}, ["ContainsAnyOf", ["Array", 1, 2, 3], "b"], True),
|
|
143
149
|
({"a": [10, 20, 30], "b": [1, 20, 3]}, ["Contains_any_of", "a", "b"], True),
|
|
144
150
|
({"a": [10, 20, 30], "b": [1, 2, 3]}, ["Contains_any_of", "a", "b"], False),
|
|
145
151
|
({}, ["Contains_all_of", ["Array", 1, 2, 3], ["Array", 1, 2, 3]], True),
|
|
146
152
|
({}, ["Contains_all_of", ["Array", 1, 2], ["Array", 1, 2, 3]], False),
|
|
147
153
|
({}, ["Contains_all_of", ["Array", 1, 2, 3], ["Array", 1, 2]], True),
|
|
148
154
|
({}, ["Contains_all_of", ["Array", 1, 2, 3], ["Array", 2]], True),
|
|
155
|
+
({}, ["ContainsAllOf", ["Array", 1, 2, 3], ["Array", 2]], True),
|
|
149
156
|
({"a": [10, 20, 30], "b": [1, 20, 3]}, ["Contains_all_of", "a", "b"], False),
|
|
150
157
|
({"a": [1, 2, 3], "b": [1, 2]}, ["Contains_all_of", "a", "b"], True),
|
|
151
158
|
({}, ["Contains_none_of", ["Array", 1, 2, 3], ["Array", 1, 2, 3]], False),
|
|
152
159
|
({}, ["Contains_none_of", ["Array", 1, 2], ["Array", 2, 3]], False),
|
|
160
|
+
({}, ["ContainsNoneOf", ["Array", 1, 2], ["Array", 2, 3]], False),
|
|
153
161
|
({}, ["Contains_none_of", ["Array", 1, 2, 3], ["Array", 4, 5]], True),
|
|
154
162
|
({}, ["Not", True], False),
|
|
155
163
|
({}, ["Not", 0], True),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mathjson-solver-1.6.0 → mathjson_solver-1.7.0}/src/mathjson_solver.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|