/usr/share/doc/python-tables/examples/vlarray3.py is in python-tables-doc 3.4.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/usr/bin/env python
"""Example that shows how to easily save a variable number of atoms with a
VLArray."""
from __future__ import print_function
import numpy
import tables
N = 100
shape = (3, 3)
numpy.random.seed(10) # For reproductible results
f = tables.open_file("vlarray3.h5", mode="w")
vlarray = f.create_vlarray(f.root, 'vlarray1',
tables.Float64Atom(shape=shape),
"ragged array of arrays")
k = 0
for i in range(N):
l = []
for j in range(numpy.random.randint(N)):
l.append(numpy.random.randn(*shape))
k += 1
vlarray.append(l)
print("Total number of atoms:", k)
f.close()
|