1
"""Small example of do/undo capability with PyTables"""
6
fileh = tables.openFile("tutorial3-1.h5", "w", title="Undo/Redo demo 1")
8
#'-**-**-**-**-**-**- enable undo/redo log -**-**-**-**-**-**-**-'
12
one = fileh.createArray('/', 'anarray', [3,4], "An array")
16
another = fileh.createArray('/', 'anotherarray', [4,5], "Another array")
17
# Now undo the past operation
19
# Check that anotherarray does not exist in the object tree but anarray does
20
assert "/anarray" in fileh.objects
21
assert "/anotherarray" not in fileh.objects
24
# Check that anarray does not exist in the object tree
25
assert "/anarray" not in fileh.objects
26
assert "/anotherarray" not in fileh.objects
27
# Go forward up to the next marker
29
# Check that anarray has come back to life in a sane state
30
assert "/anarray" in fileh.objects
31
assert fileh.root.anarray.read() == [3,4]
32
assert fileh.root.anarray.title == "An array"
33
assert fileh.root.anarray == one
34
# But anotherarray is not here yet
35
assert "/anotherarray" not in fileh.objects
36
# Now, go rewind up to the end
38
assert "/anarray" in fileh.objects
39
# Check that anotherarray has come back to life in a sane state
40
assert "/anotherarray" in fileh.objects
41
assert fileh.root.anotherarray.read() == [4,5]
42
assert fileh.root.anotherarray.title == "Another array"
43
assert fileh.root.anotherarray == another
45
#'-**-**-**-**-**-**- disable undo/redo log -**-**-**-**-**-**-**-'