Skip to content

Drop support for Numpy 1.12. #84

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

Merged
merged 9 commits into from
Jan 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.abs.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.ceil.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.conj.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.conjugate.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.exp.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.expm1.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.floor.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.log1p.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.rint.rst

This file was deleted.

16 changes: 1 addition & 15 deletions docs/generated/sparse.COO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COO
.. autoclass:: COO

.. note::
:obj:`COO` objects also support :doc:`operators <../user_manual/operations/basic>`
:obj:`COO` objects also support :doc:`operators <../user_manual/operations/operators>`
and :doc:`indexing <../user_manual/operations/indexing>`

.. rubric:: Attributes
Expand All @@ -33,22 +33,8 @@ COO
:toctree:

COO.elemwise
COO.abs
COO.astype
COO.ceil
COO.conj
COO.conjugate
COO.exp
COO.expm1
COO.floor
COO.log1p
COO.rint
COO.round
COO.sin
COO.sinh
COO.sqrt
COO.tan
COO.tanh

.. rubric:: :doc:`Reductions <../user_manual/operations/reductions>`
.. autosummary::
Expand Down
6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.sin.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.sinh.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.sqrt.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.tan.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/generated/sparse.COO.tanh.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/user_manual/operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ common operations <operations/other>`_
.. toctree::
:maxdepth: 2

operations/basic
operations/operators
operations/elemwise
operations/reductions
operations/indexing
Expand Down
36 changes: 8 additions & 28 deletions docs/user_manual/operations/elemwise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,34 @@ To illustrate, the following are all possible, and will produce another

.. code-block:: python

x.abs()
np.abs(x)
np.sin(x)
np.sqrt(x)
x.conj()
x.expm1()
np.conj(x)
np.expm1(x)
np.log1p(x)

However, the following are all unsupported and will raise a :obj:`ValueError`:

.. code-block:: python

x.exp()
np.exp(x)
np.cos(x)
np.log(x)

Notice that you can apply any unary or binary :obj:`numpy.ufunc` to :obj:`COO`
arrays, :obj:`scipy.sparse.spmatrix` objects and scalars and it will work so
long as the result is not dense.
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.

:obj:`COO.elemwise`
-------------------
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:`scipy.sparse.spmatrix`. For example, the following will add two
a :obj:`numpy.ndarray`. For example, the following will add two
:obj:`COO` objects:

.. code-block:: python

x.elemwise(np.add, y)

Partial List of Supported :obj:`numpy.ufunc` s
----------------------------------------------
Although any unary or binary :obj:`numpy.ufunc` should work if the result is
not dense, when calling in the form :code:`x.func()`, the following operations
are supported:

* :obj:`COO.abs`
* :obj:`COO.expm1`
* :obj:`COO.log1p`
* :obj:`COO.sin`
* :obj:`COO.sinh`
* :obj:`COO.tan`
* :obj:`COO.tanh`
* :obj:`COO.sqrt`
* :obj:`COO.ceil`
* :obj:`COO.floor`
* :obj:`COO.round`
* :obj:`COO.rint`
* :obj:`COO.conj`
* :obj:`COO.conjugate`
* :obj:`COO.astype`
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. currentmodule:: sparse

Basic Operations
================
Operators
=========
:obj:`COO` objects can have a number of operators applied to them. They support
operations with scalars, :obj:`scipy.sparse.spmatrix` objects, and other
operations with scalars, :obj:`numpy.ndarray` objects, and other
:obj:`COO` objects. For example, to get the sum of two :obj:`COO` objects, you
would do the following:

Expand Down Expand Up @@ -53,6 +53,46 @@ If densification is needed, it must be explicit. In other words, you must call
:obj:`COO.todense` on the :obj:`COO` object. If both operands are :obj:`COO`,
both must be densified.

Operations with :obj:`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`:

.. code-block:: python

x + y
x - y

The following is true so long as there are no infinities or NaNs in :code:`x`:

.. code-block:: python

x * y

In general, if operating on the :code:`numpy.ndarray` with a zero would produce
all-zeros then the operation is supported.

Operations with :obj:`scipy.sparse.spmatrix`
--------------------------------------------
Certain operations with :obj:`scipy.sparse.spmatrix` are also supported.
For example, the following are all allowed if :code:`y` is a :obj:`scipy.sparse.spmatrix`:

.. code-block:: python

x + y
x - y
x * y
x > y
x < y

In general, if operating on a :code:`scipy.sparse.spmatrix` is the same as operating
on :obj:`COO`, as long as it is to the right of the operator.

.. note:: Results are not guaranteed if :code:`x` is a :obj:`scipy.sparse.spmatrix`.
For this reason, we recommend that all Scipy sparse matrices should be explicitly
converted to :obj:`COO` before any operations.

Broadcasting
------------
All binary operators support :obj:`broadcasting <numpy.doc.broadcasting>`.
Expand All @@ -67,8 +107,9 @@ will raise a :obj:`ValueError`.
Full List of Operators
----------------------
Here, :code:`x` and :code:`y` can be :obj:`COO` arrays,
:obj:`scipy.sparse.spmatrix` objects or scalars, keeping in mind :ref:`auto
densification rules <auto-densification>`. The following operators are supported:
:obj:`numpy.ndarray` objects or scalars, keeping in mind :ref:`auto
densification rules <auto-densification>`. In addition, :code:`y` can also
be a :obj:`scipy.sparse.spmatrix` The following operators are supported:

* Basic algebraic operations

Expand Down Expand Up @@ -99,3 +140,5 @@ densification rules <auto-densification>`. The following operators are supported

* :obj:`operator.lshift` (:code:`x << y`)
* :obj:`operator.rshift` (:code:`x >> y`)

.. note:: In-place operators are not supported at this time.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
numpy >= 1.13
scipy >= 0.19
six
Loading