diff --git a/notebooks/core.ipynb b/notebooks/core.ipynb index 262cc89..0a5ddd7 100644 --- a/notebooks/core.ipynb +++ b/notebooks/core.ipynb @@ -109,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "a25c1f5b-13ed-4a1e-a1ab-bfcb8b850021", "metadata": {}, "outputs": [ @@ -119,7 +119,7 @@ "dict_keys(['any', 'tuple', 'union', 'boolean', 'number', 'integer', 'float', 'string', 'list', 'tree', 'map', 'array', 'maybe', 'path', 'wires', 'schema', 'edge', 'length', 'time', 'current', 'luminosity', 'mass', 'substance', 'temperature', '', 'length/time', 'length^2*mass/time', 'current*time', 'length^2*mass/temperature*time^2', 'length/time^2', 'mass/length*time^2', 'current*time^2/length^2*mass', 'length^2*mass/current^2*time^3', '/substance', 'length^2*mass/substance*temperature*time^2', 'current*time/substance', 'current^2*time^3/length^2*mass', 'length^2*mass/current*time^2', 'mass/temperature^4*time^3', 'length^4*mass/time^3', 'length*temperature', '/temperature*time', 'length^3/mass*time^2', '/length', 'length*mass/current^2*time^2', 'current^2*time^4/length^3*mass', 'length^3*mass/current^2*time^4', 'length^2', '/time', 'length^3', 'length^3/time', 'length*mass/time^2', 'length^2*mass/time^2', 'length^2*mass/time^3', 'mass/length^3', 'mass/length*time', 'length^2/time', 'length*time/mass', 'substance/length^3', 'substance/time', 'length^2/time^2', 'current*time/mass', 'mass/time^2', 'luminosity/length^2', 'mass/time^3', 'length^2*mass/current*time^3', 'length*mass/current*time^3', 'current^2*time^4/length^2*mass', 'length^2*mass/current^2*time^2', 'mass/current*time^2', 'current*length*time', 'current*length^2*time', 'current*length^2', 'printing_unit', 'printing_unit/length', '/printing_unit', 'mass/length', 'length/mass', 'length^1_5*mass^0_5/time', 'length^0_5*mass^0_5/time', 'length^1_5*mass^0_5/time^2', 'mass^0_5/length^0_5*time', 'time/length', 'length^0_5*mass^0_5', 'mass^0_5/length^1_5', 'time^2/length'])" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -160,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "c0caa21b-1506-44d9-8eaa-13dae215a107", "metadata": {}, "outputs": [ @@ -178,7 +178,7 @@ " '_inherit': ['number']}" ] }, - "execution_count": 3, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -197,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "id": "71304c9e-8915-4122-9c5e-cd287851e385", "metadata": {}, "outputs": [ @@ -221,7 +221,7 @@ " '_description': '64-bit integer'}}" ] }, - "execution_count": 4, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -263,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "id": "723e4d35-251f-45a0-bd13-79577a05faaf", "metadata": {}, "outputs": [ @@ -273,7 +273,7 @@ "True" ] }, - "execution_count": 5, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -284,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 10, "id": "2d66ca35-a17a-435e-a1c9-2bab5affe8d5", "metadata": {}, "outputs": [ @@ -294,7 +294,7 @@ "False" ] }, - "execution_count": 6, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -305,7 +305,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "id": "7dc63b69-c922-4077-b290-bdcdf674997b", "metadata": {}, "outputs": [ @@ -315,7 +315,7 @@ "False" ] }, - "execution_count": 7, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -326,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "id": "b02092aa-389c-4c07-a322-1c012944188f", "metadata": {}, "outputs": [ @@ -336,7 +336,7 @@ "True" ] }, - "execution_count": 8, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -355,7 +355,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 14, "id": "ce87189a-a630-4cda-b9a9-f3eea5665bc7", "metadata": {}, "outputs": [ @@ -380,7 +380,7 @@ " '_type': 'histone'}" ] }, - "execution_count": 9, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -414,7 +414,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 15, "id": "a8098d90-5736-485c-8e34-3b807619d822", "metadata": {}, "outputs": [ @@ -424,7 +424,7 @@ "False" ] }, - "execution_count": 40, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -436,7 +436,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 16, "id": "8468e14d-fd5b-4bd9-aba6-975c070a0802", "metadata": {}, "outputs": [ @@ -446,7 +446,7 @@ "False" ] }, - "execution_count": 41, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -458,7 +458,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 17, "id": "9865f102-34c7-4957-b41f-d982d3050e30", "metadata": {}, "outputs": [ @@ -468,7 +468,7 @@ "False" ] }, - "execution_count": 42, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -480,7 +480,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 18, "id": "4ef3a4eb-37ab-439c-a906-e9debc88b6ad", "metadata": {}, "outputs": [ @@ -490,7 +490,7 @@ "False" ] }, - "execution_count": 43, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -502,7 +502,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 19, "id": "aa1b204c-cf22-40f5-a1f8-76a60975ad92", "metadata": {}, "outputs": [ @@ -512,7 +512,7 @@ "False" ] }, - "execution_count": 44, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -524,7 +524,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 21, "id": "fc572ef5-9667-45f7-bf8c-c8d04ebe3fa3", "metadata": {}, "outputs": [ @@ -534,7 +534,7 @@ "True" ] }, - "execution_count": 45, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -546,7 +546,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 22, "id": "80d242bb-e710-40c6-8347-59898a2babe0", "metadata": {}, "outputs": [ @@ -556,7 +556,7 @@ "True" ] }, - "execution_count": 16, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -620,7 +620,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 24, "id": "19fab013-4954-4ab1-bc3a-a9b977d61cf1", "metadata": {}, "outputs": [ @@ -646,7 +646,7 @@ " '_deserialize': 'deserialize_boolean'}}" ] }, - "execution_count": 17, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -675,7 +675,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 25, "id": "4e8dcbed-1dc1-447a-9e54-6730d2e55b28", "metadata": {}, "outputs": [ @@ -685,7 +685,7 @@ "0.0" ] }, - "execution_count": 46, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -696,7 +696,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 26, "id": "445c24dd-9840-432d-a77e-5827e77b68c1", "metadata": {}, "outputs": [ @@ -706,7 +706,7 @@ "''" ] }, - "execution_count": 47, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -717,7 +717,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 27, "id": "065c4043-004b-4696-8738-8289f553b788", "metadata": {}, "outputs": [ @@ -727,7 +727,7 @@ "{'base': 0, 'state': ''}" ] }, - "execution_count": 48, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -748,7 +748,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 28, "id": "cb4aabb7-d4ff-4a35-bbd4-f79ba8d3e763", "metadata": {}, "outputs": [ @@ -758,7 +758,7 @@ "{'state': 'M', 'base': 0}" ] }, - "execution_count": 49, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -787,7 +787,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 29, "id": "b85bcdd3-6a10-4ed3-a954-9c616d3d1f45", "metadata": {}, "outputs": [ @@ -797,7 +797,7 @@ "5" ] }, - "execution_count": 50, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -832,7 +832,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 30, "id": "1ee2b430-477d-4d55-b4d7-8d29d302487f", "metadata": {}, "outputs": [ @@ -860,7 +860,7 @@ " '_inherit': ['list[string]']}" ] }, - "execution_count": 51, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -879,7 +879,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 31, "id": "cb29529d-2045-4c05-b8ad-5161548010d6", "metadata": {}, "outputs": [ @@ -889,7 +889,7 @@ "False" ] }, - "execution_count": 52, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -900,7 +900,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 32, "id": "c76ba6de-d63c-4976-891c-79e88ea6a0f4", "metadata": {}, "outputs": [ @@ -910,7 +910,7 @@ "[]" ] }, - "execution_count": 53, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -921,7 +921,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 33, "id": "bbbf39c0-5dd8-4f96-8a56-fbfb2aac7a18", "metadata": {}, "outputs": [ @@ -931,7 +931,7 @@ "True" ] }, - "execution_count": 54, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -942,7 +942,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 34, "id": "7c02539a-3a91-41e0-a881-348b0c733044", "metadata": {}, "outputs": [ @@ -952,7 +952,7 @@ "{'a': {'b': ['a', 'x']}, 'x': {'y': ['b']}, 'z': 0.0}" ] }, - "execution_count": 55, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -975,7 +975,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 35, "id": "c176d455-6040-446c-b0ee-5bce851337ca", "metadata": {}, "outputs": [], @@ -1001,7 +1001,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 36, "id": "1bd6147e-8ea3-4bdc-8090-d6c9a4b09d61", "metadata": {}, "outputs": [ @@ -1082,7 +1082,7 @@ " '_inherit': ['tree[path]']}}" ] }, - "execution_count": 57, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -1107,7 +1107,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 37, "id": "839a285e-ae1f-4663-aef3-2789bb57f98f", "metadata": {}, "outputs": [], @@ -1142,7 +1142,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 39, "id": "6d8ea9a3-fb8f-4290-8a73-2a01e7784ae2", "metadata": {}, "outputs": [ @@ -1159,7 +1159,7 @@ " 'emitter': {'total molecules': 0}}" ] }, - "execution_count": 59, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1173,8 +1173,8 @@ }, { "cell_type": "code", - "execution_count": 60, - "id": "dde17d8e", + "execution_count": 40, + "id": "8b6527c9", "metadata": {}, "outputs": [ { @@ -1254,7 +1254,7 @@ " '_inherit': ['tree[path]']}},\n", " 'molecules': {'glucose': {'_type': 'float',\n", " '_check': 'check_float',\n", - " '_apply': 'set',\n", + " '_apply': 'accumulate',\n", " '_serialize': 'to_string',\n", " '_description': '64-bit floating point precision number',\n", " '_default': '0.0',\n", @@ -1398,7 +1398,7 @@ " '_inherit': ['number']}}}" ] }, - "execution_count": 60, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -1409,7 +1409,7 @@ }, { "cell_type": "markdown", - "id": "845f0f8c", + "id": "06b49c3e", "metadata": {}, "source": [ "## view and project\n", @@ -1421,7 +1421,7 @@ }, { "cell_type": "markdown", - "id": "e49e7458", + "id": "3b859449", "metadata": {}, "source": [ "Here are the input paths for our edge, ie the mapping from how the process sees the values it operates on to the actual places in the state where those values live. " @@ -1429,8 +1429,8 @@ }, { "cell_type": "code", - "execution_count": 61, - "id": "67d567b8", + "execution_count": 41, + "id": "57334859", "metadata": {}, "outputs": [ { @@ -1439,7 +1439,7 @@ "{'concentration': ['molecules', 'glucose'], 'field': ['states']}" ] }, - "execution_count": 61, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1450,7 +1450,7 @@ }, { "cell_type": "markdown", - "id": "515c04a2", + "id": "d5f22a21", "metadata": {}, "source": [ "When we \"view\" the state we receive it in the form the edge expects based on its schema and inputs:" @@ -1458,8 +1458,8 @@ }, { "cell_type": "code", - "execution_count": 62, - "id": "3ae50f49", + "execution_count": 42, + "id": "db5153dd", "metadata": {}, "outputs": [ { @@ -1468,7 +1468,7 @@ "{'concentration': 10.0, 'field': {'growth': False}}" ] }, - "execution_count": 62, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1479,7 +1479,7 @@ }, { "cell_type": "markdown", - "id": "9d696186", + "id": "a914d902", "metadata": {}, "source": [ "When instead we \"project\" we are taking a state that's produced by the edge according to its outputs schema and translating that back into wherever the output paths are pointing in the total state:" @@ -1487,8 +1487,8 @@ }, { "cell_type": "code", - "execution_count": 63, - "id": "9b0690dd", + "execution_count": 43, + "id": "003daf71", "metadata": {}, "outputs": [ { @@ -1499,7 +1499,7 @@ " 'delta': ['molecules', 'glucose']}" ] }, - "execution_count": 63, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1510,8 +1510,8 @@ }, { "cell_type": "code", - "execution_count": 64, - "id": "f0c5cc67", + "execution_count": 44, + "id": "314e0726", "metadata": {}, "outputs": [ { @@ -1522,7 +1522,7 @@ " 'molecules': {'glucose': -0.001}}" ] }, - "execution_count": 64, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1538,7 +1538,7 @@ }, { "cell_type": "markdown", - "id": "3c67f2c6", + "id": "ad6a98cc", "metadata": {}, "source": [ "## apply\n", @@ -1548,7 +1548,7 @@ }, { "cell_type": "markdown", - "id": "4d2a9f5d", + "id": "0b726f3c", "metadata": {}, "source": [ "As an example, let's use the projection of the update we computed above:" @@ -1556,8 +1556,8 @@ }, { "cell_type": "code", - "execution_count": 65, - "id": "e4207e2d", + "execution_count": 46, + "id": "b314bfb7", "metadata": {}, "outputs": [ { @@ -1568,12 +1568,12 @@ " 'outputs': {'target': ['states', 'growth'],\n", " 'total': ['emitter', 'total molecules'],\n", " 'delta': ['molecules', 'glucose']}},\n", - " 'molecules': {'glucose': -0.001},\n", + " 'molecules': {'glucose': 9.999},\n", " 'states': {'growth': True},\n", " 'emitter': {'total molecules': 55}}" ] }, - "execution_count": 65, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1587,7 +1587,7 @@ }, { "cell_type": "markdown", - "id": "492816fd", + "id": "2aa4d1fb", "metadata": {}, "source": [ "In this case we see the apply added the update to the existing value. Sometimes this is what we want (this is the meaning of the \"accumulate\" apply method) and sometimes its not. We can also override any of the methods in the schema (notice the original `full_state` is unchanged - applying an update always leaves the original state alone):" @@ -1595,8 +1595,8 @@ }, { "cell_type": "code", - "execution_count": 66, - "id": "c81ee634", + "execution_count": 47, + "id": "d0a228ce", "metadata": {}, "outputs": [ { @@ -1612,7 +1612,7 @@ " 'emitter': {'total molecules': 0}}" ] }, - "execution_count": 66, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1623,8 +1623,8 @@ }, { "cell_type": "code", - "execution_count": 67, - "id": "06a5911c", + "execution_count": 48, + "id": "65693903", "metadata": {}, "outputs": [ { @@ -1640,7 +1640,7 @@ " 'emitter': {'total molecules': 55}}" ] }, - "execution_count": 67, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1653,7 +1653,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0fbaa7ff", + "id": "b5c4e2e9", "metadata": {}, "outputs": [], "source": []