question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: default value of `optimize` in `numpy.einsum`

See original GitHub issue

In the documentation page https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.einsum.html, the default value of optimize is correctly stated to be False in the function signature, but erroneously stated to be True in the parameter description:

optimize : {False, True, ‘greedy’, ‘optimal’}, optional Controls if intermediate optimization should occur. No optimization will occur if False and True will default to the ‘greedy’ algorithm. Also accepts an explicit contraction list from the np.einsum_path function. See np.einsum_path for more details. Default is True.

Reproducing code example:

import timeit
print(timeit.timeit("np.einsum('ea,fb,abcd,gc,hd->efgh', C, C, I, C, C, optimize = True)", 'import numpy as np; I = np.random.rand(10, 10, 10, 10); C = np.random.rand(10, 10)', number = 10))
print(timeit.timeit("np.einsum('ea,fb,abcd,gc,hd->efgh', C, C, I, C, C)", 'import numpy as np; I = np.random.rand(10, 10, 10, 10); C = np.random.rand(10, 10)', number = 10))

The second line should run much slower than the first line.

Numpy/Python version information:

1.15.1 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
melissawmcommented, Jan 12, 2021

Is there anything left to do in this issue or can it be closed?

0reactions
charriscommented, Oct 31, 2018

Looks like it would be easier to just fix the documentation for the default value of optimize.

EDIT: Given how often this issue has come up, probably worth doing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

numpy.einsum — NumPy v1.24 Manual
In implicit mode einsum computes these values. ... No optimization will occur if False and True will default to the 'greedy' algorithm.
Read more >
Why is the optimize argument False by default in np.einsum?
In the docs of the numpy.einsum (which may be found here) it says that for using optimization may increase calculation of contractions with ......
Read more >
numpy.einsum() - JAX documentation - Read the Docs
jax.numpy.einsum(*operands, out=None, optimize='optimal', precision=None, ... which means default precision for the backend, a Precision enum value ...
Read more >
torch.einsum — PyTorch 1.13 documentation
For example, matrix multiplication can be computed using einsum as ... differently from NumPy in that it allows dimensions covered by the ellipsis...
Read more >
qiskit_nature.settings — Qiskit Nature 0.5.1 documentation
[docs]class QiskitNatureSettings: """Global settings for Qiskit Nature. ... bool: """Returns the setting used for `numpy.einsum(optimize=...)`.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found