Skip to content

einsum error with unicode input (regression in Numpy 1.14) #10369

Closed

Description

@saimn

This was working before Numpy 1.14 and now fails (on Python 2):

In [1]: from __future__ import unicode_literals
   ...: import numpy as np
   ...: np.einsum('...i,...i', [1,2,3], [2,3,4])
   ...: 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-dea65e271386> in <module>()
      1 from __future__ import unicode_literals
      2 import numpy as np
----> 3 np.einsum('...i,...i', [1,2,3], [2,3,4])

/home/conseil/miniconda3/envs/py2/lib/python2.7/site-packages/numpy/core/einsumfunc.pyc in einsum(*operands, **kwargs)
   1085     # Build the contraction list and operand
   1086     operands, contraction_list = einsum_path(*operands, optimize=optimize_arg,
-> 1087                                              einsum_call=True)
   1088
   1089     handle_out = False

/home/conseil/miniconda3/envs/py2/lib/python2.7/site-packages/numpy/core/einsumfunc.pyc in einsum_path(*operands, **kwargs)
    686
    687     # Python side parsing
--> 688     input_subscripts, output_subscript, operands = _parse_einsum_input(operands)
    689     subscripts = input_subscripts + '->' + output_subscript
    690

/home/conseil/miniconda3/envs/py2/lib/python2.7/site-packages/numpy/core/einsumfunc.pyc in _parse_einsum_input(operands)
    529         if char not in input_subscripts:
    530             raise ValueError("Output character %s did not appear in the input"
--> 531                              % char)
    532
    533     # Make sure number operands is equivalent to the number of terms

ValueError: Output character e did not appear in the input

Activity

  1. mhvk commented on Jan 11, 2018

    @mhvk
    Contributor

    Should perhaps add that this is a consequence of optimize=True having become the default - this bug must have been present for that branch in 1.13 as well.

    Anyway, thanks for the fix!

  2. added a commit that references this issue on Jan 11, 2018
    77ac4a5
  3. saimn commented on Jan 11, 2018

    @saimn
    ContributorAuthor

    Ah ok, this explains why I did not find recent changes on these lines in the einsum/blas PR (I looked the history very quickly!).

  4. added a commit that references this issue on Jan 14, 2018
    f5efb93
  5. added a commit that references this issue on Feb 15, 2018
    8e6ae10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions