Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed Jul 17, 2019
1 parent edd328e commit 7031163
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
32 changes: 29 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pyn5
.. image:: https://img.shields.io/pypi/v/pyn5.svg
:target: https://pypi.python.org/pypi/pyn5

.. image:: https://img.shields.io/pypi/pyversions/pyn5.svg
:target: https://pypi.python.org/pypi/pyn5

.. image:: https://travis-ci.org/pattonw/rust-pyn5.svg?branch=master
:target: https://travis-ci.org/pattonw/rust-pyn5

Expand All @@ -14,19 +17,36 @@ pyn5
:alt: Documentation Status




Python wrapper around rust-n5.


* Free software: MIT license
* Documentation: https://rust-pyn5.readthedocs.io.

Installation
------------

``pip install pyn5`` installs pre-compiled wheels.
To build from source, you need

* `setuptools-rust`_
* a rust_ compiler

- >= 1.34.0-nightly 2019-02-06
- <= 1.36.0-nightly 2019-07-01

Features
--------

* TODO
* h5py-like interface

Related projects
----------------

* N5_ (file system format spec and reference implementation in java)
* `rust-n5`_ (implementation in rust, used in pyn5)
* zarr_ (similar chunked array storage library and format, supports some N5 features)
* z5_ (C++ implementation of zarr and N5 with python bindings, depends on conda)

Credits
-------
Expand All @@ -35,3 +55,9 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _N5: https://github.com/saalfeldlab/n5/
.. _rust-n5: https://github.com/aschampion/rust-n5/
.. _zarr: https://zarr-developers.github.io/
.. _z5: https://github.com/constantinpape/z5/
.. _setuptools-rust: https://github.com/PyO3/setuptools-rust
.. _rust: https://www.rust-lang.org/tools/install
49 changes: 49 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,52 @@ Usage
To use pyn5 in a project::

import pyn5

pyn5 exposes an API largely compatible with h5py_.
There are additionally some enums defined to optionally help manage open modes and compression types


.. code-block:: python
import numpy as np
from pyn5 import File, Mode, CompressionType
f = File("path/to/test.n5", mode=Mode.READ_WRITE_CREATE) # default mode 'a'
g1 = f.create_group("group1")
g2 = f.require_group("/group1/group2")
ds1 = g2.create_dataset(
"dataset1",
data=np.random.random((10, 10)),
chunks=(5, 5),
compression=CompressionType.GZIP,
compression_opts=-1
) # default compression
# indexing supports slices, integers, ellipses, and newaxes
arr = ds1[:, 5, np.newaxes]
ds1.attrs["key"] = "value"
Differences from h5py
---------------------

* The HDF5_ format is different to N5_; refer to their specifications
* No files are held open, so there is no need to use a context manager (``with``) to open a ``File``

- But you can use one if you want, for compatibility

* Attributes must be JSON-serializable

- The default encoder will convert numpy arrays to nested lists; they will remain lists when read

* Compression types are as described in the N5_ spec
* Group and Dataset copying and linking are not supported
* Non-zero fill values, dataset resizing, and named dimensions are not supported


.. _HDF5: https://support.hdfgroup.org/HDF5/doc/H5.format.html
.. _h5py: http://docs.h5py.org/en/stable/
.. _N5: https://github.com/saalfeldlab/n5/#file-system-specification-version-203-snapshot

0 comments on commit 7031163

Please sign in to comment.