If there are class-equivalent arcs check all formula filters to see if they need to be updated
558716
public function fixupFormulas()
	{
		// Find the class-equivalentClass arc role(s)
		$taxonomies = $this->context->getTaxonomiesWithArcRoleTypeId('class-equivalentClass');
		$arcRoles = array_map( function( /** @var XBRL $taxonomy */ $taxonomy )
		{
			$arcRole = $taxonomy->getArcRoleTypeForId( 'class-equivalentClass' );
			if ( ! $arcRole ) return '';
			return str_replace( 'link:definitionArc/', '', $arcRole );
		}, $taxonomies  );

		if ( ! $arcRoles ) return;

		$nonDimensionalRoleRef = $this->getNonDimensionalRoleRefs();
		$classEquivalents = null;
		foreach ( $arcRoles as $arcRole )
		{
			if ( ! isset( $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ] ) ) continue;
			$classEquivalents = $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ];
			break;
		}

		if ( ! $classEquivalents ) return;

		foreach ( $this->getImportedSchemas() as $label => $taxonomy )
		{
			if ( ! $taxonomy->getHasFormulas() ) continue;

			$resources = $taxonomy->getGenericResource('filter', 'conceptName' );
			if ( ! $resources ) continue;

			$baseTaxonomy = null; // $this->getBaseTaxonomy() ? $this->getTaxonomyForXSD( $this->getBaseTaxonomy() ) : null;

			foreach ( $classEquivalents['arcs'] as $fac => $gaaps )
			{
				$facTaxonomy = $this->getTaxonomyForXSD( $fac );
				if ( ! $facTaxonomy ) continue;

				$facElement = $facTaxonomy->getElementById( $fac );
				if ( ! $facElement ) continue;

				$facClark = "{{$facTaxonomy->getNamespace()}}{$facElement['name']}";

				foreach ( $resources as $resource )
				{
					$changed = false;

					foreach ( $resource['filter']['qnames'] as $qnIndex => $qname )
					{
						if ( $qname != $facClark ) continue;

						foreach ( $gaaps as $gaapLabel => $gaap )
						{
							$gaapTaxonomy = $this->getTaxonomyForXSD( $gaapLabel );
							if ( ! $gaapTaxonomy ) continue;

							$gaapElement = $gaapTaxonomy->getElementById( $gaapLabel );
							if ( ! $gaapElement ) continue;

							// $gaapClark = "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}";
							$gaapClark = $baseTaxonomy
								? "{{$baseTaxonomy->getNamespace()}}{$gaapElement['name']}"
								: "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}";

							echo "{$resource['linkbase']} - {$resource['resourceName']}: from $facClark to $gaapClark\n";

							//$taxonomy->genericRoles['roles']
							//		[ $resource['roleUri'] ]
							//		['resources']
							//		[ $resource['linkbase'] ]
							//		[ $resource['resourceName'] ]
							//		[ $resource['index'] ]['qnames'][ $qnIndex ] = $gaapClark;
							if ( $resource['filter']['qnames'][ $qnIndex ] == $facClark )
							{
								$resource['filter']['qnames'][ $qnIndex ] = $gaapClark;
							}
							else
							{
								$resource['filter']['qnames'][] = $gaapClark;
							}
							$changed = true;
						}
					}

					if ( $changed )
					{
						$taxonomy->updateGenericResource( $resource['roleUri'], $resource['linkbase'], $resource['resourceName'], $resource['index'], $resource['filter'] );
					}
				}
			}
		}
	}
280105
def check(self, values, namespace):
        """"""
        is_tuplish_type = (issubclass(self._cls, tg.Tuple) or
                           issubclass(type(values), self._cls))
        if (not _is_sequence(values) or not is_tuplish_type or
                len(values) != len(self._checks)):
            return False
        for thischeck, thisvalue in zip(self._checks, values):
            if not thischeck(thisvalue, namespace):
                return False
        return True
1172973
def compare(self,
                query_classes: List,
                reference_classes: List,
                method: Optional) -> SimResult:
        
        raise NotImplementedError
323267
function applyTransformationsGroup( filter, element, group ) {
		var i, rule;

		for ( i = 0; i < group.length; ++i ) {
			rule = group[ i ];

			// Test with #check or #left only if it's set.
			// Do not apply transformations because that creates infinite loop.
			if ( ( !rule.check || filter.check( rule.check, false ) ) &&
				( !rule.left || rule.left( element ) ) ) {
				rule.right( element, transformationsTools );
				return; // Only first matching rule in a group is executed.
			}
		}
	}
763632
function checkSimpleExpression(range, version) {
  range = range.trim();
  if (range === '') {
    return true;
  }

  const versionComponents = version.split(componentRegex);
  const {modifier, rangeComponents} = getModifierAndComponents(range);
  switch (modifier) {
    case '<':
      return checkLessThan(versionComponents, rangeComponents);
    case '<=':
      return checkLessThanOrEqual(versionComponents, rangeComponents);
    case '>=':
      return checkGreaterThanOrEqual(versionComponents, rangeComponents);
    case '>':
      return checkGreaterThan(versionComponents, rangeComponents);
    case '~':
    case '~>':
      return checkApproximateVersion(versionComponents, rangeComponents);
    default:
      return checkEqual(versionComponents, rangeComponents);
  }
}
865587
function addMorphTargets( geometry, targets, accessors ) {

		var hasMorphPosition = false;
		var hasMorphNormal = false;

		for ( var i = 0, il = targets.length; i < il; i ++ ) {

			var target = targets[ i ];

			if ( target.POSITION !== undefined ) hasMorphPosition = true;
			if ( target.NORMAL !== undefined ) hasMorphNormal = true;

			if ( hasMorphPosition && hasMorphNormal ) break;

		}

		if ( ! hasMorphPosition && ! hasMorphNormal ) return;

		var morphPositions = [];
		var morphNormals = [];

		for ( var i = 0, il = targets.length; i < il; i ++ ) {

			var target = targets[ i ];
			var attributeName = 'morphTarget' + i;

			if ( hasMorphPosition ) {

				// Three.js morph position is absolute value. The formula is
				//   basePosition
				//     + weight0 * ( morphPosition0 - basePosition )
				//     + weight1 * ( morphPosition1 - basePosition )
				//     ...
				// while the glTF one is relative
				//   basePosition
				//     + weight0 * glTFmorphPosition0
				//     + weight1 * glTFmorphPosition1
				//     ...
				// then we need to convert from relative to absolute here.

				if ( target.POSITION !== undefined ) {

					// Cloning not to pollute original accessor
					var positionAttribute = cloneBufferAttribute( accessors[ target.POSITION ] );
					positionAttribute.name = attributeName;

					var position = geometry.attributes.position;

					for ( var j = 0, jl = positionAttribute.count; j < jl; j ++ ) {

						positionAttribute.setXYZ(
							j,
							positionAttribute.getX( j ) + position.getX( j ),
							positionAttribute.getY( j ) + position.getY( j ),
							positionAttribute.getZ( j ) + position.getZ( j )
						);

					}

				} else {

					positionAttribute = geometry.attributes.position;

				}

				morphPositions.push( positionAttribute );

			}

			if ( hasMorphNormal ) {

				// see target.POSITION's comment

				var normalAttribute;

				if ( target.NORMAL !== undefined ) {

					var normalAttribute = cloneBufferAttribute( accessors[ target.NORMAL ] );
					normalAttribute.name = attributeName;

					var normal = geometry.attributes.normal;

					for ( var j = 0, jl = normalAttribute.count; j < jl; j ++ ) {

						normalAttribute.setXYZ(
							j,
							normalAttribute.getX( j ) + normal.getX( j ),
							normalAttribute.getY( j ) + normal.getY( j ),
							normalAttribute.getZ( j ) + normal.getZ( j )
						);

					}

				} else {

					normalAttribute = geometry.attributes.normal;

				}

				morphNormals.push( normalAttribute );

			}

		}

		if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
		if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;

	}
1249145
private void decideTypeFilterToAdd(Filter filter) {
        Filter step = filter;

        if (Operator.MATCH == step.getRelation().getOperator() ||
                step.getRelation().getRightTerm() instanceof FunctionSelector) {
            if (matchList.isEmpty()) {
                matchList = new ArrayList<>();
            }
            matchList.add(filter);
        } else {
            if (filterList.isEmpty()) {
                filterList = new ArrayList<>();
            }
            filterList.add(filter);
        }
    }
427594
def _check_classes(self):
        
        try:
            self.classes = self.imdbs[0].classes
            self.num_classes = len(self.classes)
        except AttributeError:
            # fine, if no classes is provided
            pass

        if self.num_classes > 0:
            for db in self.imdbs:
                assert self.classes == db.classes, "Multiple imdb must have same classes"
1312896
def add_invariant_checks(cls: type) -> None:
    """"""
    # Candidates for the decoration as list of (name, dir() value)
    init_name_func = None  # type: Optional[Tuple[str, Callable[..., None]]]
    names_funcs = []  # type: List[Tuple[str, Callable[..., None]]]
    names_properties = []  # type: List[Tuple[str, property]]

    # Filter out entries in the directory which are certainly not candidates for decoration.
    for name, value in [(name, getattr(cls, name)) for name in dir(cls)]:
        # We need to ignore __repr__ to prevent endless loops when generating error messages.
        # __getattribute__, __setattr__ and __delattr__ are too invasive and alter the state of the instance.
        # Hence we don't consider them "public".
        if name in ["__repr__", "__getattribute__", "__setattr__", "__delattr__"]:
            continue

        if name == "__init__":
            assert inspect.isfunction(value) or isinstance(value, _SLOT_WRAPPER_TYPE), \
                "Expected __init__ to be either a function or a slot wrapper, but got: {}".format(type(value))

            init_name_func = (name, value)
            continue

        if not inspect.isfunction(value) and not isinstance(value, _SLOT_WRAPPER_TYPE) and \
                not isinstance(value, property):
            continue

        # Ignore class methods
        if getattr(value, "__self__", None) is cls:
            continue

        # Ignore "protected"/"private" methods
        if name.startswith("_") and not (name.startswith("__") and name.endswith("__")):
            continue

        if inspect.isfunction(value) or isinstance(value, _SLOT_WRAPPER_TYPE):
            names_funcs.append((name, value))

        elif isinstance(value, property):
            names_properties.append((name, value))

        else:
            raise NotImplementedError("Unhandled directory entry of class {} for {}: {}".format(cls, name, value))

    if init_name_func:
        name, func = init_name_func
        wrapper = _decorate_with_invariants(func=func, is_init=True)
        setattr(cls, name, wrapper)

    for name, func in names_funcs:
        wrapper = _decorate_with_invariants(func=func, is_init=False)
        setattr(cls, name, wrapper)

    for name, prop in names_properties:
        new_prop = property(  # type: ignore
            fget=_decorate_with_invariants(func=prop.fget, is_init=False) if prop.fget else None,
            fset=_decorate_with_invariants(func=prop.fset, is_init=False) if prop.fset else None,
            fdel=_decorate_with_invariants(func=prop.fdel, is_init=False) if prop.fdel else None,
            doc=prop.__doc__)
        setattr(cls, name, new_prop)
573649
def matches(self, client, event_data):
        """"""

        for f in self.filters:
            if not f(client, event_data):
                return False

        return True
390061
def method_missing(method, *args, &block)
      
      attribute = ActiveSupport::Inflector.camelize(method.to_s, false)
  
      if attribute =~ /=$/
        attribute = attribute.chop
        return super unless self.attributes.include?(attribute)
        self.changed_attributes[attribute] = args[0]
        self.attributes[attribute] = args[0]
      else
        return super unless self.attributes.include?(attribute)
        self.attributes[attribute]
      end 
            
    end
357268
def update_filter(self):
        
        # Consider the filter invalid
        self.valid_filter = False

        try:
            # Format the new filter
            filter_str = self._original_filter.format(
                **self._component_context.properties
            )
        except KeyError as ex:
            # An entry is missing: abandon
            logging.warning("Missing filter value: %s", ex)
            raise ValueError("Missing filter value")

        try:
            # Parse the new LDAP filter
            new_filter = ldapfilter.get_ldap_filter(filter_str)
        except (TypeError, ValueError) as ex:
            logging.warning("Error parsing filter: %s", ex)
            raise ValueError("Error parsing filter")

        # The filter is valid
        self.valid_filter = True

        # Compare to the "old" one
        if new_filter != self.requirement.filter:
            # Replace the requirement filter
            self.requirement.filter = new_filter
            return True

        # Same filter
        return False
1140586
def find_filter_class(filtername):
    """"""
    if filtername in FILTERS:
        return FILTERS[filtername]
    for name, cls in find_plugin_filters():
        if name == filtername:
            return cls
    return None
153425
def are_equal(self, d1, d2):
        
        possible_defect_types = (Defect, Vacancy, Substitution, Interstitial)

        if not isinstance(d1, possible_defect_types) or \
            not isinstance(d2, possible_defect_types):
            raise ValueError("Cannot use PointDefectComparator to" + \
                             " compare non-defect objects...")

        if not isinstance(d1, d2.__class__):
            return False
        elif d1.site.specie != d2.site.specie:
            return False
        elif self.check_charge and (d1.charge != d2.charge):
            return False

        sm = StructureMatcher( ltol=0.01,
                               primitive_cell=self.check_primitive_cell,
                               scale=self.check_lattice_scale)

        if not sm.fit(d1.bulk_structure, d2.bulk_structure):
            return False

        d1 = d1.copy()
        d2 = d2.copy()
        if self.check_primitive_cell or self.check_lattice_scale:
            # if allowing for base structure volume or supercell modifications,
            # then need to preprocess defect objects to allow for matching
            d1_mod_bulk_structure, d2_mod_bulk_structure, _, _ = sm._preprocess(
                d1.bulk_structure, d2.bulk_structure)
            d1_defect_site = PeriodicSite(d1.site.specie, d1.site.coords,
                                          d1_mod_bulk_structure.lattice,
                                          to_unit_cell=True,
                                          coords_are_cartesian=True)
            d2_defect_site = PeriodicSite( d2.site.specie, d2.site.coords,
                                           d2_mod_bulk_structure.lattice,
                                           to_unit_cell=True,
                                           coords_are_cartesian=True)

            d1._structure = d1_mod_bulk_structure
            d2._structure = d2_mod_bulk_structure
            d1._defect_site = d1_defect_site
            d2._defect_site = d2_defect_site

        return sm.fit(d1.generate_defect_structure(),
                      d2.generate_defect_structure())
723874
function isAttrDifferent (newAttrs, oldAttrs, attributeName) {
  let oldValue = _.get(oldAttrs, attributeName + '.value')
  let newValue = _.get(newAttrs, attributeName + '.value')

  if (newValue !== undefined && !_.isEqual(oldValue, newValue)) {
    return true
  }
  return false
}
937241
def should_compile_incrementally(self, vts, ctx):
    
    if not vts.is_incremental:
      return False
    if not self._clear_invalid_analysis:
      return True
    return os.path.exists(ctx.analysis_file)
380710
def _check_data(self):
        """"""
        if self.axes is None:
            raise PolygonFilterError("`axes` parm not set.")
        if self.points is None:
            raise PolygonFilterError("`points` parm not set.")
        self.points = np.array(self.points)
        if self.points.shape[1] != 2:
            raise PolygonFilterError("data points' shape[1] must be 2.")
        if self.name is None:
            self.name = "polygon filter {}".format(self.unique_id)
        if not isinstance(self.inverted, bool):
            raise PolygonFilterError("`inverted` must be boolean.")