Skip to content

Commit

Permalink
Avoid casting to fileview-able BQM on upload, if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Jul 6, 2020
1 parent 7057ea5 commit a55d58a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dwave/cloud/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,21 @@ def _bqm_as_fileview(bqm):
# XXX: temporary until something like dwavesystems/dimod#599 is implemented.

try:
import dimod
from dimod.serialization.fileview import FileView as BQMFileView
from dimod import AdjVectorBQM
except ImportError: # pragma: no cover
return

if isinstance(bqm, BQMFileView):
return bqm

try:
if not isinstance(bqm, AdjVectorBQM):
# test explicitly to avoid copy on cast if possible
fileviewable = (dimod.AdjArrayBQM, dimod.AdjVectorBQM, dimod.AdjMapBQM)
if not isinstance(bqm, fileviewable):
try:
bqm = AdjVectorBQM(bqm)
except:
return
except:
return

try:
return BQMFileView(bqm)
Expand Down

0 comments on commit a55d58a

Please sign in to comment.