bigraph-schema 0.0.35__tar.gz → 0.0.38__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.

Files changed (34) hide show
  1. bigraph-schema-0.0.38/.github/workflows/notebook_to_html.yml +48 -0
  2. bigraph-schema-0.0.38/.github/workflows/pytest.yml +29 -0
  3. bigraph-schema-0.0.38/.gitignore +14 -0
  4. bigraph-schema-0.0.38/CLA.md +113 -0
  5. bigraph-schema-0.0.38/CODE_OF_CONDUCT.md +137 -0
  6. bigraph-schema-0.0.38/CONTRIBUTING.md +44 -0
  7. {bigraph-schema-0.0.35/bigraph_schema.egg-info → bigraph-schema-0.0.38}/PKG-INFO +1 -1
  8. bigraph-schema-0.0.38/bigraph_schema/data.py +1 -0
  9. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/registry.py +128 -4
  10. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/type_system.py +580 -230
  11. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38/bigraph_schema.egg-info}/PKG-INFO +1 -1
  12. bigraph-schema-0.0.38/bigraph_schema.egg-info/SOURCES.txt +31 -0
  13. bigraph-schema-0.0.38/notebooks/core.ipynb +1683 -0
  14. bigraph-schema-0.0.38/notebooks/demo.ipynb +1487 -0
  15. bigraph-schema-0.0.38/notebooks/images/place-link.png +0 -0
  16. bigraph-schema-0.0.38/notebooks/images/reaction-after.png +0 -0
  17. bigraph-schema-0.0.38/notebooks/images/reaction-before.png +0 -0
  18. bigraph-schema-0.0.38/notebooks/images/redex-reactum.png +0 -0
  19. bigraph-schema-0.0.38/pytest.ini +4 -0
  20. bigraph-schema-0.0.38/release.sh +43 -0
  21. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/setup.py +1 -1
  22. bigraph-schema-0.0.35/bigraph_schema.egg-info/SOURCES.txt +0 -16
  23. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/AUTHORS.md +0 -0
  24. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/LICENSE +0 -0
  25. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/README.md +0 -0
  26. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/__init__.py +0 -0
  27. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/parse.py +0 -0
  28. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/protocols.py +0 -0
  29. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/react.py +0 -0
  30. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema/units.py +0 -0
  31. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema.egg-info/dependency_links.txt +0 -0
  32. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema.egg-info/requires.txt +0 -0
  33. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/bigraph_schema.egg-info/top_level.txt +0 -0
  34. {bigraph-schema-0.0.35 → bigraph-schema-0.0.38}/setup.cfg +0 -0
@@ -0,0 +1,48 @@
1
+ name: Convert Jupyter Notebook to HTML
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - 'notebooks/demo.ipynb'
7
+ - 'notebooks/core.ipynb'
8
+
9
+ jobs:
10
+ convert:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Check out repository
14
+ uses: actions/checkout@main
15
+ with:
16
+ ref: main
17
+ fetch-depth: 0 # Fetch all history to have access to the gh-pages branch
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@main
21
+ with:
22
+ python-version: 3.x
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install nbconvert
28
+
29
+ - name: Convert Jupyter Notebook to HTML
30
+ run: |
31
+ jupyter nbconvert --to html notebooks/demo.ipynb
32
+ jupyter nbconvert --to html notebooks/core.ipynb
33
+
34
+ - name: Commit and push HTML to gh-pages branch
35
+ run: |
36
+ git config --local user.email "eagmon@github.com"
37
+ git config --local user.name "GitHub Action"
38
+ git fetch origin
39
+ mv notebooks/demo.html /tmp/demo.html
40
+ mv notebooks/core.html /tmp/core.html
41
+ git checkout gh-pages || git checkout -b gh-pages
42
+ git pull origin gh-pages
43
+ mv /tmp/demo.html notebooks/demo.html
44
+ mv /tmp/core.html notebooks/core.html
45
+ git add notebooks/demo.html
46
+ git add notebooks/core.html
47
+ git diff-index --quiet HEAD || git commit -m "Update HTML files"
48
+ git push origin gh-pages || true
@@ -0,0 +1,29 @@
1
+ name: Run Pytest
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Check out repository
13
+ uses: actions/checkout@v2
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v2
17
+ with:
18
+ python-version: 3.x
19
+
20
+ - name: Install dependencies
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ pip install pytest pytest-cov
24
+ pip install -e .
25
+
26
+ - name: Run pytest
27
+ run: |
28
+ pip install pytest
29
+ pytest --cov=bigraph_schema --cov-report=term
@@ -0,0 +1,14 @@
1
+ *.out
2
+ out/
3
+ .idea/
4
+ *-checkpoint.ipynb
5
+ __pycache__
6
+ .DS_Store
7
+ .DS_Store?
8
+ ._*
9
+ .python-version
10
+ .pytest_cache
11
+ lib/
12
+ *.ipynb_checkpoints/
13
+ dist/
14
+ bigraph_schema.egg-info/
@@ -0,0 +1,113 @@
1
+ # Individual Contributor License Agreement
2
+
3
+ Thank you for your interest in Vivarium Core. To clarify the
4
+ intellectual property license granted with Contributions from any person
5
+ or entity, each Contribution must indicate each Contributor's agreement
6
+ with the license terms below. This agreement is for your protection as a
7
+ Contributor as well as the protection of the Vivarium Core authors
8
+ (Authors) and Vivarium Core's users. It does not change your rights to
9
+ use your own Contributions for any other purpose.
10
+
11
+ You accept and agree to the following terms and conditions for Your
12
+ Contributions (present and future) that you submit to the Authors.
13
+ Except for the license granted herein to the Authors and recipients of
14
+ software distributed by the Authors, You reserve all right, title, and
15
+ interest in and to Your Contributions.
16
+
17
+ 1. Definitions
18
+
19
+ "You" (or "Your") shall mean the copyright owner or legal entity
20
+ authorized by the copyright owner that is making this Agreement with
21
+ the Authors. For legal entities, the entity making a Contribution and
22
+ all other entities that control, are controlled by, or are under
23
+ common control with that entity are considered to be a single
24
+ Contributor. For the purposes of this definition, "control" means (i)
25
+ the power, direct or indirect, to cause the direction or management
26
+ of such entity, whether by contract or otherwise, or (ii) ownership
27
+ of fifty percent (50%) or more of the outstanding shares, or (iii)
28
+ beneficial ownership of such entity.
29
+
30
+ "Contribution" shall mean any original work of authorship, including
31
+ any modifications or additions to an existing work, that is
32
+ intentionally submitted by You to the Authors for inclusion in, or
33
+ documentation of, any of the products owned or managed by the Authors
34
+ (the "Work"). For the purposes of this definition, "submitted" means
35
+ any form of electronic, verbal, or written communication sent to the
36
+ Authors or their representatives, including but not limited to
37
+ communication on electronic mailing lists, source code control
38
+ systems, and issue tracking systems that are managed by, or on behalf
39
+ of, the Authors for the purpose of discussing and improving the Work,
40
+ but excluding communication that is conspicuously marked or otherwise
41
+ designated in writing by You as "Not a Contribution."
42
+
43
+ 2. Grant of Copyright License. Subject to the terms and conditions of
44
+ this Agreement, You hereby grant to the Authors and to recipients
45
+ of software distributed by the Authors a perpetual, worldwide,
46
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license
47
+ to reproduce, prepare derivative works of, publicly display, publicly
48
+ perform, sublicense, and distribute Your Contributions and such
49
+ derivative works.
50
+
51
+ 3. Grant of Patent License. Subject to the terms and conditions of this
52
+ Agreement, You hereby grant to the Authors and to recipients of
53
+ software distributed by the Authors a perpetual, worldwide,
54
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated
55
+ in this section) patent license to make, have made, use, offer to
56
+ sell, sell, import, and otherwise transfer the Work, where such
57
+ license applies only to those patent claims licensable by You that
58
+ are necessarily infringed by Your Contribution(s) alone or by
59
+ combination of Your Contribution(s) with the Work to which such
60
+ Contribution(s) was submitted. If any entity institutes patent
61
+ litigation against You or any other entity (including a cross-claim
62
+ or counterclaim in a lawsuit) alleging that your Contribution, or the
63
+ Work to which you have contributed, constitutes direct or
64
+ contributory patent infringement, then any patent licenses granted to
65
+ that entity under this Agreement for that Contribution or Work shall
66
+ terminate as of the date such litigation is filed.
67
+
68
+ 4. You represent that you are legally entitled to grant the above
69
+ license. If your employer(s) has rights to intellectual property that
70
+ you create that includes your Contributions, you represent that you
71
+ have received permission to make Contributions on behalf of that
72
+ employer, that your employer has waived such rights for your
73
+ Contributions to the Authors, or that your employer has executed a
74
+ separate Corporate CLA with the Authors.
75
+
76
+ 5. You represent that each of Your Contributions is Your original
77
+ creation (see section 7 for submissions on behalf of others). You
78
+ represent that Your Contribution submissions include complete details
79
+ of any third-party license or other restriction (including, but not
80
+ limited to, related patents and trademarks) of which you are
81
+ personally aware and which are associated with any part of Your
82
+ Contributions.
83
+
84
+ 6. You are not expected to provide support for Your Contributions,
85
+ except to the extent You desire to provide support. You may provide
86
+ support for free, for a fee, or not at all. Unless required by
87
+ applicable law or agreed to in writing, You provide Your
88
+ Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
89
+ OF ANY KIND, either express or implied, including, without
90
+ limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT,
91
+ MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
92
+
93
+ 7. Should You wish to submit work that is not Your original creation,
94
+ You may submit it to the Authors separately from any Contribution,
95
+ identifying the complete details of its source and of any license or
96
+ other restriction (including, but not limited to, related patents,
97
+ trademarks, and license agreements) of which you are personally
98
+ aware, and conspicuously marking the work as "Submitted on behalf of
99
+ a third-party: [named here]".
100
+
101
+ 8. You agree to notify the Authors of any facts or circumstances of
102
+ which you become aware that would make these representations
103
+ inaccurate in any respect.
104
+
105
+ -----------------------------------------------------------------------
106
+
107
+ End of Contributor License Agreement
108
+
109
+ -----------------------------------------------------------------------
110
+
111
+ The text of this agreement was adapted from the Apache Software
112
+ Foundation's [Individual Contributor License
113
+ Agreement](https://apache.org/licenses/icla.pdf).
@@ -0,0 +1,137 @@
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in
6
+ our community a harassment-free experience for everyone, regardless of
7
+ age, body size, visible or invisible disability, ethnicity, sex
8
+ characteristics, gender identity and expression, level of experience,
9
+ education, socio-economic status, nationality, personal appearance,
10
+ race, caste, color, religion, or sexual identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open,
13
+ welcoming, diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our
24
+ mistakes, and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political
33
+ attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our
43
+ standards of acceptable behavior and will take appropriate and fair
44
+ corrective action in response to any behavior that they deem
45
+ inappropriate, threatening, offensive, or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or
48
+ reject comments, commits, code, wiki edits, issues, and other
49
+ contributions that are not aligned to this Code of Conduct, and will
50
+ communicate reasons for moderation decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also
55
+ applies when an individual is officially representing the community in
56
+ public spaces. Examples of representing our community include using an
57
+ official e-mail address, posting via an official social media account,
58
+ or acting as an appointed representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may
63
+ be reported to the Authors at the email addresses in
64
+ [`AUTHORS.md`](AUTHORS.md). All complaints will be reviewed and
65
+ investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security
68
+ of the reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in
73
+ determining the consequences for any action they deem in violation of
74
+ this Code of Conduct:
75
+
76
+ ### 1. Correction
77
+
78
+ **Community Impact**: Use of inappropriate language or other behavior
79
+ deemed unprofessional or unwelcome in the community.
80
+
81
+ **Consequence**: A private, written warning from community leaders,
82
+ providing clarity around the nature of the violation and an explanation
83
+ of why the behavior was inappropriate. A public apology may be
84
+ requested.
85
+
86
+ ### 2. Warning
87
+
88
+ **Community Impact**: A violation through a single incident or series of
89
+ actions.
90
+
91
+ **Consequence**: A warning with consequences for continued behavior. No
92
+ interaction with the people involved, including unsolicited interaction
93
+ with those enforcing the Code of Conduct, for a specified period of
94
+ time. This includes avoiding interactions in community spaces as well as
95
+ external channels like social media. Violating these terms may lead to a
96
+ temporary or permanent ban.
97
+
98
+ ### 3. Temporary Ban
99
+
100
+ **Community Impact**: A serious violation of community standards,
101
+ including sustained inappropriate behavior.
102
+
103
+ **Consequence**: A temporary ban from any sort of interaction or public
104
+ communication with the community for a specified period of time. No
105
+ public or private interaction with the people involved, including
106
+ unsolicited interaction with those enforcing the Code of Conduct, is
107
+ allowed during this period. Violating these terms may lead to a
108
+ permanent ban.
109
+
110
+ ### 4. Permanent Ban
111
+
112
+ **Community Impact**: Demonstrating a pattern of violation of community
113
+ standards, including sustained inappropriate behavior, harassment of an
114
+ individual, or aggression toward or disparagement of classes of
115
+ individuals.
116
+
117
+ **Consequence**: A permanent ban from any sort of public interaction
118
+ within the community.
119
+
120
+ ## Attribution
121
+
122
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
123
+ version 2.1, available at
124
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
125
+
126
+ Community Impact Guidelines were inspired by
127
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
128
+
129
+ For answers to common questions about this code of conduct, see the FAQ at
130
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
131
+ [https://www.contributor-covenant.org/translations][translations].
132
+
133
+ [homepage]: https://www.contributor-covenant.org
134
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
135
+ [Mozilla CoC]: https://github.com/mozilla/diversity
136
+ [FAQ]: https://www.contributor-covenant.org/faq
137
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,44 @@
1
+ # Contributing to Bigraph-Schema
2
+
3
+ ## Making a Contribution
4
+
5
+ Thank you for your interest in contributing to Vivarium Core! Here's how
6
+ you can get started:
7
+
8
+ 1. Review the [Contributor License Agreement](CLA.md) (CLA). Whenever
9
+ you submit a contribution to Vivarium Core, you are agreeing to the
10
+ CLA, which grants us rights to use your contribution. You don't need
11
+ to do anything special to "sign" the CLA. Instead, opening a pull
12
+ request indicates your agreement to the CLA.
13
+ 2. [Optional] If you want to make a contribution that isn't covered by
14
+ an existing issue, go ahead an open a new one!
15
+ 3. Once you have found or created an issue that describes the
16
+ contribution you want to make, wait to get feedback from the project
17
+ maintainers.
18
+ 4. If the project maintainers agree that your proposal makes sense, you
19
+ can fork the repository, make your changes, and open a pull request.
20
+ If you haven't done this before, check out [GitHub's guide to open
21
+ source
22
+ contributions](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
23
+ 5. Wait to get feedback from the project maintainers and then address
24
+ any review comments they leave. Once your pull request is approved,
25
+ the project maintainers will merge it.
26
+
27
+ ## Contacting Us
28
+
29
+ * To request features or report bugs, please open an
30
+ [issue](https://github.com/vivarium-collective/bigraph-schema/issues).
31
+ * To ask questions or request help, please open a [discussion
32
+ thread](https://github.com/vivarium-collective/bigraph-schema/discussions).
33
+ * To contact the maintainers privately, for example to report a
34
+ violation of our [code of conduct](CODE_OF_CONDUCT.md) or to notify us
35
+ of a security issue, you can use the contact information in the
36
+ [`AUTHORS.md` file](AUTHORS.md).
37
+
38
+ ## Code of Conduct
39
+
40
+ We expect kindness and respect in all interactions with the Vivarium
41
+ Collective community. Harassing or insulting behavior is not welcome and will
42
+ result in enforcement actions. Please review our [code of
43
+ conduct](CODE_OF_CONDUCT.md), which describes our expectations and
44
+ enforcement actions in more detail.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bigraph-schema
3
- Version: 0.0.35
3
+ Version: 0.0.38
4
4
  Summary: A serializable type schema for compositional systems biology
5
5
  Home-page: https://github.com/vivarium-collective/bigraph-schema
6
6
  Author: Eran Agmon, Ryan Spangler
@@ -13,9 +13,12 @@ import traceback
13
13
  import numpy as np
14
14
 
15
15
  from pprint import pformat as pf
16
+ from typing import Any, Tuple, Union, Optional, Mapping
17
+ from dataclasses import field, make_dataclass
16
18
 
17
19
  from bigraph_schema.parse import parse_expression
18
20
  from bigraph_schema.protocols import local_lookup_module, function_module
21
+ import bigraph_schema.data
19
22
 
20
23
 
21
24
  NONE_SYMBOL = '!nil'
@@ -525,6 +528,34 @@ def fold_union(schema, state, method, values, core):
525
528
  return result
526
529
 
527
530
 
531
+ def type_parameters_for(schema):
532
+ parameters = []
533
+ for key in schema['_type_parameters']:
534
+ subschema = schema.get(f'_{key}', 'any')
535
+ parameters.append(subschema)
536
+
537
+ return parameters
538
+
539
+
540
+ def dataclass_union(schema, path, core):
541
+ parameters = type_parameters_for(schema)
542
+ subtypes = []
543
+ for parameter in parameters:
544
+ dataclass = core.dataclass(
545
+ parameter,
546
+ path)
547
+
548
+ if isinstance(dataclass, str):
549
+ subtypes.append(dataclass)
550
+ elif isinstance(dataclass, type):
551
+ subtypes.append(dataclass.__name__)
552
+ else:
553
+ subtypes.append(str(dataclass))
554
+
555
+ parameter_block = ', '.join(subtypes)
556
+ return eval(f'Union[{parameter_block}]')
557
+
558
+
528
559
  def divide_any(schema, state, values, core):
529
560
  divisions = values.get('divisions', 2)
530
561
 
@@ -551,6 +582,92 @@ def divide_any(schema, state, values, core):
551
582
  for _ in range(divisions)]
552
583
 
553
584
 
585
+ def is_schema_key(schema, key):
586
+ return key.strip('_') not in schema.get('_type_parameters', []) and key.startswith('_')
587
+
588
+
589
+ def resolve_any(schema, update, core):
590
+ outcome = schema.copy()
591
+
592
+ for key, subschema in update.items():
593
+ if key == '_type' and key in outcome:
594
+ if outcome[key] != subschema:
595
+ if core.inherits_from(outcome[key], subschema):
596
+ continue
597
+ elif core.inherits_from(subschema, outcome[key]):
598
+ outcome[key] = subschema
599
+ else:
600
+ raise Exception(f'cannot resolve types when updating\ncurrent type: {schema}\nupdate type: {update}')
601
+
602
+ elif not key in outcome or is_schema_key(update, key):
603
+ if subschema:
604
+ outcome[key] = subschema
605
+ else:
606
+ outcome[key] = core.resolve_schemas(
607
+ outcome.get(key),
608
+ subschema)
609
+
610
+ return outcome
611
+
612
+
613
+ def dataclass_any(schema, path, core):
614
+ parts = path
615
+ if not parts:
616
+ parts = ['top']
617
+ dataclass_name = '_'.join(parts)
618
+
619
+ if isinstance(schema, dict):
620
+ type_name = schema.get('_type', 'any')
621
+
622
+ branches = {}
623
+ for key, subschema in schema.items():
624
+ if not key.startswith('_'):
625
+ branch = core.dataclass(
626
+ subschema,
627
+ path + [key])
628
+
629
+ def default(subschema=subschema):
630
+ return core.default(subschema)
631
+
632
+ branches[key] = (
633
+ key,
634
+ branch,
635
+ field(default_factory=default))
636
+
637
+ dataclass = make_dataclass(
638
+ dataclass_name,
639
+ branches.values(),
640
+ namespace={
641
+ '__module__': 'bigraph_schema.data'})
642
+
643
+ setattr(
644
+ bigraph_schema.data,
645
+ dataclass_name,
646
+ dataclass)
647
+
648
+ else:
649
+ schema = core.access(schema)
650
+ dataclass = core.dataclass(schema, path)
651
+
652
+ return dataclass
653
+
654
+
655
+ def dataclass_tuple(schema, path, core):
656
+ parameters = type_parameters_for(schema)
657
+ subtypes = []
658
+
659
+ for index, key in enumerate(schema['type_parameters']):
660
+ subschema = schema.get(key, 'any')
661
+ subtype = core.dataclass(
662
+ subschema,
663
+ path + [index])
664
+
665
+ subtypes.append(subtype)
666
+
667
+ parameter_block = ', '.join(subtypes)
668
+ return eval(f'tuple[{parameter_block}]')
669
+
670
+
554
671
  def divide_tuple(schema, state, values, core):
555
672
  divisions = values.get('divisions', 2)
556
673
 
@@ -740,10 +857,13 @@ def merge_any(schema, current_state, new_state, core):
740
857
  elif isinstance(new_state, dict):
741
858
  if isinstance(current_state, dict):
742
859
  for key, value in new_state.items():
743
- current_state[key] = core.merge(
744
- schema.get(key),
745
- current_state.get(key),
746
- value)
860
+ if key.startswith('_'):
861
+ current_state[key] = value
862
+ else:
863
+ current_state[key] = core.merge(
864
+ schema.get(key),
865
+ current_state.get(key),
866
+ value)
747
867
  return current_state
748
868
  else:
749
869
  return new_state
@@ -954,6 +1074,8 @@ registry_types = {
954
1074
  '_check': check_any,
955
1075
  '_serialize': serialize_any,
956
1076
  '_deserialize': deserialize_any,
1077
+ '_dataclass': dataclass_any,
1078
+ '_resolve': resolve_any,
957
1079
  '_fold': fold_any,
958
1080
  '_merge': merge_any,
959
1081
  '_bind': bind_any,
@@ -967,6 +1089,7 @@ registry_types = {
967
1089
  '_slice': slice_tuple,
968
1090
  '_serialize': serialize_tuple,
969
1091
  '_deserialize': deserialize_tuple,
1092
+ '_dataclass': dataclass_tuple,
970
1093
  '_fold': fold_tuple,
971
1094
  '_divide': divide_tuple,
972
1095
  '_bind': bind_tuple,
@@ -980,6 +1103,7 @@ registry_types = {
980
1103
  '_slice': slice_union,
981
1104
  '_serialize': serialize_union,
982
1105
  '_deserialize': deserialize_union,
1106
+ '_dataclass': dataclass_union,
983
1107
  '_fold': fold_union,
984
1108
  '_description': 'union of a set of possible types'}}
985
1109