Skip to content

Commit 7b51af6

Browse files
committed
Update research note
1 parent 5c0a2aa commit 7b51af6

File tree

2 files changed

+223
-1
lines changed

2 files changed

+223
-1
lines changed

dev/TypedDictionary.ipynb

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 31,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from typing import TypedDict\n",
10+
"\n"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 33,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"a = TypedDict(\"EntityType\", {\"Words\": str, \"Total Length\": int})"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": 39,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"a.__repr__ = lambda x: \"A\""
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 48,
34+
"metadata": {},
35+
"outputs": [
36+
{
37+
"ename": "TypeError",
38+
"evalue": "dict expected at most 1 argument, got 2",
39+
"output_type": "error",
40+
"traceback": [
41+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
42+
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
43+
"\u001b[0;32m/var/folders/y0/fwkpk2ps087b_2qxvhjstrfr0000gn/T/ipykernel_57262/3336926982.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mTypedDict2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"EntityType\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m\"Words\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"Total Length\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
44+
"\u001b[0;31mTypeError\u001b[0m: dict expected at most 1 argument, got 2"
45+
]
46+
}
47+
],
48+
"source": [
49+
"class TypedDict2(TypedDict):\n",
50+
" def __init__(self, typename, fields):\n",
51+
" super().__init__(typename, fields)\n",
52+
" def __repr__(self) -> str:\n",
53+
" return f\"CustomTypedDict({super().__repr__()})\"\n",
54+
" \n",
55+
" \n",
56+
"TypedDict2(\"EntityType\", {\"Words\": str, \"Total Length\": int})"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": null,
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"\"Volume_per_Unit\"\n",
66+
"\n",
67+
"\"VolumeperUnit\""
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": 49,
73+
"metadata": {},
74+
"outputs": [
75+
{
76+
"data": {
77+
"text/plain": [
78+
"{'Words': str, 'Total Length': int}"
79+
]
80+
},
81+
"execution_count": 49,
82+
"metadata": {},
83+
"output_type": "execute_result"
84+
}
85+
],
86+
"source": [
87+
"TypedDict2({\"Words\": str, \"Total Length\": int})"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": 50,
93+
"metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"class Test(TypedDict):\n",
97+
" Words: str\n",
98+
" Total_Length: int"
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": 47,
104+
"metadata": {},
105+
"outputs": [
106+
{
107+
"name": "stdout",
108+
"output_type": "stream",
109+
"text": [
110+
"<class '__main__.Test'>\n"
111+
]
112+
}
113+
],
114+
"source": [
115+
"print(Test)"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"metadata": {},
122+
"outputs": [],
123+
"source": []
124+
}
125+
],
126+
"metadata": {
127+
"kernelspec": {
128+
"display_name": "BlockScience",
129+
"language": "python",
130+
"name": "python3"
131+
},
132+
"language_info": {
133+
"codemirror_mode": {
134+
"name": "ipython",
135+
"version": 3
136+
},
137+
"file_extension": ".py",
138+
"mimetype": "text/x-python",
139+
"name": "python",
140+
"nbconvert_exporter": "python",
141+
"pygments_lexer": "ipython3",
142+
"version": "3.9.12"
143+
}
144+
},
145+
"nbformat": 4,
146+
"nbformat_minor": 2
147+
}

research_notes/2025-01-27 Concept Specs.md

+76-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,79 @@
5454
- The wirings are similar to a DAG
5555
- A stack block wiring has domain of the first component and codomain of the last component
5656
- A parallel block has the summation of component domains and component codomains
57-
- There are future potential wiring types such as a looping block or having a notation for multiple outputs of the spaces, i.e. similar to if we have 1-N outputs that are variable between a block but they all follow the same codomain space schema
57+
- There are future potential wiring types such as a looping block or having a notation for multiple outputs of the spaces, i.e. similar to if we have 1-N outputs that are variable between a block but they all follow the same codomain space schema
58+
59+
60+
## Proposed Relational Schema V2
61+
62+
### Space
63+
64+
1. ID: PrimaryKey
65+
2. Name: string
66+
3. Description: Optional, string
67+
68+
### Block
69+
70+
1. ID: PrimaryKey
71+
2. Name: string
72+
3. Description: Optional, string
73+
74+
### Ports
75+
76+
1. ID: PrimaryKey
77+
2. Name: string
78+
3. Index: Integer
79+
4. Space: ForeignKey to Space.Name, string
80+
81+
### Terminals
82+
83+
1. ID: PrimaryKey
84+
2. Name: string
85+
3. Index: Integer
86+
4. Space: ForeignKey to Space.Name, string
87+
88+
## Proposed Schema V2
89+
90+
### Space
91+
92+
{"ID": PrimaryKey,
93+
"Name": string,
94+
"Description": string}
95+
96+
### Block
97+
98+
{"ID": PrimaryKey,
99+
"Name": string,
100+
"Description": string,
101+
"Domain": List[Space.ID],
102+
"Codomain": List[Space.ID]}
103+
104+
## Concrete Block
105+
106+
{"ID": PrimaryKey,
107+
"Name": string,
108+
"Description": string,
109+
"Parent": Block.ID}
110+
111+
- It is legal to have many to one concrete blocks of abstract blocks
112+
113+
## Wire (Concrete Space)
114+
115+
{"ID": PrimaryKey,
116+
"Parent": Space.ID,
117+
"SourceBlock": ConcreteBlock.ID,
118+
"TargetBlock": ConcreteBlock.ID,
119+
"SourceIndex": int,
120+
"TargetIndex": int}
121+
122+
- Check matches up
123+
124+
## System
125+
126+
{"ConcreteBlocks": List[ConcreteBlock.ID],
127+
"Wires": List[Wire.ID]}
128+
129+
- Check that:
130+
- All of the ports/domain need to be filled
131+
- All domain ports only get one input
132+
- Terminals can go 0...N ports (and they would just be sending replicas of the same output)

0 commit comments

Comments
 (0)