nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: dgasmith/opt_einsum
Pull request #195 (2022-07-05 20:25:01)

Fix `dp` to work for contractions with no sized axes (scalars only).
Fix `dp` to work for contractions with no sized axes (scalars only).

codecov[bot]: # [Codecov](https://codecov.io/gh/dgasmith/opt_einsum/pull/195?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Smith) Report
> Merging [#195](https://codecov.io/gh/dgasmith/opt_einsum/pull/195?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Smith) (7ac72cb) into [master](https://codecov.io/gh/dgasmith/opt_einsum/commit/89cf0b3236d9e7dd2d8cdec435e9f4a4c88598d5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Smith) (89cf0b3) will **decrease** coverage by `6.66%`.
> The diff coverage is `100.00%`.



Patch:
diff --git a/opt_einsum/paths.py b/opt_einsum/paths.py
index eac3630..ac8ccd5 100644
--- a/opt_einsum/paths.py
+++ b/opt_einsum/paths.py
@@ -1217,7 +1217,7 @@ class DynamicProgramming(PathOptimizer):
         output = frozenset(symbol2int[c] for c in output_)
         size_dict_canonical = {symbol2int[c]: v for c, v in size_dict_.items() if c in symbol2int}
         size_dict = [size_dict_canonical[j] for j in range(len(size_dict_canonical))]
-        naive_cost = naive_scale * len(inputs) * functools.reduce(operator.mul, size_dict)
+        naive_cost = naive_scale * len(inputs) * functools.reduce(operator.mul, size_dict, 1)
 
         inputs, inputs_done, inputs_contractions = _dp_parse_out_single_term_ops(inputs, all_inds, ind_counts)
 


Test patch:
diff --git a/opt_einsum/tests/test_contract.py b/opt_einsum/tests/test_contract.py
index 453a779..ef3ee5d 100644
--- a/opt_einsum/tests/test_contract.py
+++ b/opt_einsum/tests/test_contract.py
@@ -13,6 +13,7 @@ tests = [
     "a,->a",
     "ab,->ab",
     ",ab,->ab",
+    ",,->",
     # Test hadamard-like products
     "a,ab,abc->abc",
     "a,b,ab->ab",
diff --git a/opt_einsum/tests/test_paths.py b/opt_einsum/tests/test_paths.py
index c6fef4f..eb4b18b 100644
--- a/opt_einsum/tests/test_paths.py
+++ b/opt_einsum/tests/test_paths.py
@@ -58,6 +58,7 @@ path_scalar_tests = [
     ["ab,->ab", 1],
     [",a,->a", 2],
     [",,a,->a", 3],
+    [",,->", 2],
 ]