Computes the probability of each state given a particular set of angles.

        :param angles: A concatenated list of angles [betas]+[gammas]
        :return: The probabilities of each outcome given those angles.
184276
def probabilities(self, angles: List[float]) -> np.ndarray:
        
        if isinstance(angles, list):
            angles = np.array(angles)

        assert angles.shape[0] == 2 * self.steps, "angles must be 2 * steps"

        param_prog = self.get_parameterized_program()
        prog = param_prog(angles)
        wf = WavefunctionSimulator().wavefunction(prog)
        wf = wf.amplitudes.reshape((-1, 1))
        probs = np.zeros_like(wf)
        for xx in range(2 ** len(self.qubits)):
            probs[xx] = np.conj(wf[xx]) * wf[xx]
        return probs
1252699
def get_measure_probabilities(wf, qubit):
    
    n_qubits = len(wf.shape)
    all_inds = list(range(n_qubits))

    return np.einsum(np.conj(wf), all_inds,
                     wf, all_inds,
                     [int(qubit)])
1198984
def get_angle_difference(v1, v2):
    """"""
    v1 = numpy.array(v1)
    v2 = numpy.array(v2)
    angle=numpy.arccos(old_div((numpy.dot(v1, v2) ), (numpy.sqrt(math.fsum(v1**2)) * numpy.sqrt(math.fsum(v2**2)))))    
    return math.degrees(angle)
92750
def rotate_2D(angle):
    
    return N.array([[N.cos(angle),-N.sin(angle)],
                    [N.sin(angle),N.cos(angle)]])
902817
def rotateX(self, angle):
        
        rad = angle * math.pi / 180
        cosa = math.cos(rad)
        sina = math.sin(rad)
        y = self.y * cosa - self.z * sina
        z = self.y * sina + self.z * cosa
        return Point3D(self.x, y, z)
1130941
def angleDiff(angle1, angle2, take_smaller=True):
    
    a = np.arctan2(np.sin(angle1 - angle2), np.cos(angle1 - angle2))
    if isinstance(a, np.ndarray) and take_smaller:
        a = np.abs(a)
        # take smaller of both possible angles:
        ab = np.abs(np.pi - a)
        with np.errstate(invalid='ignore'):
            i = a > ab
        a[i] = ab[i]
    return a
260905
def get_angle(v1, v2, units="degrees"):
    
    d = np.dot(v1, v2) / np.linalg.norm(v1) / np.linalg.norm(v2)
    d = min(d, 1)
    d = max(d, -1)
    angle = math.acos(d)
    if units == "degrees":
        return math.degrees(angle)
    elif units == "radians":
        return angle
    else:
        raise ValueError("Invalid units {}".format(units))
320829
def angular_errors(self, degrees=True):
        
        hyp_axes = self.method(self)
        v = angular_errors(hyp_axes)
        if degrees:
            v = N.degrees(v)
        return tuple(v)
262638
def euler_angles(self):
        
        q_wxyz = self.quaternion
        q_xyzw = np.roll(q_wxyz, -1)
        return transformations.euler_from_quaternion(q_xyzw)
287404
def create_from_axis_angle(cls, angle, ax, ay, az, degrees=False):
        
        if degrees:
            angle = np.radians(angle)
        while angle < 0:
            angle += np.pi*2
        angle2 = angle/2.0
        sinang2 = np.sin(angle2)
        return Quaternion(np.cos(angle2), ax*sinang2, ay*sinang2, az*sinang2)
325985
def containment_angle(self, energies=None, fraction=0.68, scale_fn=None):
        """"""

        if energies is None:
            energies = self.energies

        vals = self.interp(energies[np.newaxis, :], self.dtheta[:, np.newaxis],
                           scale_fn=scale_fn)
        dtheta = np.radians(self.dtheta[:, np.newaxis] * np.ones(vals.shape))
        return self._calc_containment(dtheta, vals, fraction)
526541
def angle_to(self, rhs):
    

    return math.acos(self.dot(rhs) / (self.magnitude() * rhs.magnitude()))
1289091
def fit_angle(fit1, fit2, degrees=True):
    
    return N.degrees(angle(fit1.normal,fit2.normal))
906032
def angle(self, center1_x, center1_y, center2_x, center2_y):
        
        phi_G = np.arctan2(center2_y - center1_y, center2_x - center1_x)
        return phi_G
151394
def get_full_angles(self):
        
        if (self.sun_azi is not None and self.sun_zen is not None and
                self.sat_azi is not None and self.sat_zen is not None):
            return self.sun_azi, self.sun_zen, self.sat_azi, self.sat_zen

        self.sun_azi, self.sun_zen, self.sat_azi, self.sat_zen = self._get_full_angles()
        self.sun_azi = da.from_delayed(self.sun_azi, dtype=self["ANGULAR_RELATIONS"].dtype,
                                       shape=(self.scanlines, self.pixels))
        self.sun_zen = da.from_delayed(self.sun_zen, dtype=self["ANGULAR_RELATIONS"].dtype,
                                       shape=(self.scanlines, self.pixels))
        self.sat_azi = da.from_delayed(self.sat_azi, dtype=self["ANGULAR_RELATIONS"].dtype,
                                       shape=(self.scanlines, self.pixels))
        self.sat_zen = da.from_delayed(self.sat_zen, dtype=self["ANGULAR_RELATIONS"].dtype,
                                       shape=(self.scanlines, self.pixels))
        return self.sun_azi, self.sun_zen, self.sat_azi, self.sat_zen
198400
def _wrap_angle(self, theta):
        
        result = ((theta + pi) % (2*pi)) - pi
        if result == -pi: result = pi
        return result
1054007
def angles(self) -> Tuple[float]:
        
        m = self._matrix
        lengths = self.lengths
        angles = np.zeros(3)
        for i in range(3):
            j = (i + 1) % 3
            k = (i + 2) % 3
            angles[i] = abs_cap(dot(m[j], m[k]) / (lengths[j] * lengths[k]))
        angles = np.arccos(angles) * 180.0 / pi
        return tuple(angles.tolist())