Skip to content

Commit

Permalink
update for review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Jul 2, 2020
1 parent dc23938 commit 4dde939
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/source/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ so long the *objects themselves* just support multiplication and addition (
``__mul__`` and ``__add__`` dunder methods respectively). Use it by supplying
``backend='object'``.

For example imagine we want to perform a contraction of arrays made up of
For example, imagine we want to perform a contraction of arrays made up of
`sympy <www.sympy.org>`_ symbols:

.. code-block:: python
Expand All @@ -359,7 +359,7 @@ For example imagine we want to perform a contraction of arrays made up of
array([i*(a*e + b*g) + k*(a*f + b*h), j*(c*e + d*g) + l*(c*f + d*h)],
dtype=object)
There's a few things to note here:
There are a few things to note here:

* The returned array is a ``numpy.ndarray`` but since it has ``dtype=object``
it can really hold *any* python objects
Expand Down
4 changes: 2 additions & 2 deletions opt_einsum/backends/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy

from . import objects
from . import object_arrays
from . import cupy as _cupy
from . import jax as _jax
from . import tensorflow as _tensorflow
Expand Down Expand Up @@ -53,7 +53,7 @@ def _import_func(func, backend, default=None):
# also pre-populate with the arbitrary object backend
('tensordot', 'object'): numpy.tensordot,
('transpose', 'object'): numpy.transpose,
('einsum', 'object'): objects.oinsum,
('einsum', 'object'): object_arrays.object_einsum,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import operator


def oinsum(eq, *arrays):
def object_einsum(eq, *arrays):
"""A ``einsum`` implementation for ``numpy`` arrays with object dtype.
The loop is performed in python, meaning that the objects themselves need
The loop is performed in python, meaning the objects themselves need
only to implement ``__mul__`` and ``__add__`` for the contraction to be
computed. This may be useful when, for example, computing expressions of
tensors with symbolic elements, but note it will be very slow when compared
Expand Down
2 changes: 1 addition & 1 deletion opt_einsum/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def test_auto_backend_custom_array_no_tensordot():


@pytest.mark.parametrize("string", tests)
def test_objects(string):
def test_object_arrays_backend(string):
views = helpers.build_views(string)
ein = contract(string, *views, optimize=False, use_blas=False)
assert ein.dtype != object
Expand Down

0 comments on commit 4dde939

Please sign in to comment.