Rearranges data from depth into blocks of spatial data.
556465
def depthtospace(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'})

    return "depth_to_space", new_attrs, inputs
518905
private static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>>
		N rearrangeTree(AbstractGISTreeSet<P, N> tree, N node, Rectangle2afp<?, ?, ?, ?, ?, ?> desiredBounds,
				GISTreeSetNodeFactory<P, N> builder) {
		// Search for the node that completely contains the desired area
		N topNode = node.getParentNode();
		while (topNode != null && isOutsideNodeBuildingBounds(topNode, desiredBounds)) {
			topNode = topNode.getParentNode();
		}

		final Rectangle2afp<?, ?, ?, ?, ?, ?> dr;
		if (topNode == null) {
			// Node node found, the entire tree should be rebuilt
			topNode = tree.getTree().getRoot();
			if (topNode == null) {
				throw new IllegalStateException();
			}
			dr = union(topNode, desiredBounds);
		} else {
			dr = getNormalizedNodeBuildingBounds(topNode, desiredBounds);
		}

		// Build a new subtree
		final N parent = topNode.getParentNode();
		final Iterator<P> dataIterator = new PrefixDataDepthFirstTreeIterator<>(topNode);
		final N newTopNode = builder.newNode(
				topNode.getZone(),
				dr.getMinX(), dr.getMinY(), dr.getWidth(), dr.getHeight());
		while (dataIterator.hasNext()) {
			if (!addInside(tree, newTopNode, dataIterator.next(), builder, false)) {
				throw new IllegalStateException();
			}
		}

		// Replace rearranged subtree by the new one
		if (parent != null) {
			parent.setChildAt(topNode.getZone().ordinal(), newTopNode);
			return parent;
		}
		tree.getTree().setRoot(newTopNode);
		return newTopNode;
	}
42267
def _condense(self, data):
    '''
    
    '''
    if data:
      return reduce(operator.ior, data.values())
    return set()
646661
def rearrange
      if self.parent_id
        self.parent_ids = parent.parent_ids + [self.parent_id]
      else
        self.parent_ids = []
      end

      self.depth = parent_ids.size

      rearrange_children! if self.parent_ids_changed?
    end
894943
def blockshapes(self):
        """"""
        if self._blockshapes is None:
            if self._filename:
                self._populate_from_rasterio_object(read_image=False)
            else:
                # if no file is attached to the raster set the shape of each band to be the data array size
                self._blockshapes = [(self.height, self.width) for z in range(self.num_bands)]
        return self._blockshapes
126720
def scatter_blocks_2d(x, indices, shape):
  """"""
  x_shape = common_layers.shape_list(x)
  # [length, batch, heads, dim]
  x_t = tf.transpose(
      tf.reshape(x, [x_shape[0], x_shape[1], -1, x_shape[-1]]), [2, 0, 1, 3])
  x_t_shape = common_layers.shape_list(x_t)
  indices = tf.reshape(indices, [-1, 1])
  scattered_x = tf.scatter_nd(indices, x_t, x_t_shape)
  scattered_x = tf.transpose(scattered_x, [1, 2, 0, 3])
  return tf.reshape(scattered_x, shape)
58761
function transform( data ) {
	var rows = data.rows;
	var out;
	var i;
	out = new Array( rows.length );
	for ( i = 0; i < rows.length; i++ ) {
		out[ i ] = rows[ i ].key[ 1 ];
	}
	return out;
}
390153
def merge(data,skip=50,fraction=1.0):
    """"""

    w,s,d = data.chains.shape
    
    start = int((1.0 - fraction) * s)
    total = int((s - start) / skip)
        
    return data.chains[:,start::skip,:].reshape((w*total,d))
109285
public void rearrangeTriangles(int[] indices) {
        assert indices.length % 3 == 0;
        // Step 1: Make sure that the first index of each triangle is the smallest
        // one (rotate triangle nodes if necessary)
        for (int off = 0; off < indices.length; off += 3) {
            if ((indices[off + 1] < indices[off]) && (indices[off + 1] < indices[off + 2])) {
                int tmp = indices[off];
                indices[off] = indices[off + 1];
                indices[off + 1] = indices[off + 2];
                indices[off + 2] = tmp;
            } else if ((indices[off + 2] < indices[off]) && (indices[off + 2] < indices[off + 1])) {
                int tmp = indices[off];
                indices[off] = indices[off + 2];
                indices[off + 2] = indices[off + 1];
                indices[off + 1] = tmp;
            }
        }

        // Step 2: Sort the triangles based on the first triangle index
        Triangle[] tris = new Triangle[indices.length / 3];
        for (int i = 0; i < tris.length; i++) {
            int off = i * 3;
            tris[i] = new Triangle(indices, off);
        }

        Arrays.sort(tris);

        for (int i = 0; i < tris.length; i++) {
            int off = i * 3;
            tris[i].copyBack(indices, off);
        }
    }
1271806
def rectify(self, frames):
        
        new_frames = []
        for i, side in enumerate(("left", "right")):
            new_frames.append(cv2.remap(frames[i],
                                        self.undistortion_map[side],
                                        self.rectification_map[side],
                                        cv2.INTER_NEAREST))
        return new_frames
62991
public void subDivide() {
        MemoryWorkspace workspace =
                workspaceMode == WorkspaceMode.NONE ? new DummyWorkspace()
                        : Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread(
                        workspaceConfigurationExternal,
                        workspaceExternal);
        try (MemoryWorkspace ws = workspace.notifyScopeEntered()) {

            INDArray newCorner = Nd4j.create(D);
            INDArray newWidth = Nd4j.create(D);
            for (int i = 0; i < numChildren; i++) {
                int div = 1;
                for (int d = 0; d < D; d++) {
                    newWidth.putScalar(d, .5 * boundary.width(d));
                    if ((i / div) % 2 == 1)
                        newCorner.putScalar(d, boundary.corner(d) - .5 * boundary.width(d));
                    else
                        newCorner.putScalar(d, boundary.corner(d) + .5 * boundary.width(d));
                    div *= 2;
                }

                children[i] = new SpTree(this, data, newCorner, newWidth, indices);

            }

            // Move existing points to correct children
            for (int i = 0; i < size; i++) {
                boolean success = false;
                for (int j = 0; j < this.numChildren; j++)
                    if (!success)
                        success = children[j].insert(index[i]);

                index[i] = -1;
            }

            // Empty parent node
            size = 0;
            isLeaf = false;
        }
    }
460452
def denormalize_bboxes(bboxes, rows, cols):
    """"""
    return [denormalize_bbox(bbox, rows, cols) for bbox in bboxes]
505554
def _recursiveReduce(mapFunc, reductionFunc, scan, *iterables):
    """"""
    if iterables:
        half = min(len(x) // 2 for x in iterables)
        data_left = [list(x)[:half] for x in iterables]
        data_right = [list(x)[half:] for x in iterables]
    else:
        data_left = data_right = [[]]

    # Submit the left and right parts of the reduction
    out_futures = [None, None]
    out_results = [None, None]
    for index, data in enumerate([data_left, data_right]):
        if any(len(x) <= 1 for x in data):
            out_results[index] = mapFunc(*list(zip(*data))[0])
        else:
            out_futures[index] = submit(
                _recursiveReduce,
                mapFunc,
                reductionFunc,
                scan,
                *data
            )

    # Wait for the results
    for index, future in enumerate(out_futures):
        if future:
            out_results[index] = future.result()

    # Apply a scan if needed
    if scan:
        last_results = copy.copy(out_results)
        if type(out_results[0]) is not list:
            out_results[0] = [out_results[0]]
        else:
            last_results[0] = out_results[0][-1]
        if type(out_results[1]) is list:
            out_results[0].extend(out_results[1][:-1])
            last_results[1] = out_results[1][-1]
        out_results[0].append(reductionFunc(*last_results))
        return out_results[0]

    return reductionFunc(*out_results)
4684
def reshape_to_2d(arr):
  '''
  

  '''
  return arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
809259
def dump_t_coords(dataset_dir, data_dir, dataset, root=None, compress=True):
    """"""
    if root is None:
        root = {}
    tcoords = dataset.GetPointData().GetTCoords()
    if tcoords:
        dumped_array = dump_data_array(dataset_dir, data_dir, tcoords, {}, compress)
        root['pointData']['activeTCoords'] = len(root['pointData']['arrays'])
        root['pointData']['arrays'].append({'data': dumped_array})
752495
def _slice_datasets(self, dataset_ids, slice_key, new_area, area_only=True):
        """"""
        new_datasets = {}
        datasets = (self[ds_id] for ds_id in dataset_ids)
        for ds, parent_ds in dataset_walker(datasets):
            ds_id = DatasetID.from_dict(ds.attrs)
            # handle ancillary variables
            pres = None
            if parent_ds is not None:
                pres = new_datasets[DatasetID.from_dict(parent_ds.attrs)]
            if ds_id in new_datasets:
                replace_anc(ds, pres)
                continue
            if area_only and ds.attrs.get('area') is None:
                new_datasets[ds_id] = ds
                replace_anc(ds, pres)
                continue

            if not isinstance(slice_key, dict):
                # match dimension name to slice object
                key = dict(zip(ds.dims, slice_key))
            else:
                key = slice_key
            new_ds = ds.isel(**key)
            if new_area is not None:
                new_ds.attrs['area'] = new_area

            new_datasets[ds_id] = new_ds
            if parent_ds is None:
                # don't use `__setitem__` because we don't want this to
                # affect the existing wishlist/dep tree
                self.datasets[ds_id] = new_ds
            else:
                replace_anc(new_ds, pres)
600509
def from_coords(cls, coords, sort=True):
        
        coords = list(coords)
        if sort:
            coords.sort()
        if len(coords[0]) == 2:  # 2D coordinates
            lons, lats = zip(*coords)
            depths = None
        else:  # 3D coordinates
            lons, lats, depths = zip(*coords)
            depths = numpy.array(depths)
        return cls(numpy.array(lons), numpy.array(lats), depths)