MCPcopy Create free account
hub / github.com/numpy/numpy / _update_other_results

Function _update_other_results

numpy/core/einsumfunc.py:273–310  ·  view source on GitHub ↗

Update the positions and provisional input_sets of ``results`` based on performing the contraction result ``best``. Remove any involving the tensors contracted. Parameters ---------- results : list List of contraction results produced by ``_parse_possible_contraction``.

(results, best)

Source from the content-addressed store, hash-verified

271
272
273def _update_other_results(results, best):
274 """Update the positions and provisional input_sets of ``results`` based on
275 performing the contraction result ``best``. Remove any involving the tensors
276 contracted.
277
278 Parameters
279 ----------
280 results : list
281 List of contraction results produced by ``_parse_possible_contraction``.
282 best : list
283 The best contraction of ``results`` i.e. the one that will be performed.
284
285 Returns
286 -------
287 mod_results : list
288 The list of modified results, updated with outcome of ``best`` contraction.
289 """
290
291 best_con = best[1]
292 bx, by = best_con
293 mod_results = []
294
295 for cost, (x, y), con_sets in results:
296
297 # Ignore results involving tensors just contracted
298 if x in best_con or y in best_con:
299 continue
300
301 # Update the input_sets
302 del con_sets[by - int(by > x) - int(by > y)]
303 del con_sets[bx - int(bx > x) - int(bx > y)]
304 con_sets.insert(-1, best[2][-1])
305
306 # Update the position indices
307 mod_con = x - int(x > bx) - int(x > by), y - int(y > bx) - int(y > by)
308 mod_results.append((cost, mod_con, con_sets))
309
310 return mod_results
311
312def _greedy_path(input_sets, output_set, idx_dict, memory_limit):
313 """

Callers 1

_greedy_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected