Python numpy 模块,alen() 实例源码

我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用numpy.alen()

项目:lps-anchor-pos-estimator    作者:bitcraze    | 项目源码 | 文件源码
def setdiff(eq1, eq2):

    eq1, eq2 = eqsize(eq1, eq2)

    c1 = [None] * eq1.shape
    c2 = [None] * eq2.shape

    for i in range(0, eq1.size):

        c1.append[i] = hash(eq2[i])

    for i in range(0, eq2.size):

        c2[i] = hash(eq2[i])

    ia = np.delete(np.arange(np.alen(c1)), np.searchsorted(c1, c2))

    ia = (ia[:]).conj().T

    p = eq1[ia]

    return p, ia
项目:SDF-Python    作者:ScientificDataFormat    | 项目源码 | 文件源码
def _validate_dataset(ds):
    if not type(ds.data) is np.ndarray:
        return ['Dataset.data must be a numpy.ndarray']

    elif np.alen(ds.data) < 1:
        return ['Dataset.data must not be empty']

    elif not np.issubdtype(ds.data.dtype, np.float64):
        return ['Dataset.data.dtype must be numpy.float64']

    if ds.is_scale:
        if len(ds.data.shape) != 1:
            return ['Scales must be one-dimensional']
        if np.any(np.diff(ds.data) <= 0):
            return ['Scales must be strictly monotonic increasing']
    else:
        if (len(ds.data.shape) >= 1) and (ds.data.shape[0] > 0) and not (len(ds.data.shape) == len(ds.scales)):
            return ['The number of scales does not match the number of dimensions']

    return []
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_basic(self):
        m = np.array([1, 2, 3])
        self.assertEqual(np.alen(m), 3)

        m = np.array([[1, 2, 3], [4, 5, 7]])
        self.assertEqual(np.alen(m), 2)

        m = [1, 2, 3]
        self.assertEqual(np.alen(m), 3)

        m = [[1, 2, 3], [4, 5, 7]]
        self.assertEqual(np.alen(m), 2)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_singleton(self):
        self.assertEqual(np.alen(5), 1)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_basic(self):
        m = np.array([1, 2, 3])
        self.assertEqual(np.alen(m), 3)

        m = np.array([[1, 2, 3], [4, 5, 7]])
        self.assertEqual(np.alen(m), 2)

        m = [1, 2, 3]
        self.assertEqual(np.alen(m), 3)

        m = [[1, 2, 3], [4, 5, 7]]
        self.assertEqual(np.alen(m), 2)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_singleton(self):
        self.assertEqual(np.alen(5), 1)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_basic(self):
        m = np.array([1, 2, 3])
        self.assertEqual(np.alen(m), 3)

        m = np.array([[1, 2, 3], [4, 5, 7]])
        self.assertEqual(np.alen(m), 2)

        m = [1, 2, 3]
        self.assertEqual(np.alen(m), 3)

        m = [[1, 2, 3], [4, 5, 7]]
        self.assertEqual(np.alen(m), 2)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_singleton(self):
        self.assertEqual(np.alen(5), 1)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_basic(self):
        m = np.array([1, 2, 3])
        self.assertEqual(np.alen(m), 3)

        m = np.array([[1, 2, 3], [4, 5, 7]])
        self.assertEqual(np.alen(m), 2)

        m = [1, 2, 3]
        self.assertEqual(np.alen(m), 3)

        m = [[1, 2, 3], [4, 5, 7]]
        self.assertEqual(np.alen(m), 2)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_singleton(self):
        self.assertEqual(np.alen(5), 1)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_basic(self):
        m = np.array([1, 2, 3])
        self.assertEqual(np.alen(m), 3)

        m = np.array([[1, 2, 3], [4, 5, 7]])
        self.assertEqual(np.alen(m), 2)

        m = [1, 2, 3]
        self.assertEqual(np.alen(m), 3)

        m = [[1, 2, 3], [4, 5, 7]]
        self.assertEqual(np.alen(m), 2)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_singleton(self):
        self.assertEqual(np.alen(5), 1)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def shape(a):
    """
    Return the shape of an array.

    Parameters
    ----------
    a : array_like
        Input array.

    Returns
    -------
    shape : tuple of ints
        The elements of the shape tuple give the lengths of the
        corresponding array dimensions.

    See Also
    --------
    alen
    ndarray.shape : Equivalent array method.

    Examples
    --------
    >>> np.shape(np.eye(3))
    (3, 3)
    >>> np.shape([[1, 2]])
    (1, 2)
    >>> np.shape([0])
    (1,)
    >>> np.shape(0)
    ()

    >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
    >>> np.shape(a)
    (2,)
    >>> a.shape
    (2,)

    """
    try:
        result = a.shape
    except AttributeError:
        result = asarray(a).shape
    return result