Skip to content

Commit

Permalink
Merge pull request #1306 from tacaswell/doc_tweaks
Browse files Browse the repository at this point in the history
DOC: minor changes to the documentation
  • Loading branch information
aragilar committed Oct 10, 2019
2 parents 6301a61 + 96876a6 commit 7261bc4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
8 changes: 7 additions & 1 deletion docs/quick.rst
Expand Up @@ -11,12 +11,18 @@ With `Anaconda <http://continuum.io/downloads>`_ or

conda install h5py


If there are wheels for your platform (mac, linux, windows on x86) and
you do not need MPI you can install ``h5py`` via pip::

pip install h5py

With `Enthought Canopy <https://www.enthought.com/products/canopy/>`_, use
the GUI package manager or::

enpkg h5py

With pip or setup.py, see :ref:`install`.
To install from source see :ref:`install`.

Core concepts
-------------
Expand Down
39 changes: 24 additions & 15 deletions examples/vds_simple.py
@@ -1,29 +1,38 @@
'''A simple example of building a virtual dataset.
"""A simple example of building a virtual dataset.
This makes four 'source' HDF5 files, each with a 1D dataset of 100 numbers.
Then it makes a single 4x100 virtual dataset in a separate file, exposing
the four sources as one dataset.
'''
"""

import h5py
import numpy as np

# Create source files (1.h5 to 4.h5)
for n in range(1, 5):
with h5py.File('{}.h5'.format(n), 'w') as f:
d = f.create_dataset('data', (100,), 'i4')
d[:] = np.arange(100) + n
# create some sample data
data = np.arange(0, 100).reshape(1, 100) + np.arange(1, 5).reshape(4, 1)

# Assemble virtual dataset
layout = h5py.VirtualLayout(shape=(4, 100), dtype='i4')
# Create source files (0.h5 to 3.h5)
for n in range(4):
with h5py.File(f"{n}.h5", "w") as f:
d = f.create_dataset("data", (100,), "i4", data[n])

for n in range(1, 5):
# Assemble virtual dataset
layout = h5py.VirtualLayout(shape=(4, 100), dtype="i4")
for n in range(4):
filename = "{}.h5".format(n)
vsource = h5py.VirtualSource(filename, 'data', shape=(100,))
layout[n - 1] = vsource
vsource = h5py.VirtualSource(filename, "data", shape=(100,))
layout[n] = vsource

# Add virtual dataset to output file
with h5py.File("VDS.h5", 'w', libver='latest') as f:
f.create_virtual_dataset('data', layout, fillvalue=-5)
with h5py.File("VDS.h5", "w", libver="latest") as f:
f.create_virtual_dataset("vdata", layout, fillvalue=-5)
f.create_dataset("data", data=data, dtype="i4")


# read data back
# virtual dataset is transparent for reader!
with h5py.File("VDS.h5", "r") as f:
print("Virtual dataset:")
print(f['data'][:, :10])
print(f["vdata"][:, :10])
print("Normal dataset:")
print(f["data"][:, :10])
9 changes: 9 additions & 0 deletions news/drop-old-python.rst
@@ -0,0 +1,9 @@
Support for Python versions
---------------------------
h5py 3.0 will support Python 3.6 and Python 3.7

.. important::

* Support for Python 3.4 has been dropped.
* Support for Python 3.5 has been dropped.
* Support for Python 2.7 has been dropped.

0 comments on commit 7261bc4

Please sign in to comment.