Store and read data arrays using YAML format
Code: "io_yaml_test.py"
Programming language: Python
DMelt Version 1.4. Last modified: 03/13/2016. License: Free
http://jwork.org/dmelt/code/cache/io_yaml_test_4149.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from jhplot.io import *
from jhplot import *

print "Write YAML data"
f=HFileYAML("test.yaml","w")

p0=P0D("test1");
p0.randomUniform(100,0,100)

p1=P1D("test2")
p1.add(10,20,3);
p1.add(20,40,3);
p1.add(30,80,3);
p1.add(40,60,3);

p2=P2D("test3")
p2.add(1,2,4)
p2.add(3,3,5)

f.write("t0",p0)
f.write("t1",p1)
f.write("t2",p2)
f.close()

print "Read YAML data:"
f=HFileYAML("test.yaml")
print f.read("t0")
print f.read("t1")
print f.read("t2")
f.close()