nodes: 0, module; 1, function_definition; 2, function_name:samples; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, return_statement; 12, identifier:n; 13, None; 14, identifier:sorted_by; 15, string; 16, comment:"""Return an iterable over the samples.
  
          Args:
              n (int, optional, default=None):
                  Maximum number of samples to return in the view.
  
              sorted_by (str/None, optional, default='energy'):
                  Selects the record field used to sort the samples. If None,
                  samples are returned in record order.
  
          Returns:
              :obj:`.SamplesArray`: A view object mapping variable labels to
              values.
  
          Examples:
  
              >>> sampleset = dimod.ExactSolver().sample_ising({'a': 0.1, 'b': 0.0},
              ...                                              {('a', 'b'): 1})
              >>> for sample in sampleset.samples():
              ...     print(sample)
              {'a': -1, 'b': 1}
              {'a': 1, 'b': -1}
              {'a': -1, 'b': -1}
              {'a': 1, 'b': 1}
  
              >>> sampleset = dimod.ExactSolver().sample_ising({'a': 0.1, 'b': 0.0},
              ...                                              {('a', 'b'): 1})
              >>> samples = sampleset.samples()
              >>> samples[0]
              {'a': -1, 'b': 1}
              >>> samples[0, 'a']
              -1
              >>> samples[0, ['b', 'a']]
              array([ 1, -1], dtype=int8)
              >>> samples[1:, ['a', 'b']]
              array([[ 1, -1],
                     [-1, -1],
                     [ 1,  1]], dtype=int8)
  
          """; 17, comparison_operator:n is not None; 18, block; 19, comparison_operator:sorted_by is None; 20, block; 21, else_clause; 22, call; 23, string_content:energy; 24, identifier:n; 25, None; 26, return_statement; 27, identifier:sorted_by; 28, None; 29, expression_statement; 30, block; 31, identifier:SamplesArray; 32, argument_list; 33, subscript; 34, assignment; 35, expression_statement; 36, expression_statement; 37, identifier:samples; 38, attribute; 39, call; 40, slice; 41, identifier:samples; 42, attribute; 43, assignment; 44, assignment; 45, identifier:self; 46, identifier:variables; 47, attribute; 48, argument_list; 49, identifier:n; 50, attribute; 51, identifier:sample; 52, identifier:order; 53, call; 54, identifier:samples; 55, subscript; 56, identifier:self; 57, identifier:samples; 58, keyword_argument; 59, identifier:self; 60, identifier:record; 61, attribute; 62, argument_list; 63, attribute; 64, identifier:order; 65, identifier:sorted_by; 66, identifier:sorted_by; 67, identifier:np; 68, identifier:argsort; 69, subscript; 70, attribute; 71, identifier:sample; 72, attribute; 73, identifier:sorted_by; 74, identifier:self; 75, identifier:record; 76, identifier:self; 77, identifier:record
code: def samples(self, n=None, sorted_by='energy'):
          """Return an iterable over the samples.
  
          Args:
              n (int, optional, default=None):
                  Maximum number of samples to return in the view.
  
              sorted_by (str/None, optional, default='energy'):
                  Selects the record field used to sort the samples. If None,
                  samples are returned in record order.
  
          Returns:
              :obj:`.SamplesArray`: A view object mapping variable labels to
              values.
  
          Examples:
  
              >>> sampleset = dimod.ExactSolver().sample_ising({'a': 0.1, 'b': 0.0},
              ...                                              {('a', 'b'): 1})
              >>> for sample in sampleset.samples():
              ...     print(sample)
              {'a': -1, 'b': 1}
              {'a': 1, 'b': -1}
              {'a': -1, 'b': -1}
              {'a': 1, 'b': 1}
  
              >>> sampleset = dimod.ExactSolver().sample_ising({'a': 0.1, 'b': 0.0},
              ...                                              {('a', 'b'): 1})
              >>> samples = sampleset.samples()
              >>> samples[0]
              {'a': -1, 'b': 1}
              >>> samples[0, 'a']
              -1
              >>> samples[0, ['b', 'a']]
              array([ 1, -1], dtype=int8)
              >>> samples[1:, ['a', 'b']]
              array([[ 1, -1],
                     [-1, -1],
                     [ 1,  1]], dtype=int8)
  
          """
          if n is not None:
              return self.samples(sorted_by=sorted_by)[:n]
  
          if sorted_by is None:
              samples = self.record.sample
          else:
              order = np.argsort(self.record[sorted_by])
              samples = self.record.sample[order]
  
          return SamplesArray(samples, self.variables)