valid the topology
500139
def is_topology(self, layers=None):
        '''
        
        '''
        if layers is None:
            layers = self.layers
        layers_nodle = []
        result = []
        for i, layer in enumerate(layers):
            if layer.is_delete is False:
                layers_nodle.append(i)
        while True:
            flag_break = True
            layers_toremove = []
            for layer1 in layers_nodle:
                flag_arrive = True
                for layer2 in layers[layer1].input:
                    if layer2 in layers_nodle:
                        flag_arrive = False
                if flag_arrive is True:
                    for layer2 in layers[layer1].output:
                        # Size is error
                        if layers[layer2].set_size(layer1, layers[layer1].size) is False:
                            return False
                    layers_toremove.append(layer1)
                    result.append(layer1)
                    flag_break = False
            for layer in layers_toremove:
                layers_nodle.remove(layer)
            result.append('|')
            if flag_break:
                break
        # There is loop in graph || some layers can't to arrive
        if layers_nodle:
            return False
        return result
1355984
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Dictionary, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
        if value is None:
            return True
        if self.key_prop or self.value_prop:
            for key, val in iteritems(value):
                if self.key_prop:
                    self.key_prop.assert_valid(instance, key)
                if self.value_prop:
                    self.value_prop.assert_valid(instance, val)
        return True
665843
public static String topologyIdToName(String topologyId) throws InvalidTopologyException {
        String ret;
        int index = topologyId.lastIndexOf('-');
        if (index != -1 && index > 2) {
            index = topologyId.lastIndexOf('-', index - 1);
            if (index != -1 && index > 0)
                ret = topologyId.substring(0, index);
            else
                throw new InvalidTopologyException(topologyId + " is not a valid topologyId");
        } else
            throw new InvalidTopologyException(topologyId + " is not a valid topologyId");
        return ret;
    }
1158528
def is_valid(self):
        ''''''
        return (self.is_primitive and self.name) \
            or (self.is_complex and self.name) \
            or (self.is_list and self.nested) \
            or (self.is_map and self.nested) \
            or (self.is_model and self.nested)
857768
def valid(cls, data, context=None):
        """"""
        return cls(cls.TagType.VALID, data, context)
600928
def generate_topology(non_omm_topology, non_element_types=None,
        residues=None):
    """"""
    if non_element_types is None:
        non_element_types = set()

    if isinstance(non_omm_topology, pmd.Structure):
        return _topology_from_parmed(non_omm_topology, non_element_types)
    elif has_mbuild:
        mb = import_('mbuild')
        if (non_omm_topology, mb.Compound):
            pmdCompoundStructure = non_omm_topology.to_parmed(residues=residues)
            return _topology_from_parmed(pmdCompoundStructure, non_element_types)
    else:
        raise FoyerError('Unknown topology format: {}\n'
                         'Supported formats are: '
                         '"parmed.Structure", '
                         '"mbuild.Compound", '
                         '"openmm.app.Topology"'.format(non_omm_topology))
628731
def _validate_slices_form_uniform_grid(slice_datasets):
    '''
    
    '''
    invariant_properties = [
        'Modality',
        'SOPClassUID',
        'SeriesInstanceUID',
        'Rows',
        'Columns',
        'PixelSpacing',
        'PixelRepresentation',
        'BitsAllocated',
        'BitsStored',
        'HighBit',
    ]

    for property_name in invariant_properties:
        _slice_attribute_equal(slice_datasets, property_name)

    _validate_image_orientation(slice_datasets[0].ImageOrientationPatient)
    _slice_ndarray_attribute_almost_equal(slice_datasets, 'ImageOrientationPatient', 1e-5)

    slice_positions = _slice_positions(slice_datasets)
    _check_for_missing_slices(slice_positions)
429361
def valid?
      begin
        self.each do |threshold|
          if threshold.respond_to?(:valid?)
            return false unless threshold.valid?
          else
            raise InvalidThresholdsObject, "Container object has unknown objects"
          end
        end
        return true
      rescue InvalidThresholdsObject
        return false
      end
    end
973371
def is_valid_input_meshgrid(x, ndim):
    """"""
    # This case is triggered in FunctionSpaceElement.__call__ if the
    # domain does not have an 'ndim' attribute. We return False and
    # continue.
    if ndim is None:
        return False

    if not isinstance(x, tuple):
        return False

    if ndim > 1:
        try:
            np.broadcast(*x)
        except (ValueError, TypeError):  # cannot be broadcast
            return False

    return (len(x) == ndim and
            all(isinstance(xi, np.ndarray) for xi in x) and
            all(xi.ndim == ndim for xi in x))
838367
def verify(self):
        '''
        
        '''
        # Verify size of arcs list
        if (len(self.arcs) < 2):
            raise VennRegionException("At least two arcs needed in a poly-arc region")
        if (len(self.arcs) > 4):
            raise VennRegionException("At most 4 arcs are supported currently for poly-arc regions")
        
        TRIG_TOL = 100*tol  # We need to use looser tolerance level here because conversion to angles and back is prone to large errors.
        # Verify connectedness of arcs
        for i in range(len(self.arcs)):
            if not np.all(self.arcs[i-1].end_point() - self.arcs[i].start_point() < TRIG_TOL):
                raise VennRegionException("Arcs of an poly-arc-gon must be connected via endpoints")
        
        # Verify that arcs do not cross-intersect except at endpoints
        for i in range(len(self.arcs)-1):
            for j in range(i+1, len(self.arcs)):
                ips = self.arcs[i].intersect_arc(self.arcs[j])
                for ip in ips:
                    if not (np.all(abs(ip - self.arcs[i].start_point()) < TRIG_TOL) or np.all(abs(ip - self.arcs[i].end_point()) < TRIG_TOL)):
                        raise VennRegionException("Arcs of a poly-arc-gon may only intersect at endpoints")
                
                if len(ips) != 0 and (i - j) % len(self.arcs) > 1 and (j - i) % len(self.arcs) > 1:
                    # Two non-consecutive arcs intersect. This is in general not good, but
                    # may occasionally happen when all arcs inbetween have length 0.
                    pass # raise VennRegionException("Non-consecutive arcs of a poly-arc-gon may not intersect")
        
        # Verify that vertices are ordered so that at each point the direction along the polyarc changes towards the left.
        # Note that this test only makes sense for polyarcs obtained using circle intersections & subtractions.
        # A "flower-like" polyarc may have its vertices ordered counter-clockwise yet the direction would turn to the right at each of them.
        for i in range(len(self.arcs)):
            prev_arc = self.arcs[i-1]
            cur_arc = self.arcs[i]
            if box_product(prev_arc.direction_vector(prev_arc.to_angle), cur_arc.direction_vector(cur_arc.from_angle)) < -tol:
                raise VennRegionException("Arcs must be ordered so that the direction at each vertex changes counter-clockwise")
764273
def surface_is_valid1(surface):
    """"""
    if NO_IMAGES:
        return

    ax = surface.plot(256)
    ax.axis("scaled")
    ax.set_xlim(-0.125, 2.125)
    ax.set_ylim(-0.125, 2.125)
    save_image(ax.figure, "surface_is_valid1.png")
965073
public Boolean setTopology(TopologyAPI.Topology topology, String topologyName) {
    return awaitResult(delegate.setTopology(topology, topologyName));
  }
889954
def valid_index(index, shape) -> tuple:
    
    # append slices to index
    index = list(index)
    while len(index) < len(shape):
        index.append(slice(None))
    # fill out, in reverse
    out = []
    for i, s in zip(index[::-1], shape[::-1]):
        if s == 1:
            if isinstance(i, slice):
                out.append(slice(None))
            else:
                out.append(0)
        else:
            out.append(i)
    return tuple(out[::-1])
749884
public function valid()
	{
		// Check the current position.
		if (!is_scalar($this->current) || !isset($this->objects[$this->current]))
		{
			return false;
		}

		return true;
	}
877600
def _loop_topo(self, topologyType, topologicalEntity=None, topologyTypeToAvoid=None):
        '''
        
        '''
        topoTypes = {TopAbs_VERTEX: TopoDS_Vertex,
                     TopAbs_EDGE: TopoDS_Edge,
                     TopAbs_FACE: TopoDS_Face,
                     TopAbs_WIRE: TopoDS_Wire,
                     TopAbs_SHELL: TopoDS_Shell,
                     TopAbs_SOLID: TopoDS_Solid,
                     TopAbs_COMPOUND: TopoDS_Compound,
                     TopAbs_COMPSOLID: TopoDS_CompSolid}

        assert topologyType in topoTypes.keys(), '%s not one of %s' % (topologyType, topoTypes.keys())
        self.topExp = TopExp_Explorer()
        # use self.myShape if nothing is specified
        if topologicalEntity is None and topologyTypeToAvoid is None:
            self.topExp.Init(self.myShape, topologyType)
        elif topologicalEntity is None and topologyTypeToAvoid is not None:
            self.topExp.Init(self.myShape, topologyType, topologyTypeToAvoid)
        elif topologyTypeToAvoid is None:
            self.topExp.Init(topologicalEntity, topologyType)
        elif topologyTypeToAvoid:
            self.topExp.Init(topologicalEntity,
                             topologyType,
                             topologyTypeToAvoid)
        seq = []
        hashes = []  # list that stores hashes to avoid redundancy
        occ_seq = TopTools_ListOfShape()
        while self.topExp.More():
            current_item = self.topExp.Current()
            current_item_hash = current_item.__hash__()

            if not current_item_hash in hashes:
                hashes.append(current_item_hash)
                occ_seq.Append(current_item)

            self.topExp.Next()
        # Convert occ_seq to python list
        occ_iterator = TopTools_ListIteratorOfListOfShape(occ_seq)
        while occ_iterator.More():
            topo_to_add = self.topoFactory[topologyType](occ_iterator.Value())
            seq.append(topo_to_add)
            occ_iterator.Next()

        if self.ignore_orientation:
            # filter out those entities that share the same TShape
            # but do *not* share the same orientation
            filter_orientation_seq = []
            for i in seq:
                _present = False
                for j in filter_orientation_seq:
                    if i.IsSame(j):
                        _present = True
                        break
                if _present is False:
                    filter_orientation_seq.append(i)
            return filter_orientation_seq
        else:
            return iter(seq)
503389
function validateDeep(map) {
  if (!(map instanceof Map)) {
    throw new Error(`Invalid graph: Expected Map instead found ${typeof map}`);
  }

  map.forEach((value, key) => {
    if (typeof value === 'object' && value instanceof Map) {
      validateDeep(value);
      return;
    }

    if (typeof value !== 'number' || value <= 0) {
      throw new Error(`Values must be numbers greater than 0. Found value ${value} at ${key}`);
    }
  });
}
677286
def is_valid(cls, arg):
        """"""
        return isinstance(arg, (int, long)) and (not isinstance(arg, bool))