Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge README content into the main index doc page #97

Merged
merged 2 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Range of changes to docs.
* Fix all broken links in the docs.
* Add useful links to README.
  • Loading branch information
hameerabbasi committed Jan 31, 2018
commit 0406c986e08b284425a6ffb16fbd7a978ec2d2d9
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Sparse Multidimensional Arrays
|Build Status|

This library provides multi-dimensional sparse arrays.
Read `the documentation <https://sparse-nd.readthedocs.io/en/latest>`_
for more information.

* `Documentation <https://sparse.pydata.org/en/latest>`_
* `Contributing <https://github.com/pydata/sparse/blob/master/docs/contributing.rst>`_
* `Bug Reports/Feature Requests <https://github.com/pydata/sparse/issues>`_

.. |Build Status| image:: https://travis-ci.org/pydata/sparse.svg?branch=master
:target: https://travis-ci.org/pydata/sparse
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Changelog
- Fix nnz for scalars (:pr:`48`) `Hameer Abbasi`_
- Update README (:pr:`50`) (:pr:`53`) `Hameer Abbasi`_
- Fix large concatenations and stacks (:pr:`50`) `Hameer Abbasi`_
- Add __array_ufunc__ for __call__ and reduce (:pr:`r9`) `Hameer Abbasi`_
- Add __array_ufunc__ for __call__ and reduce (:pr:`49`) `Hameer Abbasi`_
- Update documentation (:pr:`54`) `Hameer Abbasi`_
- Flake8 and coverage in pytest (:pr:`59`) `Nils Werner`_
- Copy constructor (:pr:`55`) `Nils Werner`_
Expand Down
20 changes: 10 additions & 10 deletions docs/construct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can construct :obj:`COO` arrays from coordinates and value data.

The :code:`coords` parameter contains the indices where the data is nonzero,
and the :code:`data` parameter contains the data corresponding to those indices.
For example, the following code will generate a :math:`5 \times 5` identity
For example, the following code will generate a :math:`5 \times 5` diagonal
matrix:

.. code-block:: python
Expand Down Expand Up @@ -53,9 +53,9 @@ explicitly. For example, if we did the following without the
data = [1, 4, 2, 1]
s = COO(coords, data, shape=(5, 5))

From :obj:`scipy.sparse.spmatrix` objects
-----------------------------------------
To construct :obj:`COO` array from :obj:`scipy.sparse.spmatrix`
From :doc:`Scipy sparse matrices <generated/scipy.sparse.spmatrix>`
-------------------------------------------------------------------
To construct :obj:`COO` array from :obj:`spmatrix <scipy.sparse.spmatrix>`
objects, you can use the :obj:`COO.from_scipy_sparse` method. As an
example, if :code:`x` is a :obj:`scipy.sparse.spmatrix`, you can
do the following to get an equivalent :obj:`COO` array:
Expand All @@ -64,8 +64,8 @@ do the following to get an equivalent :obj:`COO` array:

s = COO.from_scipy_sparse(x)

From :obj:`numpy.ndarray` objects
---------------------------------
From :doc:`Numpy arrays <reference/generated/numpy.ndarray>`
------------------------------------------------------------
To construct :obj:`COO` arrays from :obj:`numpy.ndarray`
objects, you can use the :obj:`COO.from_numpy` method. As an
example, if :code:`x` is a :obj:`numpy.ndarray`, you can
Expand Down Expand Up @@ -100,7 +100,7 @@ dictionary or is set to :code:`dtype('float64')` if that is not present.
.. code-block:: python

s = DOK((6, 5, 2))
s2 = DOK((2, 3, 4), dtype=np.float64)
s2 = DOK((2, 3, 4), dtype=np.uint8)

After this, you can build the array by assigning arrays or scalars to elements
or slices of the original array. Broadcasting rules are followed.
Expand All @@ -114,7 +114,7 @@ perform arithmetic or other operations on it.

.. code-block:: python

s2 = COO(s)
s3 = COO(s)

In addition, it is possible to access single elements of the :obj:`DOK` array
using normal Numpy indexing.
Expand All @@ -128,8 +128,8 @@ using normal Numpy indexing.

Converting :obj:`COO` objects to other Formats
----------------------------------------------
:obj:`COO` arrays can be converted to :obj:`numpy.ndarray` objects,
or to some :obj:`scipy.sparse.spmatrix` subclasses via the following
:obj:`COO` arrays can be converted to :doc:`Numpy arrays <reference/generated/numpy.ndarray>`,
or to some :obj:`spmatrix <scipy.sparse.spmatrix>` subclasses via the following
methods:

* :obj:`COO.todense`: Converts to a :obj:`numpy.ndarray` unconditionally.
Expand Down
18 changes: 15 additions & 3 deletions docs/contribute.rst → docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ If you're not already familiar with it, we follow the `fork and pull model
<https://help.github.com/articles/about-collaborative-development-models/>`_
on GitHub.

Filing Issues
-------------
If you find a bug or would like a new feature, you might want to `consider
filing a new issue on GitHub <https://github.com/pydata/sparse/issues>`_. Before
you open a new issue, please make sure of the following:

* This should go without saying, but make sure what you are requesting is within
the scope of this project.
* The bug/feature is still present/missing on the ``master`` branch on GitHub.
* A similar issue or pull request isn't already open. If one already is, it's better
to contribute to the discussion there.

Running/Adding Unit Tests
-------------------------
It is best if all new functionality and/or bug fixes have unit tests added
Expand All @@ -25,9 +37,9 @@ with each use-case.
Since we support both Python 2.7 and Python 3.5 and newer, it is recommended
to test with at least these two versions before committing your code or opening
a pull request. We use `pytest <https://docs.pytest.org/en/latest/>`_ as our unit
testing framework, with the pytest-cov extension to check code coverage and
pytest-flake8 to check code style. You don't need to configure these extensions
yourself. Once you've configured your environment, you can just :code:`cd` to
testing framework, with the ``pytest-cov`` extension to check code coverage and
``pytest-flake8`` to check code style. You don't need to configure these extensions
yourself. Once you've configured your environment, you can just ``cd`` to
the root of your repository and run

.. code-block:: bash
Expand Down
8 changes: 5 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ It generalizes the :obj:`scipy.sparse.coo_matrix` and :obj:`scipy.sparse.dok_mat
but extends beyond just rows and columns to an arbitrary number of dimensions.

Additionally, this project maintains compatibility with the :obj:`numpy.ndarray` interface
rather than the obj:`numpy.matrix` interface used in :obj:`scipy.sparse`
rather than the :obj:`numpy.matrix` interface used in :obj:`scipy.sparse`

These differences make this project useful in certain situations
where scipy.sparse matrices are not well suited,
Expand All @@ -29,7 +29,9 @@ costs when working with these arrays.
Design
------

The main data structure in this library follows the `Coordinate List (COO) <https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_(COO)>`_ layout for sparse matrices, but extends it to multiple dimensions.
The main data structure in this library follows the
`Coordinate List (COO) <https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_(COO)>`_
layout for sparse matrices, but extends it to multiple dimensions.

The COO layout, which stores the row index, column index, and value of every element:

Expand Down Expand Up @@ -81,7 +83,7 @@ This library is licensed under BSD-3
construct
operations
generated/sparse
contribute
contributing
changelog

.. _scipy.sparse: https://docs.scipy.org/doc/scipy/reference/sparse.html
28 changes: 14 additions & 14 deletions docs/operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Operators
---------

:obj:`COO` objects support a number of operations. They interact with scalars,
:obj:`numpy.ndarray` objects, other :obj:`COO` objects, and
:doc:`Numpy arrays <reference/generated/numpy.ndarray>`, other :obj:`COO` objects, and
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why was this change required?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saying "numpy dot enn dee array objects" is a mouthful. I thought it would be easier for readers to just change it to "Numpy arrays."

:obj:`scipy.sparse.spmatrix` objects, all following standard Python and Numpy
conventions.

Expand Down Expand Up @@ -37,8 +37,8 @@ This page describes those valid operations, and their limitations.
~~~~~~~~~~~~~~~~~~~
This function allows you to apply any arbitrary unary or binary function where
the first object is :obj:`COO`, and the second is a scalar, :obj:`COO`, or
a :obj:`numpy.ndarray`. For example, the following will add two
:obj:`COO` objects:
a :doc:`Numpy arrays <reference/generated/numpy.ndarray>`. For example, the
following will add two :obj:`COO` objects:

.. code-block:: python

Expand All @@ -49,7 +49,7 @@ a :obj:`numpy.ndarray`. For example, the following will add two
Auto-Densification
~~~~~~~~~~~~~~~~~~
Operations that would result in dense matrices, such as binary
operations with :obj:`numpy.ndarray` objects or certain operations with
operations with :doc:`Numpy arrays <reference/generated/numpy.ndarray>` objects or certain operations with
scalars are not allowed and will raise a :obj:`ValueError`. For example,
all of the following will raise a :obj:`ValueError`. Here, :code:`x` and
:code:`y` are :obj:`COO` objects.
Expand Down Expand Up @@ -79,8 +79,8 @@ If densification is needed, it must be explicit. In other words, you must call
both must be densified.


Operations with :obj:`numpy.ndarray`
------------------------------------
Operations with :doc:`Numpy arrays <reference/generated/numpy.ndarray>`
-----------------------------------------------------------------------
Certain operations with :obj:`numpy.ndarray` are also supported. For example,
the following are all allowed if :code:`x` is a :obj:`numpy.ndarray` and
:code:`(x == 0).all()` evaluates to :code:`True`:
Expand Down Expand Up @@ -123,7 +123,7 @@ on :obj:`COO`, as long as it is to the right of the operator.

Broadcasting
------------
All binary operators support :obj:`broadcasting <numpy.doc.broadcasting>`.
All binary operators support :doc:`broadcasting <user/basics.broadcasting>`.
This means that (under certain conditions) you can perform binary operations
on arrays with unequal shape. Namely, when the shape is missing a dimension,
or when a dimension is :code:`1`. For example, performing a binary operation
Expand Down Expand Up @@ -199,7 +199,7 @@ However, the following are all unsupported and will raise a :obj:`ValueError`:
np.cos(x)
np.log(x)

Notice that you can apply any unary or binary :obj:`numpy.ufunc` to :obj:`COO`
Notice that you can apply any unary or binary :doc:`numpy.ufunc <reference/ufuncs>` to :obj:`COO`
arrays, and :obj:`numpy.ndarray` objects and scalars and it will work so
long as the result is not dense. When applying to :obj:`numpy.ndarray` objects,
we check that operating on the array with zero would always produce a zero.
Expand All @@ -225,7 +225,7 @@ currently work:

:obj:`COO.reduce`
~~~~~~~~~~~~~~~~~
This method can take an arbitrary :obj:`numpy.ufunc` and performs a
This method can take an arbitrary :doc:`numpy.ufunc <reference/ufuncs>` and performs a
reduction using that method. For example, the following will perform
a sum:

Expand All @@ -234,15 +234,15 @@ a sum:
x.reduce(np.add, axis=1)

.. note::
:obj:`sparse` currently performs reductions by grouping together all
This library currently performs reductions by grouping together all
coordinates along the supplied axes and reducing those. Then, if the
number in a group is deficient, it reduces an extra time with zero.
As a result, if reductions can change by adding multiple zeros to
it, this method won't be accurate. However, it works in most cases.

Partial List of Supported Reductions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Although any binary :obj:`numpy.ufunc` should work for reductions, when calling
Although any binary :doc:`numpy.ufunc <reference/ufuncs>` should work for reductions, when calling
in the form :code:`x.reduction()`, the following reductions are supported:

* :obj:`COO.sum`
Expand Down Expand Up @@ -288,6 +288,6 @@ All of the following will raise an :obj:`IndexError`, like in Numpy 1.13 and lat
Other Operations
----------------
:obj:`COO` arrays support a number of other common operations. Among them are
:obj:`dot <COO.dot>`, :obj:`tensordot <COO.tensordot>`, :obj:`concatenate <COO.concatenate>`
and :obj:`stack <COO.stack>`, :obj:`COO.transpose <COO.transpose>` and :obj:`reshape <COO.reshape>`.
You can view the full list on the API reference page for :obj:`sparse`.
:obj:`dot`, :obj:`tensordot`, :obj:`concatenate`
and :obj:`stack`, :obj:`transpose <COO.transpose>` and :obj:`reshape <COO.reshape>`.
You can view the full list on the :doc:`API reference page <generated/sparse>`.
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Compute
-------

Many of the normal Numpy operations work on :obj:`COO` objects just like on :obj:`numpy.ndarray` objects.
This includes arithmetic, :obj:`numpy.ufunc` operations, or functions like tensordot and transpose.
This includes arithmetic, :doc:`numpy.ufunc <reference/ufuncs>` operations, or functions like tensordot and transpose.

.. code-block:: python

Expand All @@ -69,4 +69,4 @@ you can use the ``todense`` method (which will result in a :obj:`numpy.ndarray`)
y = x.todense() + 5

For more operations see the :doc:`Operations documentation <operations>`
or the :doc:`API reference <api>`.
or the :doc:`API reference <generated/sparse>`.