dwave.cloud.computation.Future.num_occurrences#

property Future.num_occurrences[source]#

Number of sample occurrences buffer for the submitted job.

First calls to access data of a Future object are blocking; subsequent access to this property is non-blocking.

Returns:

number of occurrences. When returned results are ordered in a histogram, num_occurrences indicates the number of times a particular solution recurred.

Return type:

list or NumPy matrix of doubles

Examples

This example creates a solver using the local system’s default D-Wave Cloud Client configuration file, submits a simple Ising problem with several ground states to a remote D-Wave resource for 20 samples, and prints the returned results, which are ordered as a histogram. The problem’s ground states tend to recur frequently, and so those solutions have num_occurrences greater than 1.

>>> from dwave.cloud import Client
>>> with Client.from_config() as client:  
...     solver = client.get_solver()
...     quad = {(16, 20): -1, (17, 20): 1, (16, 21): 1, (17, 21): 1}
...     computation = solver.sample_ising({}, quad, num_reads=500, answer_mode='histogram')
...     for i in range(len(computation.num_occurrences)):
...         print(computation.samples[i][16], computation.samples[i][17],
...               computation.samples[i][20], computation.samples[i][21],
...               ' --> ', computation.energies[i], computation.num_occurrences[i])
...
(-1, 1, -1, -1, ' --> ', -2.0, 41)
(-1, -1, -1, 1, ' --> ', -2.0, 53)
(1, -1, 1, 1, ' --> ', -2.0, 55)
(1, 1, -1, -1, ' --> ', -2.0, 52)
(1, 1, 1, -1, ' --> ', -2.0, 60)
(1, -1, 1, -1, ' --> ', -2.0, 196)
(-1, 1, -1, 1, ' --> ', -2.0, 15)
(-1, -1, 1, 1, ' --> ', -2.0, 28)