bigraph-schema 0.0.56__tar.gz → 0.0.58__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/.github/workflows/notebook_to_html.yml +48 -0
- bigraph-schema-0.0.58/.github/workflows/pytest.yml +29 -0
- bigraph-schema-0.0.58/.gitignore +14 -0
- bigraph-schema-0.0.58/CLA.md +113 -0
- bigraph-schema-0.0.58/CODE_OF_CONDUCT.md +137 -0
- bigraph-schema-0.0.58/CONTRIBUTING.md +44 -0
- {bigraph-schema-0.0.56/bigraph_schema.egg-info → bigraph-schema-0.0.58}/PKG-INFO +1 -1
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/registry.py +46 -0
- bigraph-schema-0.0.56/bigraph_schema/type_system_tests.py → bigraph-schema-0.0.58/bigraph_schema/tests.py +102 -3
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/type_functions.py +130 -49
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/type_system.py +73 -51
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/utilities.py +0 -1
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58/bigraph_schema.egg-info}/PKG-INFO +1 -1
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema.egg-info/SOURCES.txt +16 -2
- bigraph-schema-0.0.58/notebooks/core.ipynb +1683 -0
- bigraph-schema-0.0.58/notebooks/demo.ipynb +1487 -0
- bigraph-schema-0.0.58/notebooks/images/place-link.png +0 -0
- bigraph-schema-0.0.58/notebooks/images/reaction-after.png +0 -0
- bigraph-schema-0.0.58/notebooks/images/reaction-before.png +0 -0
- bigraph-schema-0.0.58/notebooks/images/redex-reactum.png +0 -0
- bigraph-schema-0.0.58/pytest.ini +4 -0
- bigraph-schema-0.0.58/release.sh +43 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/setup.py +1 -1
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/AUTHORS.md +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/LICENSE +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/README.md +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/__init__.py +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/edge.py +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/parse.py +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/protocols.py +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema/units.py +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema.egg-info/dependency_links.txt +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema.egg-info/requires.txt +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/bigraph_schema.egg-info/top_level.txt +0 -0
- {bigraph-schema-0.0.56 → bigraph-schema-0.0.58}/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,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.
|
|
@@ -151,6 +151,52 @@ def set_path(tree, path, value, top=None, cursor=None):
|
|
|
151
151
|
return tree
|
|
152
152
|
|
|
153
153
|
|
|
154
|
+
def set_star_path(tree, path, value, top=None, cursor=()):
|
|
155
|
+
if tree is None:
|
|
156
|
+
tree = {}
|
|
157
|
+
if top is None:
|
|
158
|
+
top = tree
|
|
159
|
+
if path is None or len(path) == 0:
|
|
160
|
+
return tree
|
|
161
|
+
else:
|
|
162
|
+
if isinstance(path, str):
|
|
163
|
+
path = (path,)
|
|
164
|
+
|
|
165
|
+
head = path[0]
|
|
166
|
+
tail = path[1:]
|
|
167
|
+
|
|
168
|
+
if head == '..':
|
|
169
|
+
if len(cursor) == 0:
|
|
170
|
+
raise Exception(
|
|
171
|
+
f'trying to travel above the top of the tree: {path}')
|
|
172
|
+
else:
|
|
173
|
+
return set_star_path(
|
|
174
|
+
top,
|
|
175
|
+
cursor[:-1],
|
|
176
|
+
value)
|
|
177
|
+
elif head == '*':
|
|
178
|
+
for key in value:
|
|
179
|
+
tree[key] = set_star_path(
|
|
180
|
+
{},
|
|
181
|
+
tail,
|
|
182
|
+
value[key],
|
|
183
|
+
cursor=(key,))
|
|
184
|
+
return top
|
|
185
|
+
else:
|
|
186
|
+
if len(tail) == 0:
|
|
187
|
+
tree[head] = value
|
|
188
|
+
return top
|
|
189
|
+
else:
|
|
190
|
+
if head not in tree:
|
|
191
|
+
tree[head] = {}
|
|
192
|
+
return set_star_path(
|
|
193
|
+
tree[head],
|
|
194
|
+
tail,
|
|
195
|
+
value,
|
|
196
|
+
top=top,
|
|
197
|
+
cursor=tuple(cursor) + (head,))
|
|
198
|
+
|
|
199
|
+
|
|
154
200
|
def transform_path(tree, path, transform):
|
|
155
201
|
"""
|
|
156
202
|
Given a tree, a path, and a transform (function), mutate the tree by replacing the subtree at the path by whatever
|
|
@@ -838,7 +838,7 @@ def test_inherits_from(core):
|
|
|
838
838
|
|
|
839
839
|
assert core.inherits_from(
|
|
840
840
|
'tree[path]',
|
|
841
|
-
'tree[list[string]]')
|
|
841
|
+
'tree[list[string~integer]]')
|
|
842
842
|
|
|
843
843
|
assert not core.inherits_from(
|
|
844
844
|
'tree[path]',
|
|
@@ -1861,6 +1861,7 @@ def test_star_path(core):
|
|
|
1861
1861
|
'green': 9999.4,
|
|
1862
1862
|
'yellow': 11,
|
|
1863
1863
|
'blue': 'umbrella'}}}
|
|
1864
|
+
|
|
1864
1865
|
# TODO: can you do everything the * is doing here with _path instead?
|
|
1865
1866
|
nested_path = ['aaa', '*', 'green']
|
|
1866
1867
|
|
|
@@ -1873,6 +1874,51 @@ def test_star_path(core):
|
|
|
1873
1874
|
assert state['ccc'] == 9999.4
|
|
1874
1875
|
|
|
1875
1876
|
|
|
1877
|
+
def test_star_view_project(core):
|
|
1878
|
+
schema = {
|
|
1879
|
+
'edges': 'map[edge[view:map[float],project:map[string]]]',
|
|
1880
|
+
'stores': 'map[map[green:float|yellow:integer|blue:string]]'}
|
|
1881
|
+
|
|
1882
|
+
state = {
|
|
1883
|
+
'edges': {
|
|
1884
|
+
'edge': {
|
|
1885
|
+
'inputs': {
|
|
1886
|
+
'view': ['..', 'stores', 'aaa', '*', 'green']},
|
|
1887
|
+
'outputs': {
|
|
1888
|
+
'project': ['..', 'stores', 'aaa', '*', 'blue']}}},
|
|
1889
|
+
'stores': {
|
|
1890
|
+
'aaa': {
|
|
1891
|
+
'bbb': {
|
|
1892
|
+
'green': 1.1,
|
|
1893
|
+
'yellow': 55,
|
|
1894
|
+
'blue': 'what'},
|
|
1895
|
+
'ccc': {
|
|
1896
|
+
'green': 9999.4,
|
|
1897
|
+
'yellow': 11,
|
|
1898
|
+
'blue': 'umbrella'}}}}
|
|
1899
|
+
|
|
1900
|
+
edge_path = ['edges', 'edge']
|
|
1901
|
+
|
|
1902
|
+
view = core.view_edge(
|
|
1903
|
+
schema,
|
|
1904
|
+
state,
|
|
1905
|
+
edge_path)
|
|
1906
|
+
|
|
1907
|
+
internal = {
|
|
1908
|
+
'project': {
|
|
1909
|
+
'bbb': 'everything',
|
|
1910
|
+
'ccc': 'inside out'}}
|
|
1911
|
+
|
|
1912
|
+
project = core.project_edge(
|
|
1913
|
+
schema,
|
|
1914
|
+
state,
|
|
1915
|
+
edge_path,
|
|
1916
|
+
internal)
|
|
1917
|
+
|
|
1918
|
+
assert view['view']['bbb'] == state['stores']['aaa']['bbb']['green']
|
|
1919
|
+
assert project['stores']['aaa']['ccc']['blue'] == internal['project']['ccc']
|
|
1920
|
+
|
|
1921
|
+
|
|
1876
1922
|
def test_set_slice(core):
|
|
1877
1923
|
float_schema, float_state = core.set_slice(
|
|
1878
1924
|
'map[float]',
|
|
@@ -2342,8 +2388,6 @@ def fix_test_slice_edge(core):
|
|
|
2342
2388
|
|
|
2343
2389
|
schema, state = core.generate(initial_schema, initial_state)
|
|
2344
2390
|
|
|
2345
|
-
import ipdb; ipdb.set_trace()
|
|
2346
|
-
|
|
2347
2391
|
inner_schema, inner_state = core.slice(
|
|
2348
2392
|
schema,
|
|
2349
2393
|
state,
|
|
@@ -2381,6 +2425,58 @@ def fix_test_complex_wiring(core):
|
|
|
2381
2425
|
assert state['AAAA']['AAAAA']['d'] == 0.0
|
|
2382
2426
|
|
|
2383
2427
|
|
|
2428
|
+
def test_tree_equivalence(core):
|
|
2429
|
+
initial_state = {
|
|
2430
|
+
'store1': {
|
|
2431
|
+
'store1.1': '1.0'}}
|
|
2432
|
+
|
|
2433
|
+
# create a nested store type and register it
|
|
2434
|
+
store11 = {
|
|
2435
|
+
'store1.1': {
|
|
2436
|
+
'_type': 'float',
|
|
2437
|
+
'_default': '1.0'}}
|
|
2438
|
+
|
|
2439
|
+
core.register('store1.1', store11)
|
|
2440
|
+
|
|
2441
|
+
# create a tree schema that uses this type
|
|
2442
|
+
store_tree = {
|
|
2443
|
+
'_type': 'tree',
|
|
2444
|
+
'_leaf': 'store1.1'}
|
|
2445
|
+
|
|
2446
|
+
# interpret the state as a simple tree of float
|
|
2447
|
+
store_schema, store_state = core.generate(
|
|
2448
|
+
'tree[float]',
|
|
2449
|
+
initial_state)
|
|
2450
|
+
|
|
2451
|
+
# use the nested type to fill in the state
|
|
2452
|
+
tree_schema, tree_state = core.generate(
|
|
2453
|
+
store_tree,
|
|
2454
|
+
{'store1': None})
|
|
2455
|
+
|
|
2456
|
+
# use the nested type but with an empty dict instead
|
|
2457
|
+
fill_schema, fill_state = core.generate(
|
|
2458
|
+
store_tree,
|
|
2459
|
+
{'store1': {}})
|
|
2460
|
+
|
|
2461
|
+
# supply the whole schema at once instead of registering
|
|
2462
|
+
inline_schema, inline_state = core.generate({
|
|
2463
|
+
'_type': 'tree',
|
|
2464
|
+
'_leaf': {
|
|
2465
|
+
'store1.1': {
|
|
2466
|
+
'_type': 'float',
|
|
2467
|
+
'_default': '1.0'}}},
|
|
2468
|
+
{'store1': {}})
|
|
2469
|
+
|
|
2470
|
+
# here is the state we expect from each of these calls
|
|
2471
|
+
# to generate
|
|
2472
|
+
target_state = {
|
|
2473
|
+
'store1': {
|
|
2474
|
+
'store1.1': 1.0}}
|
|
2475
|
+
|
|
2476
|
+
# all of the resulting generated states are the same
|
|
2477
|
+
assert store_state == tree_state == fill_state == inline_state == target_state
|
|
2478
|
+
|
|
2479
|
+
|
|
2384
2480
|
if __name__ == '__main__':
|
|
2385
2481
|
core = TypeSystem()
|
|
2386
2482
|
core = register_test_types(core)
|
|
@@ -2432,5 +2528,8 @@ if __name__ == '__main__':
|
|
|
2432
2528
|
test_merge(core)
|
|
2433
2529
|
test_remove_omitted(core)
|
|
2434
2530
|
test_union_key_error(core)
|
|
2531
|
+
test_tree_equivalence(core)
|
|
2532
|
+
test_star_view_project(core)
|
|
2533
|
+
|
|
2435
2534
|
# test_slice_edge(core)
|
|
2436
2535
|
# test_complex_wiring(core)
|