Ejemplo n.º 1
0
def test_concatenate_errors(sc):

    x = arange(2*3*4).reshape((2, 3, 4))
    b = array(x, sc, axis=0)

    with pytest.raises(ValueError):
        concatenate(b)

    with pytest.raises(NotImplementedError):
        concatenate((b, b, b))
Ejemplo n.º 2
0
def test_concatenate():

    from numpy import concatenate as npconcatenate

    x = arange(2 * 3 * 4).reshape((2, 3, 4))
    b = concatenate((x, x))
    assert allclose(npconcatenate((x, x)), b.toarray())
Ejemplo n.º 3
0
def test_concatenate(sc):

    from numpy import concatenate as npconcatenate
    x = arange(2*3*4).reshape((2, 3, 4))

    b = array(x, sc, axis=0)
    bb = concatenate((b, b), axis=0)
    assert allclose(npconcatenate((x, x), axis=0), bb.toarray())

    bb = concatenate((b, b), axis=1)
    assert allclose(npconcatenate((x, x), axis=1), bb.toarray())

    bb = concatenate((b, b), axis=2)
    assert allclose(npconcatenate((x, x), axis=2), bb.toarray())

    b = array(x, sc, axis=(0, 1))
    bb = concatenate((b, b), axis=0)
    assert allclose(npconcatenate((x, x), axis=0), bb.toarray())

    b = array(x, sc, axis=(0, 1))
    bb = concatenate((b, b), axis=1)
    assert allclose(npconcatenate((x, x), axis=1), bb.toarray())

    b = array(x, sc, axis=(0, 1))
    bb = concatenate((b, b), axis=2)
    assert allclose(npconcatenate((x, x), axis=2), bb.toarray())
Ejemplo n.º 4
0
    def concatenate(self, arry, axis=0):
        """
        Join this array with another array.

        Paramters
        ---------
        arry : ndarray or BoltArrayLocal
            Another array to concatenate with

        axis : int, optional, default=0
            The axis along which arrays will be joined.

        Returns
        -------
        BoltArrayLocal
        """
        if isinstance(arry, ndarray):
            from bolt import concatenate
            return concatenate((self, arry), axis)
        else:
            raise ValueError("other must be local array, got %s" % type(arry))
Ejemplo n.º 5
0
    def concatenate(self, arry, axis=0):
        """
        Join this array with another array.

        Paramters
        ---------
        arry : ndarray or BoltArrayLocal
            Another array to concatenate with

        axis : int, optional, default=0
            The axis along which arrays will be joined.

        Returns
        -------
        BoltArrayLocal
        """
        if isinstance(arry, ndarray):
            from bolt import concatenate
            return concatenate((self, arry), axis)
        else:
            raise ValueError("other must be local array, got %s" % type(arry))
Ejemplo n.º 6
0
def test_concatenate_errors():

    x = arange(2 * 3 * 4).reshape((2, 3, 4))

    with pytest.raises(ValueError):
        concatenate(x)
Ejemplo n.º 7
0
def test_concatenate_errors():

    x = arange(2 * 3 * 4).reshape((2, 3, 4))

    with pytest.raises(ValueError):
        concatenate(x)
Ejemplo n.º 8
0
def test_concatenate():

    from numpy import concatenate as npconcatenate
    x = arange(2 * 3 * 4).reshape((2, 3, 4))
    b = concatenate((x, x))
    assert allclose(npconcatenate((x, x)), b.toarray())
Ejemplo n.º 9
0
 def concatenate(self, arry, axis=0):
     if isinstance(arry, ndarray):
         from bolt import concatenate
         return concatenate((self, arry), axis)
     else:
         raise ValueError("other must be local array, got %s" % type(arry))
Ejemplo n.º 10
0
 def concatenate(self, arry, axis=0):
     if isinstance(arry, ndarray):
         from bolt import concatenate
         return concatenate((self, arry), axis)
     else:
         raise ValueError("other must be local array, got %s" % type(arry))