-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4698b33
commit b80424e
Showing
6 changed files
with
507 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "03863eaf-3771-47c3-bf76-dec842375ae0", | ||
"metadata": {}, | ||
"source": [ | ||
"# Example Layouts\n", | ||
"\n", | ||
"This section provides useful layout specifications." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "41a72bcd-9e6d-4330-9f41-fd0d60ab545e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Failed to import module h5tbx\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from h5rdmtoolbox import layout\n", | ||
"from h5rdmtoolbox.database import hdfdb\n", | ||
"import h5rdmtoolbox as h5tbx" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d34a1dc2-dff1-4b04-a728-4457e73b9c71", | ||
"metadata": {}, | ||
"source": [ | ||
"## All string dataset must be one-dimensional" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 37, | ||
"id": "2a17a625-ca82-4db6-8c9e-2ad9f46f00e5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"lay = layout.Layout()\n", | ||
"string_dataset_1D = lay.add(\n", | ||
" hdfdb.FileDB.find,\n", | ||
" flt={'$ndim': {'$eq': 1},\n", | ||
" '$dtype': {'$regex': '^(?!S)*'}},\n", | ||
" recursive=True,\n", | ||
" objfilter='dataset',\n", | ||
" description='String dataset must be 1D',\n", | ||
" n={'$gt': 0}\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 38, | ||
"id": "83a7959a-d879-4f7e-9981-063ccf5ca354", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"int32\n", | ||
"|S5\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with h5tbx.File() as h5:\n", | ||
" dss = h5.create_string_dataset('a string ds', data=['one', 'two', 'three'])\n", | ||
" dss = h5.create_string_dataset('grp/a string ds', data=['one', 'two', 'three'])\n", | ||
" dsn = h5.create_dataset('a', data=4)\n", | ||
" print(dsn.dtype)\n", | ||
" print(dss.dtype)\n", | ||
" hdf_filename = h5.hdf_filename" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"id": "fc671941-728f-44c5-8f7d-5399413086ac", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"res = lay.validate(hdf_filename)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 40, | ||
"id": "591ba3e5-015c-46d1-8c46-ecf66f3f1232", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\n", | ||
"Summary of layout validation\n", | ||
"+--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------+\n", | ||
"| id | flag | flag description | description | target_type | target_name | func |\n", | ||
"|--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------|\n", | ||
"| 08d4b8c6-ce67-4a0d-be0d-7c68a353d8e1 | 1 | SUCCESSFUL | String dataset must be 1D | Group | / | h5rdmtoolbox.database.hdfdb.filedb.find |\n", | ||
"+--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------+\n", | ||
"--> Layout is valid\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"res.print_summary(exclude_keys=('called', 'kwargs'))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 41, | ||
"id": "3c2e2739-d5b8-449a-8553-dd0ed6bfe7e4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import re" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 43, | ||
"id": "4c43c5dc-7445-45be-bed1-59eee4fc7c6d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<re.Match object; span=(0, 4), match='M123'>" | ||
] | ||
}, | ||
"execution_count": 43, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"re.search('^(?!S).*', 'M123')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "95ff9f7c-2f9d-4552-bdad-7139e4ea445d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.