Check that the unit and dimension on a type attribute match.
        Alternatively, pass in a unit manually to check against the dimension
        of the type attribute
199918
def _check_dimension(typeattr, unit_id=None):
    
    if unit_id is None:
        unit_id = typeattr.unit_id

    dimension_id = _get_attr(typeattr.attr_id).dimension_id

    if unit_id is not None and dimension_id is None:
        # First error case
        unit_dimension_id = units.get_dimension_by_unit_id(unit_id).id
        raise HydraError("Unit %s (abbreviation=%s) has dimension_id %s(name=%s), but attribute has no dimension"%
                        (unit_id, units.get_unit(unit_id).abbreviation,
                        unit_dimension_id, units.get_dimension(unit_dimension_id, do_accept_dimension_id_none=True).name))
    elif unit_id is not None and dimension_id is not None:
        unit_dimension_id = units.get_dimension_by_unit_id(unit_id).id
        if unit_dimension_id != dimension_id:
            # Only error case
            raise HydraError("Unit %s (abbreviation=%s) has dimension_id %s(name=%s), but attribute has dimension_id %s(name=%s)"%
                            (unit_id, units.get_unit(unit_id).abbreviation,
                            unit_dimension_id, units.get_dimension(unit_dimension_id, do_accept_dimension_id_none=True).name,
                            dimension_id, units.get_dimension(dimension_id, do_accept_dimension_id_none=True).name))
1270090
def match(self, item):
        
        val = getattr(item, self._name) or False
        return bool(val) is self._value
1275593
def __checkAttributes(self):
        
        for a in self.__class__.required:
            if not self.attributes.has_key(a):
                raise SchemaError,\
                    'class instance %s, missing required attribute %s'\
                    %(self.__class__, a)
        for a,v in self.attributes.items():
            # attribute #other, ie. not in empty namespace
            if type(v) is dict:
                continue
            
            # predefined prefixes xmlns, xml
            if a in (XMLSchemaComponent.xmlns, XMLNS.XML):
                continue
            
            if (a not in self.__class__.attributes.keys()) and not\
                (self.isAttribute() and self.isReference()):
                raise SchemaError, '%s, unknown attribute(%s,%s)' \
                    %(self.getItemTrace(), a, self.attributes[a])
585604
function(type, value) {
    if (type !== 'attribute' && type !== 'text') {
      throw new TypeError('isBound must provide type "attribute" or "text"');
    }
    var expr = this.binders[type]._expr;
    return Boolean(expr && value && value.match(expr));
  }
268547
function checkDimension(i) {
  const ln = checkNumber(i);
  let li;

  if (i >= tokensLength ||
      !ln ||
      i + ln >= tokensLength) return 0;

  return (li = checkUnit(i + ln)) ? ln + li : 0;
}
475836
def unit_value(self, value):
        

        if isinstance(value, TimeUnit):
            self._unit = value
        else:
            self._unit = TimeUnit(value)
759565
def match_type(mtype, patterns):
    ''''''
    for p in patterns:
        if fnmatch.fnmatch(mtype, p):
            return True
    return False
719579
def match_attributes(self, el, attributes):
        """"""

        match = True
        if attributes:
            for a in attributes:
                value = self.match_attribute_name(el, a.attribute, a.prefix)
                pattern = a.xml_type_pattern if self.is_xml and a.xml_type_pattern else a.pattern
                if isinstance(value, list):
                    value = ' '.join(value)
                if value is None:
                    match = False
                    break
                elif pattern is None:
                    continue
                elif pattern.match(value) is None:
                    match = False
                    break
        return match
318743
def attr_match(cond)
      cond.each_pair { |k,v| return false unless v == @attributes[k.to_sym] || v == @attributes[k.to_s] }
      true
    end
216129
def checktype(self, elt, ps):
        '''
        '''
        typeName = _find_type(elt)
        if typeName is None or typeName == "":
            return (None,None)

        # Parse the QNAME.
        prefix,typeName = SplitQName(typeName)
        uri = ps.GetElementNSdict(elt).get(prefix)
        if uri is None:
            raise EvaluateException('Malformed type attribute (bad NS)',
                    ps.Backtrace(elt))

        #typeName = list[1]
        parselist,errorlist = self.get_parse_and_errorlist()
        if not parselist or \
        (uri,typeName) in parselist or \
        (_is_xsd_or_soap_ns(uri) and (None,typeName) in parselist):
            return (uri,typeName)
        raise EvaluateException(
                'Type mismatch (%s namespace) (got %s wanted %s)' % \
                (uri, typeName, errorlist), ps.Backtrace(elt))
112682
def check_var_units(self, ds):
        '''
        
        '''
        results = []
        for variable in self.get_applicable_variables(ds):
            msgs = []
            # Check units and dims for variable
            unit_check = hasattr(ds.variables[variable], 'units')
            no_dim_check = (getattr(ds.variables[variable], 'dimensions') == tuple())
            # Check if we have no dimensions.  If no dims, skip test
            if no_dim_check:
                continue
            # Check if we have no units
            if not unit_check:
                msgs.append("units")
            results.append(Result(BaseCheck.HIGH, unit_check, self._var_header.format(variable), msgs))

        return results
468185
def check_sizes(size, width, height):
    

    if not size:
        return width, height

    if len(size) != 2:
        raise ProtocolError(
            "size argument should be a pair (width, height)")
    if width is not None and width != size[0]:
        raise ProtocolError(
            "size[0] (%r) and width (%r) should match when both are used."
            % (size[0], width))
    if height is not None and height != size[1]:
        raise ProtocolError(
            "size[1] (%r) and height (%r) should match when both are used."
            % (size[1], height))
    return size
1345887
def _match_type(self, i):
        """"""
        self.col_match = self.RE_TYPE.match(self._source[i])
        if self.col_match is not None:
            self.section = "types"
            self.el_type = CustomType
            self.el_name = self.col_match.group("name")
           
            return True
        else:
            return False
875794
def matching_attributes?(attribute, filter)
      attribute.to_s.downcase == filter.to_s.delete('_').downcase
    end
934715
def get_dimension_by_unit_measure_or_abbreviation(measure_or_unit_abbreviation,**kwargs):
    

    unit_abbreviation, factor = _parse_unit(measure_or_unit_abbreviation)

    units = db.DBSession.query(Unit).filter(Unit.abbreviation==unit_abbreviation).all()

    if len(units) == 0:
        raise HydraError('Unit %s not found.'%(unit_abbreviation))
    elif len(units) > 1:
        raise HydraError('Unit %s has multiple dimensions not found.'%(unit_abbreviation))
    else:
        dimension = db.DBSession.query(Dimension).filter(Dimension.id==units[0].dimension_id).one()
        return str(dimension.name)
573126
def validate_enum_attribute(self, attribute: str,
                                candidates: Set[Union[str, int, float]]) -> None:
        
        self.add_errors(
            validate_enum_attribute(self.fully_qualified_name, self._spec, attribute, candidates))
60563
private void checkDimension(DiagnosticPosition pos, Type t) {
        switch (t.getTag()) {
        case METHOD:
            checkDimension(pos, t.getReturnType());
            for (List<Type> args = t.getParameterTypes(); args.nonEmpty(); args = args.tail)
                checkDimension(pos, args.head);
            break;
        case ARRAY:
            if (types.dimensions(t) > ClassFile.MAX_DIMENSIONS) {
                log.error(pos, "limit.dimensions");
                nerrs++;
            }
            break;
        default:
            break;
        }
    }