projects
/
hooke.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cc35f24
)
Add hooke.util.yaml.data_constructor to rebuild hooke.curve.Data.info.
author
W. Trevor King
<wking@drexel.edu>
Sun, 22 Aug 2010 13:34:37 +0000
(09:34 -0400)
committer
W. Trevor King
<wking@drexel.edu>
Sun, 22 Aug 2010 13:34:37 +0000
(09:34 -0400)
hooke/util/yaml.py
patch
|
blob
|
history
diff --git
a/hooke/util/yaml.py
b/hooke/util/yaml.py
index e7f99806a49c6382716f49764d8ac72e3d1092f1..46d6e2a73963c7dccf3eaea22a3aadcc916556c0 100644
(file)
--- a/
hooke/util/yaml.py
+++ b/
hooke/util/yaml.py
@@
-54,12
+54,16
@@
import types
import numpy
import yaml
import yaml.constructor
import numpy
import yaml
import yaml.constructor
+from yaml.constructor import ConstructorError
import yaml.representer
from ..curve import Data, Curve
from ..playlist import FilePlaylist
import yaml.representer
from ..curve import Data, Curve
from ..playlist import FilePlaylist
+DATA_INFO_TAG = u'!hooke.curve.DataInfo'
+
+
if False: # YAML dump debugging code
"""To help isolate data types etc. that give YAML problems.
if False: # YAML dump debugging code
"""To help isolate data types etc. that give YAML problems.
@@
-120,9
+124,14
@@
def data_representer(dumper, data):
for key in info.keys():
if key.startswith('raw '):
del(info[key])
for key in info.keys():
if key.startswith('raw '):
del(info[key])
- return dumper.represent_mapping(
u'!hooke.curve.DataInfo'
, info)
+ return dumper.represent_mapping(
DATA_INFO_TAG
, info)
yaml.add_representer(Data, data_representer)
yaml.add_representer(Data, data_representer)
+def data_constructor(loader, node):
+ info = loader.construct_mapping(node)
+ return Data(shape=(0,0), dtype=numpy.float32, info=info)
+yaml.add_constructor(DATA_INFO_TAG, data_constructor)
+
def object_representer(dumper, data):
cls = type(data)
if cls in copy_reg.dispatch_table:
def object_representer(dumper, data):
cls = type(data)
if cls in copy_reg.dispatch_table: