code: def binary_to_spin(linear, quadratic, offset):
          
          h = {}
          J = {}
          linear_offset = 0.0
          quadratic_offset = 0.0
  
          for u, bias in iteritems(linear):
              h[u] = .5 * bias
              linear_offset += bias
  
          for (u, v), bias in iteritems(quadratic):
  
              J[(u, v)] = .25 * bias
  
              h[u] += .25 * bias
              h[v] += .25 * bias
  
              quadratic_offset += bias
  
          offset += .5 * linear_offset + .25 * quadratic_offset
  
          return h, J, offset
docs: convert linear, quadratic and offset from binary to spin.
          Does no checking of vartype. Copies all of the values into new objects.