コード例 #1
0
ファイル: test_lib.py プロジェクト: syurkevi/afnumpy
def test_arctan2():
    a1 = afnumpy.random.random((2, 3))
    b1 = numpy.array(a1)
    a2 = afnumpy.random.random((2, 3))
    b2 = numpy.array(a2)
    fassert(afnumpy.arctan2(a1, a2), numpy.arctan2(b1, b2))
    c = afnumpy.random.random((2, 3))
    d = numpy.array(c)
    fassert(afnumpy.arctan2(a1, a2, out=c), numpy.arctan2(b1, b2, out=d))
    fassert(c, d)
コード例 #2
0
ファイル: test_lib.py プロジェクト: daurer/afnumpy
def test_arctan2():
    a1 = afnumpy.random.random((2,3))
    b1 = numpy.array(a1)
    a2 = afnumpy.random.random((2,3))
    b2 = numpy.array(a2)
    fassert(afnumpy.arctan2(a1,a2), numpy.arctan2(b1,b2))
    c = afnumpy.random.random((2,3))
    d = numpy.array(c)
    fassert(afnumpy.arctan2(a1,a2, out=c), numpy.arctan2(b1, b2, out=d))
    fassert(c, d)
コード例 #3
0
def angle(z, deg=0):
    """
    Return the angle of the complex argument.

    Parameters
    ----------
    z : array_like
        A complex number or sequence of complex numbers.
    deg : bool, optional
        Return angle in degrees if True, radians if False (default).

    Returns
    -------
    angle : {ndarray, scalar}
        The counterclockwise angle from the positive real axis on
        the complex plane, with dtype as numpy.float64.

    See Also
    --------
    arctan2
    absolute



    Examples
    --------
    >>> np.angle([1.0, 1.0j, 1+1j])               # in radians
    array([ 0.        ,  1.57079633,  0.78539816])
    >>> np.angle(1+1j, deg=True)                  # in degrees
    45.0

    """
    if deg:
        fact = 180 / pi
    else:
        fact = 1.0
    z = afnumpy.asarray(z)
    if numpy.issubdtype(z.dtype, numpy.complexfloating):
        zimag = z.imag
        zreal = z.real
    else:
        zimag = 0
        zreal = z
    return afnumpy.arctan2(zimag, zreal) * fact
コード例 #4
0
ファイル: function_base.py プロジェクト: Brainiarc7/afnumpy
def angle(z, deg=0):
    """
    Return the angle of the complex argument.

    Parameters
    ----------
    z : array_like
        A complex number or sequence of complex numbers.
    deg : bool, optional
        Return angle in degrees if True, radians if False (default).

    Returns
    -------
    angle : {ndarray, scalar}
        The counterclockwise angle from the positive real axis on
        the complex plane, with dtype as numpy.float64.

    See Also
    --------
    arctan2
    absolute



    Examples
    --------
    >>> np.angle([1.0, 1.0j, 1+1j])               # in radians
    array([ 0.        ,  1.57079633,  0.78539816])
    >>> np.angle(1+1j, deg=True)                  # in degrees
    45.0

    """
    if deg:
        fact = 180/pi
    else:
        fact = 1.0
    z = afnumpy.asarray(z)
    if numpy.issubdtype(z.dtype, numpy.complexfloating):
        zimag = z.imag
        zreal = z.real
    else:
        zimag = 0
        zreal = z
    return afnumpy.arctan2(zimag, zreal) * fact