Beispiel #1
0
    def test_solver_modernization(self):
        """Solver's data is "modernized", i.e. missing props are added."""

        # get real solver
        with BrickedClient() as client:
            solver = client.get_solver(qpu=True)

        # cripple it
        del solver.properties['topology']

        # mock minimal data adapter response
        inspector_data = {
            'rel': {
                'solver': solver
            },
            'details': {
                'id': 'mock-id'
            }
        }

        # store it
        push_inspector_data(inspector_data)

        # get solver data
        solver_data = get_solver_data(solver.id)

        # verify missing data is recreated
        self.assertIn('topology', solver_data['properties'])
        self.assertEqual(solver_data['properties']['topology']['type'],
                         'chimera')

        # verify the original solver data is intact
        self.assertNotIn('topology', solver.properties)
Beispiel #2
0
def show_bqm_response(bqm, embedding_context, response, warnings=None, params=None):
    """
    Visualize a quantum machine instruction (QMI) response and binary quadratic model.
    """
    data = from_bqm_response(bqm=bqm, embedding_context=embedding_context,
                             response=response, warnings=warnings, params=params)
    id_ = push_inspector_data(data)
    return open_problem(id_)
Beispiel #3
0
def show_qmi(problem, response, embedding_context=None, warnings=None, params=None):
    """
    Visualize a quantum machine instruction (QMI).
    """
    data = from_qmi_response(problem=problem, response=response,
                             embedding_context=embedding_context,
                             warnings=warnings, params=params)
    id_ = push_inspector_data(data)
    return open_problem(id_)
Beispiel #4
0
def show_bqm_sampleset(bqm, sampleset, sampler, embedding_context=None,
                       warnings=None, params=None):
    """
    Visualize a returned sampleset and binary quadratic model.
    """
    data = from_bqm_sampleset(bqm=bqm, sampleset=sampleset, sampler=sampler,
                              embedding_context=embedding_context,
                              warnings=warnings, params=params)
    id_ = push_inspector_data(data)
    return open_problem(id_)
Beispiel #5
0
def show(*args, **kwargs):
    """Auto-detect and forward to the ``show_*`` optimal for the specified
    arguments.

    For description of accepted arguments, see of :func:`.show_qmi`,
    :func:`.show_bqm_response`, or :func:`.show_bqm_sampleset`.

    Note:
        Low-level data capture is enabled on `dwave.inspector` import. Data
        captured includes the full quantum machine instruction (QMI), QPU
        response, embedding context, warnings, and sampling parameters.

        If data capture is enabled prior to embedding/sampling, you need
        provide to :func:`~dwave.inspector.show` only a response or problem ID
        for QMI inspection or a :class:`~dimod.SampleSet` for logical problem
        and QMI inspection.

        If data capture is not enabled prior to embedding/sampling, provide
        all relevant data explicitly to :func:`~dwave.inspector.show`.

    Examples:

        This example shows ways to visualize just a QMI (not a logical problem)::

            show(response)
            show((h, J), response)
            show(Q, response)
            show('69ace80c-d3b1-448a-a028-b51b94f4a49d')

        This example visualizes a QMI and explicit embedding::

            show((h, J), response, dict(embedding=embedding, chain_strength=5))

        This example shows embedding and warnings read from the sampleset::

            show(bqm, sampleset)

        This example shows embedding and warnings read from a :class:`~dimod.SampleSet`,
        from which the logical problem is reconstructed::

            show(sampleset)

    """
    block = kwargs.pop('block', Block.ONCE)
    timeout = kwargs.pop('timeout', None)
    data = from_objects(*args, **kwargs)
    id_ = push_inspector_data(data)
    return open_problem(id_, block=block, timeout=timeout)