bolt/spark/array.py
def transpose(self, *axes):
        """
        Return an array with the axes transposed.

        This operation will incur a swap unless the
        desiured permutation can be obtained
        only by transpoing the keys or the values.

        Parameters
        ----------
        axes : None, tuple of ints, or n ints
            If None, will reverse axis order.
        """
        if len(axes) == 0:
            p = arange(self.ndim-1, -1, -1)
        else:
            p = asarray(argpack(axes))

        istransposeable(p, range(self.ndim))

        split = self.split

        # compute the keys/value axes that need to be swapped
        new_keys, new_values = p[:split], p[split:]
        swapping_keys = sort(new_values[new_values < split])
        swapping_values = sort(new_keys[new_keys >= split])
        stationary_keys = sort(new_keys[new_keys < split])
        stationary_values = sort(new_values[new_values >= split])

        # compute the permutation that the swap causes
        p_swap = r_[stationary_keys, swapping_values, swapping_keys, stationary_values]

        # compute the extra permutation (p_x)  on top of this that
        # needs to happen to get the full permutation desired
        p_swap_inv = argsort(p_swap)
        p_x = p_swap_inv[p]
        p_keys, p_values = p_x[:split], p_x[split:]-split

        # perform the swap and the the within key/value permutations
        arr = self.swap(swapping_keys, swapping_values-split)
        arr = arr.keys.transpose(tuple(p_keys.tolist()))
        arr = arr.values.transpose(tuple(p_values.tolist()))

        return arr
def transpose(self, *axes):
        if len(axes) == 0:
            p = arange(self.ndim-1, -1, -1)
        else:
            p = asarray(argpack(axes))

        istransposeable(p, range(self.ndim))

        split = self.split

        # compute the keys/value axes that need to be swapped
        new_keys, new_values = p[:split], p[split:]
        swapping_keys = sort(new_values[new_values < split])
        swapping_values = sort(new_keys[new_keys >= split])
        stationary_keys = sort(new_keys[new_keys < split])
        stationary_values = sort(new_values[new_values >= split])

        # compute the permutation that the swap causes
        p_swap = r_[stationary_keys, swapping_values, swapping_keys, stationary_values]

        # compute the extra permutation (p_x)  on top of this that
        # needs to happen to get the full permutation desired
        p_swap_inv = argsort(p_swap)
        p_x = p_swap_inv[p]
        p_keys, p_values = p_x[:split], p_x[split:]-split

        # perform the swap and the the within key/value permutations
        arr = self.swap(swapping_keys, swapping_values-split)
        arr = arr.keys.transpose(tuple(p_keys.tolist()))
        arr = arr.values.transpose(tuple(p_values.tolist()))

        return arr
def transpose ( self , * axes ) : if len ( axes ) == 0 : p = arange ( self . ndim - 1 , - 1 , - 1 ) else : p = asarray ( argpack ( axes ) ) istransposeable ( p , range ( self . ndim ) ) split = self . split # compute the keys/value axes that need to be swapped new_keys , new_values = p [ : split ] , p [ split : ] swapping_keys = sort ( new_values [ new_values < split ] ) swapping_values = sort ( new_keys [ new_keys >= split ] ) stationary_keys = sort ( new_keys [ new_keys < split ] ) stationary_values = sort ( new_values [ new_values >= split ] ) # compute the permutation that the swap causes p_swap = r_ [ stationary_keys , swapping_values , swapping_keys , stationary_values ] # compute the extra permutation (p_x)  on top of this that # needs to happen to get the full permutation desired p_swap_inv = argsort ( p_swap ) p_x = p_swap_inv [ p ] p_keys , p_values = p_x [ : split ] , p_x [ split : ] - split # perform the swap and the the within key/value permutations arr = self . swap ( swapping_keys , swapping_values - split ) arr = arr . keys . transpose ( tuple ( p_keys . tolist ( ) ) ) arr = arr . values . transpose ( tuple ( p_values . tolist ( ) ) ) return arr
Return an array with the axes transposed.

        This operation will incur a swap unless the
        desiured permutation can be obtained
        only by transpoing the keys or the values.

        Parameters
        ----------
        axes : None, tuple of ints, or n ints
            If None, will reverse axis order.
Return an array with the axes transposed .