File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -539,9 +539,18 @@ def _build_expression(
539539 # 'contraction' is a no-op
540540
541541 def fn (* arrays , backend = None ):
542+ # this is surprisingly complicated 'to do nothing', since we
543+ # have to respect potential backend conversion
544+ x = arrays [0 ]
542545 if backend is None :
543- return arrays [0 ]
544- return ar .do ("array" , arrays [0 ], like = backend )
546+ # haven't requested a specific backend, just return
547+ return x
548+ elif backend == ar .infer_backend (x ):
549+ # requested backend is the same as the input, just return
550+ return x
551+ else :
552+ # requested backend is different, convert
553+ return ar .do ("array" , arrays [0 ], like = backend )
545554
546555 elif len (term ) == len (output ):
547556 # 'contraction' is just a transposition
Original file line number Diff line number Diff line change 3030 ],
3131 extras_require = {
3232 "recommended" : [
33- "cotengrust" ,
33+ "cotengrust>=0.1.3 " ,
3434 "cytoolz" ,
3535 "kahypar" ,
3636 "networkx" ,
7676 "Programming Language :: Python :: 3.9" ,
7777 "Programming Language :: Python :: 3.10" ,
7878 "Programming Language :: Python :: 3.11" ,
79+ "Programming Language :: Python :: 3.12" ,
7980 ],
8081 keywords = "tensor network contraction graph hypergraph partition einsum" ,
8182)
You can’t perform that action at this time.
0 commit comments