PyONDE 0.1.2__tar.gz → 0.1.3__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.
- pyonde-0.1.3/.github/workflows/doc.yml +59 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PKG-INFO +6 -1
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE/_version.py +3 -3
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE/onde.py +268 -86
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/PKG-INFO +6 -1
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/SOURCES.txt +1 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/scm_file_list.json +22 -21
- pyonde-0.1.3/PyONDE.egg-info/scm_version.json +8 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/README.md +5 -0
- pyonde-0.1.2/PyONDE.egg-info/scm_version.json +0 -8
- {pyonde-0.1.2 → pyonde-0.1.3}/.github/workflows/push-to-pypi.yml +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/.gitignore +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/.vscode/settings.json +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/LICENSE.txt +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE/__init__.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE/bin/__init__.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE/onde_versions/ONDE_fields_v0.9.1pre.csv +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/dependency_links.txt +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/not-zip-safe +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/PyONDE.egg-info/top_level.txt +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/demos/build_onde_file.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/demos/build_onde_graph.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/demos/build_simple_graph.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/demos/graph_modification.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/demos/load_onde_file.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/LowLevel_Class_Structure.md +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/Makefile +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/PyONDE.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/about.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/architecture.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/conf.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/index.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/installation.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/modules.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/doc/source/quickstart.rst +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/pyproject.toml +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/setup.cfg +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/setup.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/tests/try_array.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/tests/try_csv_read.py +0 -0
- {pyonde-0.1.2 → pyonde-0.1.3}/tests/try_dictionary.py +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Deploy Sphinx Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
# Allow only one concurrent deployment
|
|
15
|
+
concurrency:
|
|
16
|
+
group: "pages"
|
|
17
|
+
cancel-in-progress: true
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
build-and-deploy:
|
|
21
|
+
environment:
|
|
22
|
+
name: github-pages
|
|
23
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout source code
|
|
27
|
+
uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- name: Set up Python
|
|
30
|
+
uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: '3.11'
|
|
33
|
+
cache: 'pip' # Caches dependencies to speed up future runs
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade pip
|
|
38
|
+
pip install sphinx sphinx-rtd-theme # Add any other Sphinx themes or extensions here
|
|
39
|
+
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
|
|
40
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
41
|
+
|
|
42
|
+
- name: Build HTML documentation
|
|
43
|
+
run: |
|
|
44
|
+
# Compiles your .rst/.md files into static HTML
|
|
45
|
+
sphinx-build -b html doc/source doc/build/html
|
|
46
|
+
|
|
47
|
+
- name: Fix GitHub Pages Jekyll behavior
|
|
48
|
+
run: |
|
|
49
|
+
# Sphinx uses folders starting with underscores (like _static), which Jekyll ignores by default
|
|
50
|
+
touch doc/build/html/.nojekyll
|
|
51
|
+
|
|
52
|
+
- name: Upload artifact
|
|
53
|
+
uses: actions/upload-pages-artifact@v3
|
|
54
|
+
with:
|
|
55
|
+
path: 'doc/build/html' # Path to your compiled HTML files
|
|
56
|
+
|
|
57
|
+
- name: Deploy to GitHub Pages
|
|
58
|
+
id: deployment
|
|
59
|
+
uses: actions/deploy-pages@v4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyONDE
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: PyONDE library for reading, modifying, and writing ONDE files
|
|
5
5
|
Home-page: http://github.com/isuthermography/PyONDE
|
|
6
6
|
Author: Stephen D. Holland
|
|
@@ -29,6 +29,11 @@ More information and documentation in the doc/ folder and at
|
|
|
29
29
|
https://isuthermography.github.io/PyONDE/ and at
|
|
30
30
|
https://github.com/isuthermography/PyONDE
|
|
31
31
|
|
|
32
|
+
Acknowledgments
|
|
33
|
+
---------------
|
|
34
|
+
|
|
35
|
+
Thanks to Abhigyaan Deep for helping with some of the coating
|
|
36
|
+
|
|
32
37
|
|
|
33
38
|
Copyright 2026 Stephen D. Holland and Iowa State University
|
|
34
39
|
Research Foundation
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.3'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 3)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g5359d8d4c'
|
|
@@ -17,10 +17,14 @@ from dataclasses import dataclass, field
|
|
|
17
17
|
from typing import Optional, Any
|
|
18
18
|
import numpy as np
|
|
19
19
|
|
|
20
|
+
enable_hierarchical = False
|
|
21
|
+
|
|
20
22
|
onde_basic_attrs = {
|
|
21
23
|
"ONDEValue":(
|
|
22
24
|
"_freeze",
|
|
23
25
|
"_frozen",
|
|
26
|
+
"_referencedby",
|
|
27
|
+
"_file_realizations",
|
|
24
28
|
"_get_attr",
|
|
25
29
|
"_get_data",
|
|
26
30
|
"_set_attr",
|
|
@@ -31,6 +35,8 @@ onde_basic_attrs = {
|
|
|
31
35
|
"ONDEArray":(
|
|
32
36
|
"_freeze",
|
|
33
37
|
"_frozen",
|
|
38
|
+
"_referencedby",
|
|
39
|
+
"_file_realizations",
|
|
34
40
|
"_get_attr",
|
|
35
41
|
"_get_data",
|
|
36
42
|
"_set_attr",
|
|
@@ -41,6 +47,8 @@ onde_basic_attrs = {
|
|
|
41
47
|
"ONDEReferenceArray":(
|
|
42
48
|
"_freeze",
|
|
43
49
|
"_frozen",
|
|
50
|
+
"_referencedby",
|
|
51
|
+
"_file_realizations",
|
|
44
52
|
"_get_attr",
|
|
45
53
|
"_get_data",
|
|
46
54
|
"_get_item",
|
|
@@ -53,6 +61,8 @@ onde_basic_attrs = {
|
|
|
53
61
|
"ONDEObject":(
|
|
54
62
|
"_freeze",
|
|
55
63
|
"_frozen",
|
|
64
|
+
"_referencedby",
|
|
65
|
+
"_file_realizations",
|
|
56
66
|
"_get_attr",
|
|
57
67
|
"_set_attr",
|
|
58
68
|
"_has_attr",
|
|
@@ -237,7 +247,7 @@ class TwoWayDictionary(object):
|
|
|
237
247
|
pass
|
|
238
248
|
pass
|
|
239
249
|
|
|
240
|
-
def _del_attr(self,name):
|
|
250
|
+
def _del_attr(self,name,valueignored):
|
|
241
251
|
_bystrings = object.__getattribute__(self, "_bystrings")
|
|
242
252
|
_byobjid = object.__getattribute__(self, "_byobjid")
|
|
243
253
|
_lock = object.__getattribute__(self, "_lock")
|
|
@@ -267,7 +277,7 @@ class TwoWayDictionary(object):
|
|
|
267
277
|
return self._get_attr(name)
|
|
268
278
|
|
|
269
279
|
def __delitem__(self,name):
|
|
270
|
-
return self._del_attr(name)
|
|
280
|
+
return self._del_attr(name,None)
|
|
271
281
|
|
|
272
282
|
def _freeze(self):
|
|
273
283
|
object.__setattr__(self, "_frozen", True)
|
|
@@ -733,7 +743,7 @@ class ONDEBase(object):
|
|
|
733
743
|
|
|
734
744
|
def __getattribute__(self,name):
|
|
735
745
|
if name.startswith("_"):
|
|
736
|
-
if name in {"_freeze", "_frozen", "_add_referencedby", "__class__", "__dir__", "_get_attr","_get_attr_dataset_storage", "_set_attr","_set_dataset_attr","_get_data","_set_data","_get_item","_list_items","_set_item","_follow_path","_modification_scopes","_indices_for_object","_assign_pathel","_list_edges", "_repr", "_repr_short","_hdf5_write_group","_hdf5_write_dataset","_hdf5_write_attribute","_file_realizations","_file_realizations_lock","_add_dataset"}:
|
|
746
|
+
if name in {"_freeze", "_frozen", "_add_referencedby", "__class__", "__dir__", "_get_attr","_get_attr_dataset_storage", "_set_attr","_has_attr","_set_dataset_attr","_get_data","_set_data","_get_item","_list_items","_set_item","_follow_path","_modification_scopes","_indices_for_object","_assign_pathel","_list_edges", "_repr", "_repr_short","_hdf5_write_group","_hdf5_write_dataset","_hdf5_write_attribute","_file_realizations","_file_realizations_lock","_add_dataset"}:
|
|
737
747
|
return object.__getattribute__(self, name)
|
|
738
748
|
raise IndexError(f"ONDEBase: The attribute {name:s} has a leading underscore, which is not allowed.")
|
|
739
749
|
raise IndexError(f"ONDEBase: Unknown attribute {name:s}")
|
|
@@ -814,12 +824,12 @@ class ONDEBase(object):
|
|
|
814
824
|
"""
|
|
815
825
|
raise ValueError("ONDEBase does not have content to write")
|
|
816
826
|
|
|
817
|
-
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
827
|
+
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
818
828
|
"""Write this object to a new hdf5 dataset
|
|
819
829
|
"""
|
|
820
830
|
raise ValueError("ONDEBase does not have content to write")
|
|
821
831
|
|
|
822
|
-
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
832
|
+
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
823
833
|
"""Write this object to a new hdf5 attribute
|
|
824
834
|
"""
|
|
825
835
|
raise ValueError("ONDEBase does not have content to write")
|
|
@@ -965,7 +975,7 @@ class ONDEValue(ONDEBase):
|
|
|
965
975
|
**extra_attrs)
|
|
966
976
|
|
|
967
977
|
|
|
968
|
-
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
978
|
+
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
969
979
|
"""Write this object to a new hdf5 attribute
|
|
970
980
|
"""
|
|
971
981
|
parent.attrs[name] = self.value
|
|
@@ -1124,13 +1134,13 @@ class ONDEArray(ONDEBase):
|
|
|
1124
1134
|
shape=str(object.__getattribute__(self, 'value').shape),
|
|
1125
1135
|
**extra_attrs)
|
|
1126
1136
|
|
|
1127
|
-
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
1137
|
+
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
1128
1138
|
"""Write this object to a new hdf5 attribute
|
|
1129
1139
|
"""
|
|
1130
1140
|
parent.attrs[name] = self.value
|
|
1131
1141
|
pass
|
|
1132
1142
|
|
|
1133
|
-
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
1143
|
+
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
1134
1144
|
"""Write this object to a new hdf5 dataset
|
|
1135
1145
|
"""
|
|
1136
1146
|
ds = parent.create_dataset(name,data = self.value)
|
|
@@ -1323,7 +1333,7 @@ class ONDEReferenceArray(ONDEBase):
|
|
|
1323
1333
|
shape=str(object.__getattribute__(self, 'refs')._shape),
|
|
1324
1334
|
**extra_attrs)
|
|
1325
1335
|
|
|
1326
|
-
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
1336
|
+
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj, hierarchical_write):
|
|
1327
1337
|
"""Write this object to a new hdf5 attribute
|
|
1328
1338
|
"""
|
|
1329
1339
|
ref_dtype = h5py.special_dtype(ref = h5py.Reference)
|
|
@@ -1336,14 +1346,57 @@ class ONDEReferenceArray(ONDEBase):
|
|
|
1336
1346
|
obj = objarray[()]
|
|
1337
1347
|
if obj is not None:
|
|
1338
1348
|
# !!!*** This may need to be accelerated by caching the hdf5 object references per the various discussions on h5py indexing performance with Paul Wilcox, early 2026. https://github.com/COFREND/ONDE-format/issues/24
|
|
1349
|
+
|
|
1350
|
+
if enable_hierarchical and hierarchical_write and obj not in onde_file.file_object_dict:
|
|
1351
|
+
# This object has not been inserted yet, and this being a reference array, we cannot insert it here. So instead, place it in the PyONDE_DB
|
|
1352
|
+
|
|
1353
|
+
obj_name = f"{onde_file.db_maxidx + 1:05d}"
|
|
1354
|
+
onde_file.db_maxidx += 1
|
|
1355
|
+
|
|
1356
|
+
obj._hdf5_write_group(onde_file,onde_file.fh["PyONDE_DB"],"/PyONDE_DB",obj_name,hierarchical_write)
|
|
1357
|
+
pass
|
|
1358
|
+
|
|
1359
|
+
|
|
1339
1360
|
h5_byindex[nditer.multi_index] = onde_file.fh[onde_file.file_object_dict[obj].hdf5_path].ref
|
|
1340
1361
|
pass
|
|
1341
1362
|
pass
|
|
1342
1363
|
|
|
1343
1364
|
parent.attrs[name] = h5_byindex
|
|
1344
1365
|
pass
|
|
1366
|
+
|
|
1367
|
+
def _hdf5_write_group(self,onde_file,parent,parent_path,name, hierarchical_write):
|
|
1368
|
+
"""Write this object to a new hdf5 group. This group contains a "shape" attribute and a bunch of subgroups or alternatively attributes with hdf5 references named according to the element indices: (00001,00005) etc. the numbers are integers with a minimum of 5 digits, separated by commas and surrounded by parentheses with no spaces.
|
|
1369
|
+
"""
|
|
1370
|
+
|
|
1371
|
+
gr = parent.create_group(name)
|
|
1372
|
+
|
|
1373
|
+
byindex = self.refs.byindex
|
|
1374
|
+
gr.attrs["ONDE:SHAPE"] = byindex.shape
|
|
1375
|
+
assert(hierarchical_write)
|
|
1376
|
+
nditer = np.nditer(byindex, flags = ("multi_index","refs_ok"))
|
|
1377
|
+
|
|
1378
|
+
for objarray in nditer:
|
|
1379
|
+
obj = objarray[()]
|
|
1380
|
+
if obj is not None:
|
|
1381
|
+
|
|
1382
|
+
index_tuple = nditer.multi_index
|
|
1383
|
+
subgroup_name = "(" + ",".join([f"{idx:05d}" for idx in index_tuple]) + ")"
|
|
1384
|
+
|
|
1385
|
+
if obj not in onde_file.file_object_dict:
|
|
1386
|
+
# This object has not been inserted yet, we insert it here.
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
obj._hdf5_write_group(onde_file,gr,gr.name,subgroup_name,hierarchical_write)
|
|
1390
|
+
pass
|
|
1391
|
+
else:
|
|
1392
|
+
gr.attrs[subgroup_name] = onde_file.fh[onde_file.file_object_dict[obj].hdf5_path].ref
|
|
1393
|
+
pass
|
|
1394
|
+
pass
|
|
1395
|
+
pass
|
|
1396
|
+
|
|
1397
|
+
pass
|
|
1345
1398
|
|
|
1346
|
-
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
1399
|
+
def _hdf5_write_dataset(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
1347
1400
|
"""Write this object to a new hdf5 dataset
|
|
1348
1401
|
"""
|
|
1349
1402
|
ref_dtype = h5py.special_dtype(ref = h5py.Reference)
|
|
@@ -1356,6 +1409,16 @@ class ONDEReferenceArray(ONDEBase):
|
|
|
1356
1409
|
obj = objarray[()]
|
|
1357
1410
|
if obj is not None:
|
|
1358
1411
|
# !!!*** This may need to be accelerated by caching the hdf5 object references per the various discussions on h5py indexing performance with Paul Wilcox, early 2026. https://github.com/COFREND/ONDE-format/issues/24
|
|
1412
|
+
|
|
1413
|
+
if enable_hierarchical and hierarchical_write and obj not in onde_file.file_object_dict:
|
|
1414
|
+
# This object has not been inserted yet, and this being a reference array, we cannot insert it here. So instead, place it in the PyONDE_DB
|
|
1415
|
+
|
|
1416
|
+
obj_name = f"{onde_file.db_maxidx + 1:05d}"
|
|
1417
|
+
onde_file.db_maxidx += 1
|
|
1418
|
+
|
|
1419
|
+
obj._hdf5_write_group(onde_file,onde_file.fh["PyONDE_DB"],"/PyONDE_DB",obj_name,hierarchical_write)
|
|
1420
|
+
pass
|
|
1421
|
+
|
|
1359
1422
|
h5_byindex[nditer.multi_index] = onde_file.fh[onde_file.file_object_dict[obj].hdf5_path].ref
|
|
1360
1423
|
pass
|
|
1361
1424
|
pass
|
|
@@ -1393,6 +1456,27 @@ class ONDEReferenceArray(ONDEBase):
|
|
|
1393
1456
|
instance = cls(None,refs = refs, shape = np_h5ref_array.shape)
|
|
1394
1457
|
return instance
|
|
1395
1458
|
|
|
1459
|
+
@classmethod
|
|
1460
|
+
def load_from_hdf5_group(cls,onde_file,fileobjs_by_h5path,h5_fh,h5_group):
|
|
1461
|
+
#shape = ast.literal_eval(h5_group.attrs["shape"])
|
|
1462
|
+
shape = tuple(h5_group.attrs["ONDE:SHAPE"])
|
|
1463
|
+
|
|
1464
|
+
refs = np.empty(shape,dtype = "O")
|
|
1465
|
+
nditer = np.nditer(refs, flags = ("multi_index","refs_ok"))
|
|
1466
|
+
|
|
1467
|
+
for pos in nditer:
|
|
1468
|
+
index_tuple = nditer.multi_index
|
|
1469
|
+
subgroup_name = "(" + ",".join([f"{idx:05d}" for idx in index_tuple]) + ")"
|
|
1470
|
+
if subgroup_name in h5_group:
|
|
1471
|
+
# This is the actual object stored as an hdf5 group
|
|
1472
|
+
refs[nditer.multi_index] = ONDEObject.load_from_hdf5(onde_file,fileobjs_by_h5path,h5_fh,h5_group[subgroup_name])
|
|
1473
|
+
pass
|
|
1474
|
+
elif subgroup_name in h5_group.attrs:
|
|
1475
|
+
# This is a reference stored as an attribute not the actual object
|
|
1476
|
+
refs[nditer.multi_index] = ONDEObject.load_from_hdf5(onde_file,fileobjs_by_h5path,h5_fh,h5_fh[h5_group.attrs[subgroup_name]])
|
|
1477
|
+
pass
|
|
1478
|
+
instance = cls(None,refs = refs, shape = shape)
|
|
1479
|
+
return instance
|
|
1396
1480
|
pass
|
|
1397
1481
|
|
|
1398
1482
|
|
|
@@ -1466,7 +1550,7 @@ class ONDEObject(ONDEBase):
|
|
|
1466
1550
|
|
|
1467
1551
|
def __getattribute__(self, name):
|
|
1468
1552
|
if name.startswith("_"):
|
|
1469
|
-
if name in {"_freeze", "_frozen", "_add_referencedby", "__class__", "__dir__", "_get_attr","_get_attr_dataset_storage", "_set_attr","_set_dataset_attr","_follow_path","_modification_scopes","_indices_for_object","_assign_pathel","_list_edges","_ONDE_attrs","_ONDE_dataset_attrs", "_has_attr","_repr","_repr_short","_hdf5_write_group","_list_attrs","_hdf5_write_dataset","_hdf5_write_attribute","_file_realizations","_file_realizations_lock","_onde_class_name","_get_item","_set_item","_list_items","_has_item"}:
|
|
1553
|
+
if name in {"_freeze", "_frozen", "_add_referencedby", "__class__", "__dir__", "_get_attr","_get_attr_dataset_storage", "_set_attr","_set_dataset_attr","_follow_path","_modification_scopes","_indices_for_object","_assign_pathel","_list_edges","_ONDE_attrs","_ONDE_dataset_attrs", "_has_attr","_repr","_repr_short","_hdf5_write_group","_list_attrs","_hdf5_write_dataset","_hdf5_write_attribute","_file_realizations","_file_realizations_lock","_onde_class_name","_get_item","_set_item","_list_items","_has_item","_del_item"}:
|
|
1470
1554
|
return object.__getattribute__(self, name)
|
|
1471
1555
|
raise IndexError("ONDEObject: Attributes may not have leading underscores")
|
|
1472
1556
|
|
|
@@ -1490,6 +1574,25 @@ class ONDEObject(ONDEBase):
|
|
|
1490
1574
|
def _set_item(self,name,value):
|
|
1491
1575
|
return self._set_attr(name,value)
|
|
1492
1576
|
|
|
1577
|
+
def _del_item(self,name,valueignored):
|
|
1578
|
+
"""
|
|
1579
|
+
Set the named conceptual attribute of an ONDE object. Use _set_dataset_attr() instead if the attribute should have hdf5 dataset storage.
|
|
1580
|
+
"""
|
|
1581
|
+
_frozen = object.__getattribute__(self, "_frozen")
|
|
1582
|
+
if _frozen:
|
|
1583
|
+
raise RuntimeError("Attempting to modify an object that is already frozen")
|
|
1584
|
+
|
|
1585
|
+
|
|
1586
|
+
if name.startswith("_"):
|
|
1587
|
+
raise ValueError(f"Attributes such as \"{name:s}\" with leading underscores not allowed")
|
|
1588
|
+
|
|
1589
|
+
_ONDE_attrs = object.__getattribute__(self, "_ONDE_attrs")
|
|
1590
|
+
_ONDE_dataset_attrs = object.__getattribute__(self, "_ONDE_dataset_attrs")
|
|
1591
|
+
|
|
1592
|
+
_ONDE_dataset_attrs.discard(name)
|
|
1593
|
+
return _ONDE_attrs._del_attr(name, valueignored)
|
|
1594
|
+
|
|
1595
|
+
|
|
1493
1596
|
def __getitem__(self,name):
|
|
1494
1597
|
return self._get_attr(name)
|
|
1495
1598
|
|
|
@@ -1590,7 +1693,7 @@ class ONDEObject(ONDEBase):
|
|
|
1590
1693
|
|
|
1591
1694
|
def __dir__(self):
|
|
1592
1695
|
_ONDE_attrs = object.__getattribute__(self, "_ONDE_attrs")
|
|
1593
|
-
return ["_freeze","_frozen"] + [attrname for attrname in _ONDE_attrs]
|
|
1696
|
+
return ["_freeze","_frozen","_referencedby","_file_realizations"] + [attrname for attrname in _ONDE_attrs]
|
|
1594
1697
|
|
|
1595
1698
|
def _freeze(self):
|
|
1596
1699
|
_frozen = object.__getattribute__(self, "_frozen")
|
|
@@ -1702,25 +1805,44 @@ class ONDEObject(ONDEBase):
|
|
|
1702
1805
|
pass
|
|
1703
1806
|
return classname
|
|
1704
1807
|
|
|
1705
|
-
def _hdf5_write_group(self,onde_file,parent,parent_path,name,
|
|
1808
|
+
def _hdf5_write_group(self,onde_file,parent,parent_path,name,hierarchical_write = False):
|
|
1706
1809
|
"""Write this object to a new hdf5 group
|
|
1707
1810
|
"""
|
|
1811
|
+
|
|
1812
|
+
fileobj = ONDEFileObject(onde_instance = self,hdf5_path = posixpath.join(parent_path,name))
|
|
1813
|
+
|
|
1708
1814
|
gr = parent.create_group(name)
|
|
1709
1815
|
for attrname in self._ONDE_attrs:
|
|
1710
1816
|
value = self._ONDE_attrs[attrname]
|
|
1711
1817
|
if attrname in self._ONDE_dataset_attrs:
|
|
1712
1818
|
if isinstance(value,ONDEObject) or isinstance(value,ONDEValue):
|
|
1713
1819
|
raise ValueError(f"Error writing ONDE object of class {self._onde_class_name()}: Attribute {attrname} is marked for dataset storage, but is an {type(value).__name__} not an ONDEArray or ONDEReferenceArray")
|
|
1714
|
-
value._hdf5_write_dataset(onde_file,gr,gr.name,attrname,None)
|
|
1820
|
+
value._hdf5_write_dataset(onde_file,gr,gr.name,attrname,None,hierarchical_write)
|
|
1715
1821
|
pass
|
|
1716
1822
|
else:
|
|
1717
|
-
|
|
1823
|
+
if enable_hierarchical and onde_file.hierarchical and hierarchical_write and isinstance(value,ONDEObject):
|
|
1824
|
+
if value in onde_file.file_object_dict:
|
|
1825
|
+
value._hdf5_write_attribute(onde_file,gr,gr.name,attrname,None,hierarchical_write)
|
|
1826
|
+
pass
|
|
1827
|
+
else:
|
|
1828
|
+
obj_name = attrname
|
|
1829
|
+
value._hdf5_write_group(onde_file,gr,gr.name,obj_name,hierarchical_write)
|
|
1830
|
+
pass
|
|
1831
|
+
pass
|
|
1832
|
+
elif enable_hierarchical and onde_file.hierarchical and hierarchical_write and isinstance(value,ONDEReferenceArray):
|
|
1833
|
+
value._hdf5_write_group(onde_file,gr,gr.name,attrname,hierarchical_write)
|
|
1834
|
+
pass
|
|
1835
|
+
else:
|
|
1836
|
+
# Nonhierarchical mode or non-ONDEObject. We write an hdf5 reference as an attribute.
|
|
1837
|
+
value._hdf5_write_attribute(onde_file,gr,gr.name,attrname,None,hierarchical_write)
|
|
1838
|
+
pass
|
|
1718
1839
|
pass
|
|
1719
1840
|
pass
|
|
1841
|
+
onde_file.file_object_dict[self] = fileobj
|
|
1720
1842
|
|
|
1721
1843
|
pass
|
|
1722
1844
|
|
|
1723
|
-
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj):
|
|
1845
|
+
def _hdf5_write_attribute(self,onde_file,parent,parent_path,name,onde_fileobj,hierarchical_write):
|
|
1724
1846
|
"""Write a reference to this object to a new hdf5 attribute
|
|
1725
1847
|
"""
|
|
1726
1848
|
parent.attrs[name] = onde_file.fh[onde_file.file_object_dict[self].hdf5_path].ref
|
|
@@ -1812,9 +1934,18 @@ class ONDEObject(ONDEBase):
|
|
|
1812
1934
|
pass
|
|
1813
1935
|
pass
|
|
1814
1936
|
elif isinstance(h5_attr,h5py.Reference):
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1937
|
+
ref=h5_fh[h5_attr]
|
|
1938
|
+
if isinstance(ref,h5py.Dataset):
|
|
1939
|
+
# ONDE_DATASET:DATA is uniquely allowed to be a reference to an HDF5 dataset
|
|
1940
|
+
# Array of values
|
|
1941
|
+
attr_obj = ONDEArray.new(value = ref[...])
|
|
1942
|
+
_ONDE_attrs[attrname] = attr_obj
|
|
1943
|
+
_ONDE_dataset_attrs.add(attrname)
|
|
1944
|
+
pass
|
|
1945
|
+
else:
|
|
1946
|
+
attr_obj = ONDEObject.load_from_hdf5(onde_file, fileobjs_by_h5path, h5_fh, ref)
|
|
1947
|
+
_ONDE_attrs[attrname] = attr_obj
|
|
1948
|
+
pass
|
|
1818
1949
|
pass
|
|
1819
1950
|
else:
|
|
1820
1951
|
raise ValueError(f"Unknown hdf5 attribute type: {type(h5_attr).__name__:s}")
|
|
@@ -1837,9 +1968,17 @@ class ONDEObject(ONDEBase):
|
|
|
1837
1968
|
_ONDE_dataset_attrs.add(subname)
|
|
1838
1969
|
pass
|
|
1839
1970
|
pass
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1971
|
+
elif enable_hierarchical and isinstance(subobj,h5py.Group): # These lines will enable support for hierarchical ONDE files
|
|
1972
|
+
if not "ONDE:TYPE" in subobj.attrs and "ONDE:SHAPE" in subobj.attrs:
|
|
1973
|
+
# Must be an ONDEReferenceArray stored as an hdf5 group
|
|
1974
|
+
attr_obj = ONDEReferenceArray.load_from_hdf5_group(onde_file,fileobjs_by_h5path,h5_fh,subobj)
|
|
1975
|
+
pass
|
|
1976
|
+
else:
|
|
1977
|
+
|
|
1978
|
+
attr_obj = ONDEObject.load_from_hdf5(onde_file, fileobjs_by_h5path, h5_fh, subobj)
|
|
1979
|
+
pass
|
|
1980
|
+
_ONDE_attrs[subname] = attr_obj
|
|
1981
|
+
pass
|
|
1843
1982
|
else:
|
|
1844
1983
|
raise ValueError(f"Unknown h5type {type(subobj).__name__:s} at hdf5 path {h5_group.name:s}")
|
|
1845
1984
|
pass
|
|
@@ -2121,7 +2260,7 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2121
2260
|
pass
|
|
2122
2261
|
|
|
2123
2262
|
full_name = key
|
|
2124
|
-
if get_method_name == "_get_attr":
|
|
2263
|
+
if get_method_name == "_get_attr" and isinstance(_obj,ONDEObject):
|
|
2125
2264
|
(full_name, field) = self._full_fieldname_from_attrname(_graph, _obj, key)
|
|
2126
2265
|
if full_name is None:
|
|
2127
2266
|
full_name = key
|
|
@@ -2205,12 +2344,12 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2205
2344
|
|
|
2206
2345
|
full_name = key
|
|
2207
2346
|
field = None
|
|
2208
|
-
if set_method_name == "_set_attr" or set_method_name == "_set_dataset_attr":
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
pass
|
|
2347
|
+
#if set_method_name == "_set_attr" or set_method_name == "_set_dataset_attr":
|
|
2348
|
+
(full_name, field) = self._full_fieldname_from_attrname(_graph, our_obj, key)
|
|
2349
|
+
if full_name is None:
|
|
2350
|
+
full_name = key
|
|
2213
2351
|
pass
|
|
2352
|
+
|
|
2214
2353
|
|
|
2215
2354
|
if field is not None and set_method_name == "_set_attr":
|
|
2216
2355
|
# For now, if field.storage is "A or D", we always just store it as a dataset.
|
|
@@ -2218,8 +2357,20 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2218
2357
|
set_method_name = "_set_dataset_attr"
|
|
2219
2358
|
pass
|
|
2220
2359
|
pass
|
|
2221
|
-
|
|
2222
|
-
|
|
2360
|
+
if set_method_name == "_del_item" or isinstance(value,ONDEProxy) or isinstance(value,ONDEBase):
|
|
2361
|
+
if our_proxy is not None:
|
|
2362
|
+
set_method = getattr(our_proxy,set_method_name)
|
|
2363
|
+
set_method(full_name,value)
|
|
2364
|
+
pass
|
|
2365
|
+
elif our_obj is not None:
|
|
2366
|
+
set_method = getattr(our_obj,set_method_name)
|
|
2367
|
+
set_method(full_name,value)
|
|
2368
|
+
pass
|
|
2369
|
+
else:
|
|
2370
|
+
assert(False)
|
|
2371
|
+
pass
|
|
2372
|
+
pass
|
|
2373
|
+
elif isinstance(value,ONDEClassInstanceWrapper):
|
|
2223
2374
|
target_proxy = object.__getattribute__(value,"_proxy")
|
|
2224
2375
|
target_obj = object.__getattribute__(value,"_obj")
|
|
2225
2376
|
if our_proxy is not None and target_proxy is not None:
|
|
@@ -2242,32 +2393,7 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2242
2393
|
assert(False) # Exactly one of _obj and _proxy should be valid
|
|
2243
2394
|
pass
|
|
2244
2395
|
pass
|
|
2245
|
-
|
|
2246
|
-
if our_proxy is not None:
|
|
2247
|
-
set_method = getattr(our_proxy,set_method_name)
|
|
2248
|
-
set_method(full_name,value)
|
|
2249
|
-
pass
|
|
2250
|
-
elif our_obj is not None:
|
|
2251
|
-
set_method = getattr(our_obj,set_method_name)
|
|
2252
|
-
set_method(full_name,value._get_obj())
|
|
2253
|
-
pass
|
|
2254
|
-
else:
|
|
2255
|
-
assert(False)
|
|
2256
|
-
pass
|
|
2257
|
-
pass
|
|
2258
|
-
elif isinstance(value,ONDEBase):
|
|
2259
|
-
if our_proxy is not None:
|
|
2260
|
-
set_method = getattr(our_proxy,set_method_name)
|
|
2261
|
-
set_method(full_name,value)
|
|
2262
|
-
pass
|
|
2263
|
-
elif our_obj is not None:
|
|
2264
|
-
set_method = getattr(our_obj,set_method_name)
|
|
2265
|
-
set_method(full_name,value)
|
|
2266
|
-
pass
|
|
2267
|
-
else:
|
|
2268
|
-
assert(False)
|
|
2269
|
-
pass
|
|
2270
|
-
pass
|
|
2396
|
+
|
|
2271
2397
|
else:
|
|
2272
2398
|
#raise ValueError(f"Attribute values should be ONDEBase or ONDEProxy or ONDEClassInstanceWrapper")
|
|
2273
2399
|
#build an object from python structures
|
|
@@ -2306,6 +2432,10 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2306
2432
|
self._set_attr_or_item("_set_item",index,value)
|
|
2307
2433
|
pass
|
|
2308
2434
|
|
|
2435
|
+
def _del_item(self,index,value):
|
|
2436
|
+
self._set_attr_or_item("_del_item",index,value)
|
|
2437
|
+
pass
|
|
2438
|
+
|
|
2309
2439
|
def _get_data(self,name):
|
|
2310
2440
|
_proxy = object.__getattribute__(self,"_proxy")
|
|
2311
2441
|
_obj = object.__getattribute__(self,"_obj")
|
|
@@ -2478,8 +2608,14 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2478
2608
|
def __getattribute__(self,name):
|
|
2479
2609
|
if name.startswith('_'):
|
|
2480
2610
|
return object.__getattribute__(self,name)
|
|
2611
|
+
|
|
2612
|
+
get_method_name = "_get_attr"
|
|
2481
2613
|
|
|
2482
|
-
|
|
2614
|
+
obj = self._get_obj()
|
|
2615
|
+
if isinstance(obj,ONDEReferenceArray) or isinstance(obj,ONDEArray) or isinstance(obj,ONDEValue):
|
|
2616
|
+
get_method_name = "_get_data"
|
|
2617
|
+
pass
|
|
2618
|
+
return self._get_attr_or_item(get_method_name,name)
|
|
2483
2619
|
obsolete = r"""
|
|
2484
2620
|
if self._proxy is not None:
|
|
2485
2621
|
obj = self._proxy._get_obj()
|
|
@@ -2538,6 +2674,10 @@ class ONDEClassInstanceWrapper(object):
|
|
|
2538
2674
|
self._set_attr_or_item("_set_item",key,value)
|
|
2539
2675
|
return
|
|
2540
2676
|
|
|
2677
|
+
def __delitem__(self,key):
|
|
2678
|
+
self._set_attr_or_item("_del_item",key,None)
|
|
2679
|
+
return
|
|
2680
|
+
|
|
2541
2681
|
def __getitem__(self,key):
|
|
2542
2682
|
return self._get_attr_or_item("_get_item",key)
|
|
2543
2683
|
|
|
@@ -3273,7 +3413,7 @@ class ONDEProxy(object):
|
|
|
3273
3413
|
|
|
3274
3414
|
def __getattribute__(self, name):
|
|
3275
3415
|
if name.startswith("_"):
|
|
3276
|
-
if name in { "_set_attr","_set_dataset_attr", "_get_attr","_get_attr_dataset_storage","_get_item","_set_item","_get_data","_set_data","_set_attr_or_item_or_data","_get_obj","_follow_path","__class__","__dict__","_graph","_repr","_repr_short","_add_dataset"}:
|
|
3416
|
+
if name in { "_set_attr","_set_dataset_attr", "_get_attr","_get_attr_dataset_storage","_get_item","_set_item","_get_data","_set_data","_set_attr_or_item_or_data","_get_obj","_follow_path","__class__","__dict__","_graph","_repr","_repr_short","_add_dataset","__getitem__","_del_item"}:
|
|
3277
3417
|
return object.__getattribute__(self, name)
|
|
3278
3418
|
elif name in {"_freeze", "_frozen",}:
|
|
3279
3419
|
obj = self._get_obj()
|
|
@@ -3344,7 +3484,12 @@ class ONDEProxy(object):
|
|
|
3344
3484
|
def _set_attr(self, name, value):
|
|
3345
3485
|
self._set_attr_or_item_or_data('_set_attr', name, value)
|
|
3346
3486
|
pass
|
|
3487
|
+
|
|
3488
|
+
def _del_item(self, name, value):
|
|
3489
|
+
self._set_attr_or_item_or_data('_del_item', name, value)
|
|
3490
|
+
pass
|
|
3347
3491
|
|
|
3492
|
+
|
|
3348
3493
|
def _add(self,dataset):
|
|
3349
3494
|
"""add() method for proxying ONDEFileGraphSnapshot"""
|
|
3350
3495
|
# Must maintain parallel logic in ONDEFileGraphSnapshot.add()
|
|
@@ -3392,6 +3537,9 @@ class ONDEProxy(object):
|
|
|
3392
3537
|
def __setitem__(self,index,value):
|
|
3393
3538
|
return self._set_item(index,value)
|
|
3394
3539
|
|
|
3540
|
+
def __delitem__(self,index):
|
|
3541
|
+
return self._del_item(index,None)
|
|
3542
|
+
|
|
3395
3543
|
def _get_data(self, name):
|
|
3396
3544
|
obj = self._get_obj()
|
|
3397
3545
|
data_obj = obj._get_data(name)
|
|
@@ -3408,7 +3556,7 @@ class ONDEProxy(object):
|
|
|
3408
3556
|
pass
|
|
3409
3557
|
|
|
3410
3558
|
def _set_attr_or_item_or_data(self, set_method_name, key, value):
|
|
3411
|
-
''' Use the named set method (_set_attr,_set_dataset_attr, _set_item, or
|
|
3559
|
+
''' Use the named set method (_set_attr,_set_dataset_attr, _set_item, _set_data, or _del_item) to assign the element specified by key to the given value'''
|
|
3412
3560
|
|
|
3413
3561
|
_trans = object.__getattribute__(self, "_trans")
|
|
3414
3562
|
#import pdb
|
|
@@ -3557,15 +3705,18 @@ class ONDEFile(object):
|
|
|
3557
3705
|
db_maxidx = None # integer representing the highest index used in the PyONDE_DB hdf5 group
|
|
3558
3706
|
version = None
|
|
3559
3707
|
filetype = None
|
|
3708
|
+
hierarchical = None
|
|
3709
|
+
file_is_blank = None
|
|
3560
3710
|
|
|
3561
|
-
def __init__(self, class_defs = None, h5path = None, mode = None, fh = None,version = None, filetype = None):
|
|
3711
|
+
def __init__(self, class_defs = None, h5path = None, mode = None, fh = None,version = None, filetype = None, hierarchical = False):
|
|
3562
3712
|
self.class_defs = class_defs
|
|
3563
3713
|
self.h5path = h5path
|
|
3564
3714
|
self.mode = mode
|
|
3565
3715
|
self.fh = fh
|
|
3566
3716
|
self.version = version
|
|
3567
3717
|
self.filetype = filetype
|
|
3568
|
-
|
|
3718
|
+
self.hierarchical = hierarchical
|
|
3719
|
+
self.file_is_blank = True
|
|
3569
3720
|
self.file_object_dict = {}
|
|
3570
3721
|
self.graph = ONDEFileGraph(class_defs = self.class_defs)
|
|
3571
3722
|
|
|
@@ -3573,11 +3724,11 @@ class ONDEFile(object):
|
|
|
3573
3724
|
raise ValueError(f"Unknown mode: {self.mode:s}")
|
|
3574
3725
|
|
|
3575
3726
|
if self.mode == "r+" or self.mode == "a" or self.mode == "r":
|
|
3576
|
-
|
|
3727
|
+
self.file_is_blank = False
|
|
3577
3728
|
if version is not None:
|
|
3578
|
-
raise ValueError("Attempting to set
|
|
3729
|
+
raise ValueError("Attempting to set ONDE:VERSION on existing file.")
|
|
3579
3730
|
if filetype is not None:
|
|
3580
|
-
raise ValueError("Attempting to set
|
|
3731
|
+
raise ValueError("Attempting to set ONDE:FILETYPE on existing file.")
|
|
3581
3732
|
self.load() # Attempt to read in current contents.
|
|
3582
3733
|
pass
|
|
3583
3734
|
|
|
@@ -3596,8 +3747,8 @@ class ONDEFile(object):
|
|
|
3596
3747
|
return iter(self.keys())
|
|
3597
3748
|
|
|
3598
3749
|
def load(self):
|
|
3599
|
-
self.version = self.fh.attrs["
|
|
3600
|
-
self.filetype = set(self.fh.attrs["
|
|
3750
|
+
self.version = self.fh.attrs["ONDE:VERSION"]
|
|
3751
|
+
self.filetype = set(self.fh.attrs["ONDE:FILETYPE"])
|
|
3601
3752
|
|
|
3602
3753
|
# check for PyONDE_DB and db_maxidx
|
|
3603
3754
|
self.db_maxidx = 0
|
|
@@ -3650,22 +3801,22 @@ class ONDEFile(object):
|
|
|
3650
3801
|
def flush(self):
|
|
3651
3802
|
snap = self.graph.latest_snap
|
|
3652
3803
|
|
|
3653
|
-
# Ensure
|
|
3654
|
-
if "
|
|
3804
|
+
# Ensure ONDE:FILETYPE and ONDE:VERSION are present
|
|
3805
|
+
if "ONDE:VERSION" not in self.fh.attrs:
|
|
3655
3806
|
if self.version is not None:
|
|
3656
|
-
self.fh.attrs["
|
|
3807
|
+
self.fh.attrs["ONDE:VERSION"] = self.version
|
|
3657
3808
|
pass
|
|
3658
3809
|
else:
|
|
3659
|
-
self.fh.attrs["
|
|
3810
|
+
self.fh.attrs["ONDE:VERSION"] = self.class_defs.version
|
|
3660
3811
|
pass
|
|
3661
3812
|
pass
|
|
3662
3813
|
|
|
3663
|
-
if "
|
|
3814
|
+
if "ONDE:FILETYPE" not in self.fh.attrs:
|
|
3664
3815
|
if self.filetype is not None:
|
|
3665
|
-
self.fh.attrs["
|
|
3816
|
+
self.fh.attrs["ONDE:FILETYPE"] = list(self.filetype)
|
|
3666
3817
|
pass
|
|
3667
3818
|
else:
|
|
3668
|
-
self.fh.attrs["
|
|
3819
|
+
self.fh.attrs["ONDE:FILETYPE"] = ["ONDE_DATASET"]
|
|
3669
3820
|
pass
|
|
3670
3821
|
pass
|
|
3671
3822
|
|
|
@@ -3707,25 +3858,56 @@ class ONDEFile(object):
|
|
|
3707
3858
|
fileobj.close()
|
|
3708
3859
|
del self.file_object_dict[obj]
|
|
3709
3860
|
pass
|
|
3710
|
-
|
|
3711
3861
|
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3862
|
+
if enable_hierarchical and self.hierarchical and self.file_is_blank:
|
|
3863
|
+
# Perform hierarchical write
|
|
3864
|
+
# Only designed for new files, at least so far.
|
|
3865
|
+
|
|
3866
|
+
# Iterate through the various needed_objs, which remember
|
|
3867
|
+
# are ordered leaf first, to get the various datasets
|
|
3868
|
+
# to add to the root
|
|
3869
|
+
for needed_obj in needed_objs:
|
|
3870
|
+
assert(needed_obj in to_add)
|
|
3871
|
+
|
|
3872
|
+
if isinstance(needed_obj, ONDEObject):
|
|
3873
|
+
class_derivation = needed_obj["ONDE:TYPE"]
|
|
3874
|
+
baseclass = class_derivation.value[0]
|
|
3875
|
+
if baseclass == "ONDE_DATASET":
|
|
3876
|
+
# Write this dataset
|
|
3877
|
+
obj_name = needed_obj["ONDE:UUID"].value[5:9] # Skip the 5 characters of the "2.25." and just use the first 4 digits.
|
|
3878
|
+
while obj_name in self.fh:
|
|
3879
|
+
# Guarantee uniqueness
|
|
3880
|
+
obj_name += "_"
|
|
3881
|
+
pass
|
|
3882
|
+
|
|
3716
3883
|
|
|
3717
|
-
|
|
3718
|
-
|
|
3884
|
+
needed_obj._hdf5_write_group(onde_file = self,parent = self.fh,parent_path = "/",name = obj_name, hierarchical_write = True)
|
|
3885
|
+
pass
|
|
3886
|
+
pass
|
|
3887
|
+
pass
|
|
3888
|
+
|
|
3889
|
+
pass
|
|
3890
|
+
else:
|
|
3891
|
+
# Write all objects into PyONDE_DB group
|
|
3719
3892
|
|
|
3720
|
-
|
|
3893
|
+
# add in the needed objects. Loop ordering is because needed_objs is actually an OrderedDict.
|
|
3894
|
+
for needed_obj in needed_objs:
|
|
3895
|
+
if not needed_obj in to_add:
|
|
3896
|
+
continue
|
|
3897
|
+
|
|
3898
|
+
obj_name = f"{self.db_maxidx + 1:05d}"
|
|
3899
|
+
self.db_maxidx += 1
|
|
3900
|
+
|
|
3901
|
+
#fileobj = ONDEFileObject(onde_instance = needed_obj,hdf5_path = posixpath.join(db_path,obj_name))
|
|
3721
3902
|
|
|
3722
|
-
|
|
3903
|
+
needed_obj._hdf5_write_group(onde_file = self,parent = db,parent_path = db_path,name = obj_name)
|
|
3723
3904
|
|
|
3724
|
-
|
|
3905
|
+
#self.file_object_dict[needed_obj] = fileobj
|
|
3725
3906
|
|
|
3907
|
+
pass
|
|
3726
3908
|
pass
|
|
3727
3909
|
|
|
3728
|
-
|
|
3910
|
+
self.file_is_blank = False
|
|
3729
3911
|
self.fh.flush()
|
|
3730
3912
|
pass
|
|
3731
3913
|
|
|
@@ -3759,7 +3941,7 @@ class ONDEFile(object):
|
|
|
3759
3941
|
return self._repr(0)
|
|
3760
3942
|
|
|
3761
3943
|
@classmethod
|
|
3762
|
-
def new(cls, h5path, mode, class_defs_path=None, extra_class_defs = None, onde_version = None):
|
|
3944
|
+
def new(cls, h5path, mode, class_defs_path=None, extra_class_defs = None, onde_version = None, hierarchical = False):
|
|
3763
3945
|
fh = h5py.File(h5path, mode)
|
|
3764
3946
|
|
|
3765
3947
|
class_defs = None
|
|
@@ -3770,7 +3952,7 @@ class ONDEFile(object):
|
|
|
3770
3952
|
class_defs = ONDEClassDefinitions.load_from_csv(class_defs_path,extra_class_defs = extra_class_defs)
|
|
3771
3953
|
pass
|
|
3772
3954
|
|
|
3773
|
-
return cls(class_defs = class_defs, h5path = h5path, mode = mode, fh = fh)
|
|
3955
|
+
return cls(class_defs = class_defs, h5path = h5path, mode = mode, fh = fh, hierarchical = hierarchical)
|
|
3774
3956
|
|
|
3775
3957
|
pass
|
|
3776
3958
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyONDE
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: PyONDE library for reading, modifying, and writing ONDE files
|
|
5
5
|
Home-page: http://github.com/isuthermography/PyONDE
|
|
6
6
|
Author: Stephen D. Holland
|
|
@@ -29,6 +29,11 @@ More information and documentation in the doc/ folder and at
|
|
|
29
29
|
https://isuthermography.github.io/PyONDE/ and at
|
|
30
30
|
https://github.com/isuthermography/PyONDE
|
|
31
31
|
|
|
32
|
+
Acknowledgments
|
|
33
|
+
---------------
|
|
34
|
+
|
|
35
|
+
Thanks to Abhigyaan Deep for helping with some of the coating
|
|
36
|
+
|
|
32
37
|
|
|
33
38
|
Copyright 2026 Stephen D. Holland and Iowa State University
|
|
34
39
|
Research Foundation
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": [
|
|
3
|
+
".github/workflows/doc.yml",
|
|
4
|
+
".github/workflows/push-to-pypi.yml",
|
|
5
|
+
".gitignore",
|
|
6
|
+
".vscode/settings.json",
|
|
3
7
|
"LICENSE.txt",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
8
|
+
"PyONDE/__init__.py",
|
|
9
|
+
"PyONDE/bin/__init__.py",
|
|
10
|
+
"PyONDE/onde.py",
|
|
11
|
+
"PyONDE/onde_versions/ONDE_fields_v0.9.1pre.csv",
|
|
6
12
|
"README.md",
|
|
7
|
-
".
|
|
8
|
-
"
|
|
13
|
+
"demos/build_onde_file.py",
|
|
14
|
+
"demos/build_onde_graph.py",
|
|
9
15
|
"demos/build_simple_graph.py",
|
|
10
|
-
"demos/load_onde_file.py",
|
|
11
16
|
"demos/graph_modification.py",
|
|
12
|
-
"demos/
|
|
13
|
-
"demos/build_onde_file.py",
|
|
14
|
-
"tests/try_csv_read.py",
|
|
15
|
-
"tests/try_dictionary.py",
|
|
16
|
-
"tests/try_array.py",
|
|
17
|
-
"doc/Makefile",
|
|
17
|
+
"demos/load_onde_file.py",
|
|
18
18
|
"doc/LowLevel_Class_Structure.md",
|
|
19
|
-
"doc/
|
|
19
|
+
"doc/Makefile",
|
|
20
|
+
"doc/source/PyONDE.rst",
|
|
20
21
|
"doc/source/about.rst",
|
|
21
|
-
"doc/source/modules.rst",
|
|
22
|
-
"doc/source/conf.py",
|
|
23
|
-
"doc/source/quickstart.rst",
|
|
24
22
|
"doc/source/architecture.rst",
|
|
25
|
-
"doc/source/
|
|
23
|
+
"doc/source/conf.py",
|
|
24
|
+
"doc/source/index.rst",
|
|
26
25
|
"doc/source/installation.rst",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
26
|
+
"doc/source/modules.rst",
|
|
27
|
+
"doc/source/quickstart.rst",
|
|
28
|
+
"pyproject.toml",
|
|
29
|
+
"setup.py",
|
|
30
|
+
"tests/try_array.py",
|
|
31
|
+
"tests/try_csv_read.py",
|
|
32
|
+
"tests/try_dictionary.py"
|
|
32
33
|
]
|
|
33
34
|
}
|
|
@@ -13,6 +13,11 @@ More information and documentation in the doc/ folder and at
|
|
|
13
13
|
https://isuthermography.github.io/PyONDE/ and at
|
|
14
14
|
https://github.com/isuthermography/PyONDE
|
|
15
15
|
|
|
16
|
+
Acknowledgments
|
|
17
|
+
---------------
|
|
18
|
+
|
|
19
|
+
Thanks to Abhigyaan Deep for helping with some of the coating
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
Copyright 2026 Stephen D. Holland and Iowa State University
|
|
18
23
|
Research Foundation
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|