original_docstring:  Scale and sample from the provided binary quadratic model.
  
          Problem is scaled based on the per qubit coupling range when 
          that range is exceeded. 
  
          Args:
              bqm (:obj:`dimod.BinaryQuadraticModel`):
                  Binary quadratic model to be sampled from.
  
              **parameters:
                  Parameters for the sampling method, specified by the child
                  sampler.
  
          Returns:
              :obj:`dimod.SampleSet`
          
docstring: Scale and sample from the provided binary quadratic model.
  Problem is scaled based on the per qubit coupling range when
  that range is exceeded.
docstring_tokens: Scale and sample from the provided binary quadratic model . Problem is scaled based on the per qubit coupling range when that range is exceeded .
code: def sample(self, bqm, **parameters):
          """ Scale and sample from the provided binary quadratic model.
  
          Problem is scaled based on the per qubit coupling range when 
          that range is exceeded. 
  
          Args:
              bqm (:obj:`dimod.BinaryQuadraticModel`):
                  Binary quadratic model to be sampled from.
  
              **parameters:
                  Parameters for the sampling method, specified by the child
                  sampler.
  
          Returns:
              :obj:`dimod.SampleSet`
          """
          if 'per_qubit_coupling_range' in self.child.properties.keys():
  
              min_lim = self.child.properties['per_qubit_coupling_range'][0]
              max_lim = self.child.properties['per_qubit_coupling_range'][1]
  
              total_coupling_range = {v: sum(bqm.adj[v].values()) 
                                      for v in bqm.variables}
  
              min_coupling_range = min(total_coupling_range.values())
              max_coupling_range = max(total_coupling_range.values())
  
              if (min_coupling_range < min_lim or max_coupling_range > max_lim):
                  warnings.warn(
                      f'The per_qubit_coupling_range is violated after scaling.'
                      ' The problem is rescaled with respect to coupling range.'
                      ' No variables, interactions, or offset are ignored.')
  
                  # scaling 
                  inv_scalar = max(min_coupling_range / min_lim, 
                                   max_coupling_range / max_lim)
                  scalar = 1.0 / inv_scalar
  
                  bqm.scale(scalar,
                            ignored_variables=[],
                            ignored_interactions=[],
                            ignore_offset=[])
  
                  sampleset = self.child.sample(bqm, **parameters)
                  yield sampleset 
  
              else:
                  sampleset = self.child.sample(bqm, **parameters)
                  yield sampleset 
          else:
              sampleset = self.child.sample(bqm, **parameters)
              yield sampleset 
  
          yield sampleset
code_tokens: def sample ( self , bqm , ** parameters ) : if 'per_qubit_coupling_range' in self . child . properties . keys ( ) : min_lim = self . child . properties [ 'per_qubit_coupling_range' ] [ 0 ] max_lim = self . child . properties [ 'per_qubit_coupling_range' ] [ 1 ] total_coupling_range = { v : sum ( bqm . adj [ v ] . values ( ) ) for v in bqm . variables } min_coupling_range = min ( total_coupling_range . values ( ) ) max_coupling_range = max ( total_coupling_range . values ( ) ) if ( min_coupling_range < min_lim or max_coupling_range > max_lim ) : warnings . warn ( f'The per_qubit_coupling_range is violated after scaling.' ' The problem is rescaled with respect to coupling range.' ' No variables, interactions, or offset are ignored.' ) inv_scalar = max ( min_coupling_range / min_lim , max_coupling_range / max_lim ) scalar = 1.0 / inv_scalar bqm . scale ( scalar , ignored_variables = [ ] , ignored_interactions = [ ] , ignore_offset = [ ] ) sampleset = self . child . sample ( bqm , ** parameters ) yield sampleset else : sampleset = self . child . sample ( bqm , ** parameters ) yield sampleset else : sampleset = self . child . sample ( bqm , ** parameters ) yield sampleset yield sampleset
short_docstring: Scale and sample from the provided binary quadratic model.
short_docstring_tokens: Scale and sample from the provided binary quadratic model .
comment: """ Scale and sample from the provided binary quadratic model.
  
          Problem is scaled based on the per qubit coupling range when 
          that range is exceeded. 
  
          Args:
              bqm (:obj:`dimod.BinaryQuadraticModel`):
                  Binary quadratic model to be sampled from.
  
              **parameters:
                  Parameters for the sampling method, specified by the child
                  sampler.
  
          Returns:
              :obj:`dimod.SampleSet`
          """$SEP$# scaling 