Skip to content

Commit 850e872

Browse files
committed
[feat, refactor] refactor dtype map to use Enum DTypes. Implemented constrained dataset. Datastore.model_dump_hdf5 default mode changed to "w".
1 parent 0bc7790 commit 850e872

File tree

7 files changed

+214
-143
lines changed

7 files changed

+214
-143
lines changed

examples/custom_group.ipynb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"import numpy as np\n",
1212
"from rich.pretty import pprint\n",
1313
"\n",
14-
"from oqd_dataschema.base import Dataset, GroupBase, GroupRegistry\n",
14+
"from oqd_dataschema.base import Dataset, GroupBase, GroupRegistry, condataset\n",
1515
"from oqd_dataschema.datastore import Datastore\n",
1616
"from oqd_dataschema.groups import (\n",
1717
" SinaraRawDataGroup,\n",
@@ -29,7 +29,7 @@
2929
" Here we define a custom Group, which is automatically added at runtime to the GroupRegistry.\n",
3030
" \"\"\"\n",
3131
"\n",
32-
" array: Dataset"
32+
" array: condataset(shape_constraint=(None, 10)) # type: ignore"
3333
]
3434
},
3535
{
@@ -119,7 +119,8 @@
119119
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">)</span>,\n",
120120
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">class_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'YourCustomGroup'</span>\n",
121121
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">)</span>\n",
122-
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
122+
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>,\n",
123+
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">attrs</span>=<span style=\"font-weight: bold\">{}</span>\n",
123124
"<span style=\"font-weight: bold\">)</span>\n",
124125
"</pre>\n"
125126
],
@@ -164,7 +165,8 @@
164165
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n",
165166
"\u001b[2;32m│ │ │ \u001b[0m\u001b[33mclass_\u001b[0m=\u001b[32m'YourCustomGroup'\u001b[0m\n",
166167
"\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n",
167-
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
168+
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n",
169+
"\u001b[2;32m│ \u001b[0m\u001b[33mattrs\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m\n",
168170
"\u001b[1m)\u001b[0m\n"
169171
]
170172
},
@@ -230,7 +232,8 @@
230232
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">)</span>,\n",
231233
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">class_</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'YourCustomGroup'</span>\n",
232234
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">)</span>\n",
233-
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
235+
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>,\n",
236+
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #808000; text-decoration-color: #808000\">attrs</span>=<span style=\"font-weight: bold\">{}</span>\n",
234237
"<span style=\"font-weight: bold\">)</span>\n",
235238
"</pre>\n"
236239
],
@@ -275,7 +278,8 @@
275278
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n",
276279
"\u001b[2;32m│ │ │ \u001b[0m\u001b[33mclass_\u001b[0m=\u001b[32m'YourCustomGroup'\u001b[0m\n",
277280
"\u001b[2;32m│ │ \u001b[0m\u001b[1m)\u001b[0m\n",
278-
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
281+
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n",
282+
"\u001b[2;32m│ \u001b[0m\u001b[33mattrs\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m\n",
279283
"\u001b[1m)\u001b[0m\n"
280284
]
281285
},
@@ -287,13 +291,6 @@
287291
"parse = Datastore.model_validate_hdf5(filepath)\n",
288292
"pprint(parse)"
289293
]
290-
},
291-
{
292-
"cell_type": "code",
293-
"execution_count": null,
294-
"metadata": {},
295-
"outputs": [],
296-
"source": []
297294
}
298295
],
299296
"metadata": {

pyproject.toml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ classifiers = [
2626
"Programming Language :: Python :: 3.12",
2727
]
2828

29-
dependencies = [
30-
"bidict>=0.23.1",
31-
"h5py>=3.13.0",
32-
"pydantic>=2.10.6",
33-
]
29+
dependencies = ["h5py>=3.14.0", "pydantic>=2.10.6"]
3430

3531
[project.optional-dependencies]
3632
docs = [
@@ -52,12 +48,7 @@ select = ["E4", "E7", "E9", "F", "I"]
5248
fixable = ["ALL"]
5349

5450
[dependency-groups]
55-
dev = [
56-
"jupyter>=1.1.1",
57-
"pre-commit>=4.1.0",
58-
"rich>=14.1.0",
59-
"ruff>=0.13.1",
60-
]
51+
dev = ["jupyter>=1.1.1", "pre-commit>=4.1.0", "rich>=14.1.0", "ruff>=0.13.1"]
6152

6253

6354
[project.urls]

src/oqd_dataschema/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .base import Dataset, GroupBase, GroupRegistry
15+
from .base import Dataset, GroupBase, GroupRegistry, condataset
1616
from .datastore import Datastore
1717
from .groups import (
1818
ExpectationValueDataGroup,
@@ -32,4 +32,5 @@
3232
"MeasurementOutcomesDataGroup",
3333
"OQDTestbenchDataGroup",
3434
"SinaraRawDataGroup",
35+
"condataset",
3536
]

0 commit comments

Comments
 (0)