Save a tabarray to a numpy binary file or archive.
    
    Save a tabarray to a numpy binary file (``.npy``) or archive
    (``.npz``) that can be loaded by :func:`tabular.io.savebinary`.

    The ``.npz`` file is a zipped archive created using
    :func:`numpy.savez` and containing one or more ``.npy`` files,
    which are NumPy binary files created by :func:`numpy.save`.

    **Parameters**

        **fname** : string or file-like object

            File name or open numpy binary file (``.npy``) or archive (``.npz``) 
            created by :func:`tabular.io.savebinary`.

        **X** :  tabarray

            The actual data in a :class:`tabular.tab.tabarray`:

            * if `fname` is a ``.npy`` file, then this is the same as::

                numpy.savez(fname, data=X)

            * otherwise, if `fname` is a ``.npz`` file, then `X` is zipped 
              inside of `fname` as ``data.npy``

        **savecoloring** : boolean

            Whether or not to save the `coloring` attribute of `X`.  If 
            `savecoloring` is `True`, then `fname` must be a ``.npz`` archive 
            and `X.coloring` is zipped inside of `fname` as ``coloring.npy``

            See :func:`tabular.tab.tabarray.__new__` for more information about 
            coloring.

    **See Also:**

            :func:`tabular.io.loadbinary`, :func:`numpy.load`, 
            :func:`numpy.save`, :func:`numpy.savez`

def savebinary(fname, X, savecoloring=True):
    """
    Save a tabarray to a numpy binary file or archive.
    
    Save a tabarray to a numpy binary file (``.npy``) or archive
    (``.npz``) that can be loaded by :func:`tabular.io.savebinary`.

    The ``.npz`` file is a zipped archive created using
    :func:`numpy.savez` and containing one or more ``.npy`` files,
    which are NumPy binary files created by :func:`numpy.save`.

    **Parameters**

        **fname** : string or file-like object

            File name or open numpy binary file (``.npy``) or archive (``.npz``) 
            created by :func:`tabular.io.savebinary`.

        **X** :  tabarray

            The actual data in a :class:`tabular.tab.tabarray`:

            * if `fname` is a ``.npy`` file, then this is the same as::

                numpy.savez(fname, data=X)

            * otherwise, if `fname` is a ``.npz`` file, then `X` is zipped 
              inside of `fname` as ``data.npy``

        **savecoloring** : boolean

            Whether or not to save the `coloring` attribute of `X`.  If 
            `savecoloring` is `True`, then `fname` must be a ``.npz`` archive 
            and `X.coloring` is zipped inside of `fname` as ``coloring.npy``

            See :func:`tabular.tab.tabarray.__new__` for more information about 
            coloring.

    **See Also:**

            :func:`tabular.io.loadbinary`, :func:`numpy.load`, 
            :func:`numpy.save`, :func:`numpy.savez`

    """
    if fname[-4:] == '.npy':
        np.save(fname, X)
    else:
        if savecoloring is True:
            np.savez(fname, data=X, coloring=X.coloring)
        else:
            np.savez(fname, data=X)