bigraph-schema 0.0.58__tar.gz → 0.0.60__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.
Potentially problematic release.
This version of bigraph-schema might be problematic. Click here for more details.
- {bigraph-schema-0.0.58/bigraph_schema.egg-info → bigraph-schema-0.0.60}/PKG-INFO +1 -1
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/__init__.py +2 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/parse.py +2 -2
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/tests.py +25 -1
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/type_functions.py +81 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60/bigraph_schema.egg-info}/PKG-INFO +1 -1
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/setup.py +1 -1
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/.github/workflows/notebook_to_html.yml +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/.github/workflows/pytest.yml +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/.gitignore +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/AUTHORS.md +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/CLA.md +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/CODE_OF_CONDUCT.md +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/CONTRIBUTING.md +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/LICENSE +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/README.md +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/edge.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/protocols.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/registry.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/type_system.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/units.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema/utilities.py +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema.egg-info/SOURCES.txt +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema.egg-info/dependency_links.txt +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema.egg-info/requires.txt +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema.egg-info/top_level.txt +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/core.ipynb +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/demo.ipynb +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/images/place-link.png +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/images/reaction-after.png +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/images/reaction-before.png +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/notebooks/images/redex-reactum.png +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/pytest.ini +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/release.sh +0 -0
- {bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/setup.cfg +0 -0
|
@@ -4,3 +4,5 @@ from bigraph_schema.registry import (
|
|
|
4
4
|
from bigraph_schema.utilities import get_path, visit_method
|
|
5
5
|
from bigraph_schema.edge import Edge
|
|
6
6
|
from bigraph_schema.type_system import TypeSystem, type_schema_keys, resolve_path
|
|
7
|
+
from bigraph_schema.protocols import local_lookup_module
|
|
8
|
+
from bigraph_schema.type_functions import FUNCTION_TYPE, METHOD_TYPE
|
|
@@ -37,7 +37,7 @@ parameter_grammar = Grammar(
|
|
|
37
37
|
nest = symbol colon tree
|
|
38
38
|
type_name = symbol parameter_list?
|
|
39
39
|
parameter_list = square_left expression (comma expression)* square_right
|
|
40
|
-
symbol = ~r"[
|
|
40
|
+
symbol = ~r"[\\w\\d-_/*&^%$#@!`+ ]+"
|
|
41
41
|
dot = "."
|
|
42
42
|
colon = ":"
|
|
43
43
|
bar = "|"
|
|
@@ -49,7 +49,7 @@ parameter_grammar = Grammar(
|
|
|
49
49
|
tilde = "~"
|
|
50
50
|
not_newline = ~r"[^\\n\\r]"*
|
|
51
51
|
newline = ~"[\\n\\r]+"
|
|
52
|
-
ws = ~"
|
|
52
|
+
ws = ~r"\\s*"
|
|
53
53
|
nothing = ""
|
|
54
54
|
""")
|
|
55
55
|
|
|
@@ -7,10 +7,10 @@ import pprint
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
from dataclasses import asdict
|
|
9
9
|
|
|
10
|
+
from bigraph_schema import TypeSystem, local_lookup_module
|
|
10
11
|
from bigraph_schema.type_functions import (
|
|
11
12
|
divide_longest, base_types, accumulate, to_string, deserialize_integer, apply_schema, data_module)
|
|
12
13
|
from bigraph_schema.utilities import compare_dicts, NONE_SYMBOL
|
|
13
|
-
from bigraph_schema import TypeSystem
|
|
14
14
|
from bigraph_schema.units import units
|
|
15
15
|
from bigraph_schema.registry import establish_path, remove_omitted
|
|
16
16
|
|
|
@@ -1229,6 +1229,29 @@ def test_reaction(core):
|
|
|
1229
1229
|
{'id': 'daughter2', 'ratio': 0.7}]}}}
|
|
1230
1230
|
|
|
1231
1231
|
|
|
1232
|
+
def A(a):
|
|
1233
|
+
return a * 5
|
|
1234
|
+
|
|
1235
|
+
def B(b):
|
|
1236
|
+
return b + 11
|
|
1237
|
+
|
|
1238
|
+
def test_function_type(core):
|
|
1239
|
+
A_serialized = core.serialize(
|
|
1240
|
+
'function',
|
|
1241
|
+
A)
|
|
1242
|
+
|
|
1243
|
+
A_deserialized = core.deserialize(
|
|
1244
|
+
'function',
|
|
1245
|
+
A_serialized)
|
|
1246
|
+
|
|
1247
|
+
C = core.apply(
|
|
1248
|
+
'function',
|
|
1249
|
+
A_deserialized,
|
|
1250
|
+
B)
|
|
1251
|
+
|
|
1252
|
+
assert C(6) == 41
|
|
1253
|
+
|
|
1254
|
+
|
|
1232
1255
|
def test_map_type(core):
|
|
1233
1256
|
schema = 'map[integer]'
|
|
1234
1257
|
|
|
@@ -2508,6 +2531,7 @@ if __name__ == '__main__':
|
|
|
2508
2531
|
test_maybe_type(core)
|
|
2509
2532
|
test_tuple_type(core)
|
|
2510
2533
|
test_array_type(core)
|
|
2534
|
+
test_function_type(core)
|
|
2511
2535
|
test_union_type(core)
|
|
2512
2536
|
test_union_values(core)
|
|
2513
2537
|
test_infer_edge(core)
|
|
@@ -68,6 +68,7 @@ import types
|
|
|
68
68
|
import copy
|
|
69
69
|
import numbers
|
|
70
70
|
import numpy as np
|
|
71
|
+
from abc import ABCMeta
|
|
71
72
|
from pint import Quantity
|
|
72
73
|
from pprint import pformat as pf
|
|
73
74
|
|
|
@@ -76,6 +77,7 @@ from typing import NewType, Union, Mapping, List, Dict, Optional, Callable
|
|
|
76
77
|
from dataclasses import field, make_dataclass
|
|
77
78
|
|
|
78
79
|
from bigraph_schema import get_path, set_path
|
|
80
|
+
from bigraph_schema.protocols import local_lookup_module
|
|
79
81
|
from bigraph_schema.units import units, render_units_type
|
|
80
82
|
from bigraph_schema.registry import (
|
|
81
83
|
is_schema_key, non_schema_keys, type_parameter_key, deep_merge, hierarchy_depth, establish_path
|
|
@@ -421,6 +423,16 @@ def apply_array(schema, current, update, top_schema, top_state, path, core):
|
|
|
421
423
|
else:
|
|
422
424
|
return current + update
|
|
423
425
|
|
|
426
|
+
def apply_function(schema, current, update, top_schema, top_state, path, core):
|
|
427
|
+
def compose(a):
|
|
428
|
+
return update(
|
|
429
|
+
current(
|
|
430
|
+
a))
|
|
431
|
+
|
|
432
|
+
return compose
|
|
433
|
+
|
|
434
|
+
def apply_meta(schema, current, update, top_schema, top_state, path, core):
|
|
435
|
+
return update
|
|
424
436
|
|
|
425
437
|
# =========================
|
|
426
438
|
# Check Functions Overview
|
|
@@ -484,6 +496,22 @@ def check_float(schema, state, core=None):
|
|
|
484
496
|
def check_string(schema, state, core=None):
|
|
485
497
|
return isinstance(state, str)
|
|
486
498
|
|
|
499
|
+
class Empty():
|
|
500
|
+
def method(self):
|
|
501
|
+
pass
|
|
502
|
+
|
|
503
|
+
FUNCTION_TYPE = type(check_string)
|
|
504
|
+
METHOD_TYPE = type(Empty().method)
|
|
505
|
+
|
|
506
|
+
def check_function(schema, state, core=None):
|
|
507
|
+
return isinstance(state, FUNCTION_TYPE)
|
|
508
|
+
|
|
509
|
+
def check_method(schema, state, core=None):
|
|
510
|
+
return isinstance(state, METHOD_TYPE)
|
|
511
|
+
|
|
512
|
+
def check_meta(schema, state, core=None):
|
|
513
|
+
return isinstance(state, ABCMeta)
|
|
514
|
+
|
|
487
515
|
def check_list(schema, state, core):
|
|
488
516
|
element_type = core.find_parameter(
|
|
489
517
|
schema,
|
|
@@ -1070,6 +1098,9 @@ def serialize_maybe(schema, value, core):
|
|
|
1070
1098
|
value_type,
|
|
1071
1099
|
value)
|
|
1072
1100
|
|
|
1101
|
+
def serialize_function(schema, value, core=None):
|
|
1102
|
+
return f'{value.__module__}.{value.__name__}'
|
|
1103
|
+
|
|
1073
1104
|
def serialize_map(schema, value, core=None):
|
|
1074
1105
|
value_type = core.find_parameter(
|
|
1075
1106
|
schema,
|
|
@@ -1315,6 +1346,9 @@ def deserialize_units(schema, encoded, core):
|
|
|
1315
1346
|
else:
|
|
1316
1347
|
return units(encoded)
|
|
1317
1348
|
|
|
1349
|
+
def deserialize_function(schema, value, core=None):
|
|
1350
|
+
return local_lookup_module(value)
|
|
1351
|
+
|
|
1318
1352
|
def deserialize_map(schema, encoded, core=None):
|
|
1319
1353
|
if isinstance(encoded, dict):
|
|
1320
1354
|
value_type = core.find_parameter(
|
|
@@ -2189,6 +2223,33 @@ def generate_any(core, schema, state, top_schema=None, top_state=None, path=None
|
|
|
2189
2223
|
|
|
2190
2224
|
return generated_schema, generated_state, top_schema, top_state
|
|
2191
2225
|
|
|
2226
|
+
|
|
2227
|
+
def generate_list(core, schema, state, top_schema=None, top_state=None, path=None):
|
|
2228
|
+
schema = schema or {}
|
|
2229
|
+
state = state or core.default(schema)
|
|
2230
|
+
top_schema = top_schema or schema
|
|
2231
|
+
top_state = top_state or state
|
|
2232
|
+
path = path or []
|
|
2233
|
+
|
|
2234
|
+
element_type = core.find_parameter(
|
|
2235
|
+
schema,
|
|
2236
|
+
'element')
|
|
2237
|
+
|
|
2238
|
+
generated_state = []
|
|
2239
|
+
|
|
2240
|
+
for index, element in enumerate(state):
|
|
2241
|
+
subschema, substate, top_schema, top_state = core.generate_recur(
|
|
2242
|
+
element_type,
|
|
2243
|
+
element,
|
|
2244
|
+
top_schema=top_schema,
|
|
2245
|
+
top_state=top_state,
|
|
2246
|
+
path=path + [index])
|
|
2247
|
+
|
|
2248
|
+
generated_state.append(substate)
|
|
2249
|
+
|
|
2250
|
+
return schema, generated_state, top_schema, top_state
|
|
2251
|
+
|
|
2252
|
+
|
|
2192
2253
|
def generate_quote(core, schema, state, top_schema=None, top_state=None, path=None):
|
|
2193
2254
|
return schema, state, top_schema, top_state
|
|
2194
2255
|
|
|
@@ -2764,6 +2825,7 @@ base_types = {
|
|
|
2764
2825
|
'list': {
|
|
2765
2826
|
'_type': 'list',
|
|
2766
2827
|
'_default': [],
|
|
2828
|
+
# '_generate': generate_list,
|
|
2767
2829
|
'_check': check_list,
|
|
2768
2830
|
'_slice': slice_list,
|
|
2769
2831
|
'_apply': apply_list,
|
|
@@ -2838,6 +2900,25 @@ base_types = {
|
|
|
2838
2900
|
'_type_parameters': ['value'],
|
|
2839
2901
|
'_description': 'type to represent values that could be empty'},
|
|
2840
2902
|
|
|
2903
|
+
'function': {
|
|
2904
|
+
'_type': 'function',
|
|
2905
|
+
'_apply': apply_function,
|
|
2906
|
+
'_serialize': serialize_function,
|
|
2907
|
+
'_deserialize': deserialize_function,
|
|
2908
|
+
'_check': check_function},
|
|
2909
|
+
|
|
2910
|
+
'method': {
|
|
2911
|
+
'_type': 'function',
|
|
2912
|
+
'_apply': apply_meta,
|
|
2913
|
+
'_serialize': serialize_function,
|
|
2914
|
+
'_deserialize': deserialize_function,
|
|
2915
|
+
'_check': check_method},
|
|
2916
|
+
|
|
2917
|
+
'meta': {
|
|
2918
|
+
'_inherit': 'function',
|
|
2919
|
+
'_apply': apply_meta,
|
|
2920
|
+
'_check': check_meta},
|
|
2921
|
+
|
|
2841
2922
|
'path': {
|
|
2842
2923
|
'_type': 'path',
|
|
2843
2924
|
'_inherit': 'list[string~integer]',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bigraph-schema-0.0.58 → bigraph-schema-0.0.60}/bigraph_schema.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|