r"""
        Perform a check to find pores with overlapping or undefined Geometries

        Returns
        -------
        A HealthDict
512520
def check_geometry_health(self):
        
        """
        health = HealthDict()
        health['overlapping_pores'] = []
        health['undefined_pores'] = []
        health['overlapping_throats'] = []
        health['undefined_throats'] = []
        geoms = self.geometries().keys()
        if len(geoms):
            net = self.network
            Ptemp = np.zeros((net.Np,))
            Ttemp = np.zeros((net.Nt,))
            for item in geoms:
                Pind = net['pore.'+item]
                Tind = net['throat.'+item]
                Ptemp[Pind] = Ptemp[Pind] + 1
                Ttemp[Tind] = Ttemp[Tind] + 1
            health['overlapping_pores'] = np.where(Ptemp > 1)[0].tolist()
            health['undefined_pores'] = np.where(Ptemp == 0)[0].tolist()
            health['overlapping_throats'] = np.where(Ttemp > 1)[0].tolist()
            health['undefined_throats'] = np.where(Ttemp == 0)[0].tolist()
        return health
1093009
def CheckBlobsExist(self, blob_ids, cursor=None):
    """"""
    if not blob_ids:
      return {}

    exists = {blob_id: False for blob_id in blob_ids}
    query = ("SELECT blob_id "
             "FROM blobs "
             "FORCE INDEX (PRIMARY) "
             "WHERE blob_id IN {}".format(
                 mysql_utils.Placeholders(len(blob_ids))))
    cursor.execute(query, [blob_id.AsBytes() for blob_id in blob_ids])
    for blob_id, in cursor.fetchall():
      exists[rdf_objects.BlobID.FromBytes(blob_id)] = True
    return exists
347980
def _check_intersection(self, other):
        """"""
        # pylint: disable=C0123
        props = ["_callables_db", "_reverse_callables_db", "_modules_dict"]
        for prop in props:
            self_dict = getattr(self, prop)
            other_dict = getattr(other, prop)
            keys_self = set(self_dict.keys())
            keys_other = set(other_dict.keys())
            for key in keys_self & keys_other:
                svalue = self_dict[key]
                ovalue = other_dict[key]
                same_type = type(svalue) == type(ovalue)
                if same_type:
                    list_comp = isinstance(svalue, list) and any(
                        [item not in svalue for item in ovalue]
                    )
                    str_comp = isinstance(svalue, str) and svalue != ovalue
                    dict_comp = isinstance(svalue, dict) and svalue != ovalue
                    comp = any([list_comp, str_comp, dict_comp])
                if (not same_type) or (same_type and comp):
                    emsg = "Conflicting information between objects"
                    raise RuntimeError(emsg)
1151520
def fit_geometry(self, X=None, input_type='data'):
        """"""
        if self.geom is None:
            self.geom_ = Geometry()
        elif isinstance(self.geom, Geometry):
            self.geom_ = self.geom
        else:
            try:
                kwds = dict(**self.geom)
            except TypeError:
                raise ValueError("geom must be a Geometry instance or "
                                 "a mappable/dictionary")
            self.geom_ = Geometry(**kwds)

        if self.radius is not None:
            self.geom_.set_radius(self.radius, override=False)

        # if self.radius == 'auto':
        #     if X is not None and input_type != 'affinity':
        #         self.geom_.set_radius(self.estimate_radius(X, input_type),
        #                               override=False)
        # else:
        #     self.geom_.set_radius(self.radius,
        #                           override=False)

        if X is not None:
            self.geom_.set_matrix(X, input_type)

        return self
623107
def check_cond_latents(cond_latents, hparams):
  """"""
  if cond_latents is None:
    return
  if not isinstance(cond_latents[0], list):
    cond_latents = [cond_latents]
  exp_num_latents = hparams.num_cond_latents
  if hparams.latent_dist_encoder == "conv_net":
    exp_num_latents += int(hparams.cond_first_frame)
  if len(cond_latents) != exp_num_latents:
    raise ValueError("Expected number of cond_latents: %d, got %d" %
                     (exp_num_latents, len(cond_latents)))
  for cond_latent in cond_latents:
    if len(cond_latent) != hparams.n_levels - 1:
      raise ValueError("Expected level_latents to be %d, got %d" %
                       (hparams.n_levels - 1, len(cond_latent)))
668974
def _check_signal(self, s):
        """
        s = np.asanyarray(s)
        if s.shape[0] != self.n_vertices:
            raise ValueError('First dimension must be the number of vertices '
                             'G.N = {}, got {}.'.format(self.N, s.shape))
        return s
381158
def checkIsConsistent(self):
        
        if is_an_array(self.mask) and self.mask.shape != self.data.shape:
            raise ConsistencyError("Shape mismatch mask={}, data={}"
                                   .format(self.mask.shape != self.data.shape))
795632
function isOutside (feature, poly) {
  var a = feature.bbox = feature.bbox || extent(feature)
  var b = poly.bbox = poly.bbox || extent(poly)
  return a[2] < b[0] || a[0] > b[2] || a[3] < b[1] || a[1] > b[3]
}
659101
private static boolean checkVerticesForIntersection_(
			MultiVertexGeometryImpl geom, RasterizedGeometry2D rgeom) {
		// Do a quick raster test for each point. If any point is inside, then
		// there is an intersection.
		int pointCount = geom.getPointCount();
		Point2D pt = new Point2D();
		for (int ipoint = 0; ipoint < pointCount; ipoint++) {
			geom.getXY(ipoint, pt);
			RasterizedGeometry2D.HitType hit = rgeom.queryPointInGeometry(pt.x,
					pt.y);
			if (hit == RasterizedGeometry2D.HitType.Inside) {
				return true;
			}
		}

		return false;
	}
590923
def _get_checkers(slice_shape, patch_size):
    """"""

    if patch_size is not None:
        patch_size = check_patch_size(patch_size)
    else:
        # 7 patches in each axis, min voxels/patch = 3
        # TODO make 7 a user settable parameter
        patch_size = np.round(np.array(slice_shape) / 7).astype('int16')
        patch_size = np.maximum(patch_size, np.array([3, 3]))

    black = np.zeros(patch_size)
    white = np.ones(patch_size)
    tile = np.vstack((np.hstack([black, white]), np.hstack([white, black])))

    # using ceil so we can clip the extra portions
    num_tiles = np.ceil(np.divide(slice_shape, tile.shape)).astype(int)
    checkers = np.tile(tile, num_tiles)

    # clipping any extra columns or rows
    if any(np.greater(checkers.shape, slice_shape)):
        if checkers.shape[0] > slice_shape[0]:
            checkers = np.delete(checkers, np.s_[slice_shape[0]:], axis=0)
        if checkers.shape[1] > slice_shape[1]:
            checkers = np.delete(checkers, np.s_[slice_shape[1]:], axis=1)

    return checkers
1059667
def params_mpl(df):
    """"""
    return {'ANIb_alignment_lengths': ('afmhot', df.values.min(),
                                       df.values.max()),
            'ANIb_percentage_identity': ('spbnd_BuRd', 0, 1),
            'ANIb_alignment_coverage': ('BuRd', 0, 1),
            'ANIb_hadamard': ('hadamard_BuRd', 0, 1),
            'ANIb_similarity_errors': ('afmhot', df.values.min(),
                                       df.values.max()),
            'ANIm_alignment_lengths': ('afmhot', df.values.min(),
                                       df.values.max()),
            'ANIm_percentage_identity': ('spbnd_BuRd', 0, 1),
            'ANIm_alignment_coverage': ('BuRd', 0, 1),
            'ANIm_hadamard': ('hadamard_BuRd', 0, 1),
            'ANIm_similarity_errors': ('afmhot', df.values.min(),
                                       df.values.max()),
            'TETRA_correlations': ('spbnd_BuRd', 0, 1),
            'ANIblastall_alignment_lengths': ('afmhot', df.values.min(),
                                              df.values.max()),
            'ANIblastall_percentage_identity': ('spbnd_BuRd', 0, 1),
            'ANIblastall_alignment_coverage': ('BuRd', 0, 1),
            'ANIblastall_hadamard': ('hadamard_BuRd', 0, 1),
            'ANIblastall_similarity_errors': ('afmhot', df.values.min(),
                                              df.values.max())}
931781
def problem_glob(extension='.py'):
    """"""
    filenames = glob.glob('*[0-9][0-9][0-9]*{}'.format(extension))
    return [ProblemFile(file) for file in filenames]
1103562
def pad_for_tpu(shapes_dict, hparams, max_length):
  """"""
  padded_shapes = {}

  def get_filler(specified_max_length):
    if not specified_max_length:
      return max_length
    return min(specified_max_length, max_length)

  inputs_none_filler = get_filler(hparams.max_input_seq_length)
  targets_none_filler = get_filler(hparams.max_target_seq_length)

  def pad_one_shape(shape, none_filler):
    return [
        (dim if dim is not None else none_filler) for dim in shape.as_list()
    ]

  for key, shape in six.iteritems(shapes_dict):
    if key == "inputs":
      padded_shapes[key] = pad_one_shape(shape, inputs_none_filler)
    elif key == "targets":
      padded_shapes[key] = pad_one_shape(shape, targets_none_filler)
    else:
      padded_shapes[key] = pad_one_shape(shape, max_length)
  return padded_shapes
47709
def optimise_xy(xy, *args):
    """"""
    z, elements, coordinates = args
    window_com = np.array([xy[0], xy[1], z])
    return -pore_diameter(elements, coordinates, com=window_com)[0]
5685
def check(self, feature):
        """"""
        mapper = feature.as_dataframe_mapper()
        mapper.fit(self.X, y=self.y)
247445
def cv_error(self, cv=True, skip_endpoints=True):
        """"""
        resids = self.cv_residuals(cv)
        if skip_endpoints:
            resids = resids[1:-1]
        return np.mean(abs(resids))
155708
def check(self, feature):
        """"""
        mapper = feature.as_dataframe_mapper()
        X = mapper.fit_transform(self.X, y=self.y)
        assert not np.any(np.isnan(X))