Derived Features
8963
function() {
        if (!this._eAllSuperTypes) {
            var compute = function(eClass) {
                var superTypes = eClass.get('eSuperTypes').array(),
                    eAllSuperTypes = _.flatten(_.map(superTypes, function(s) {
                        return s.get('eAllSuperTypes');
                    }));

                return _.union(eAllSuperTypes, superTypes);
            };

            this.on('add:eSuperTypes remove:eSuperTypes', function() {
                this._eAllSuperTypes = compute(this);
            }, this);

            this._eAllSuperTypes = compute(this);
        }

        return this._eAllSuperTypes;
    }
1321957
function(){
    var feature = this.supportsFeature()
      , op
      , expr;
    if (feature) {
      expr = new nodes.Expression;
      expr.push(feature);
      while (op = this.accept('&&') || this.accept('||')) {
        expr.push(new nodes.Literal('&&' == op.val ? 'and' : 'or'));
        expr.push(this.supportsFeature());
      }
      return expr;
    }
  }
648163
function _deriveComponent(def, basic) {
        var derived = _shallowCopy(basic);

        if (def.hasOwnProperty("folder")) {
            if (derived.hasOwnProperty("folder")) {
                var folder = def.folder.concat(basic.folder);
                derived.folder = folder;
            } else {
                derived.folder = def.folder;
            }
        }

        if (def.hasOwnProperty("suffix")) {
            var index = basic.file.lastIndexOf("."),
                filename = basic.file.substring(0, index),
                extension = basic.file.substring(index);

            derived.file = filename + def.suffix + extension;
        }

        if (def.hasOwnProperty("scale") ||
                def.hasOwnProperty("width") ||
                def.hasOwnProperty("height")) {
            if (!derived.hasOwnProperty("scale") &&
                    !derived.hasOwnProperty("width") &&
                    !derived.hasOwnProperty("height")) {

                if (def.hasOwnProperty("scale")) {
                    derived.scale = def.scale;
                }

                if (def.hasOwnProperty("width")) {
                    derived.width = def.width;
                }

                if (def.hasOwnProperty("height")) {
                    derived.height = def.height;
                }
            }
        }
        
        if (def.hasOwnProperty("canvasWidth") ||
                def.hasOwnProperty("canvasHeight") ||
                def.hasOwnProperty("canvasOffsetX") ||
                def.hasOwnProperty("canvasOffsetY")) {
            if (!derived.hasOwnProperty("canvasWidth") &&
                    !derived.hasOwnProperty("canvasHeight") &&
                    !derived.hasOwnProperty("canvasOffsetX") &&
                    !derived.hasOwnProperty("canvasOffsetY")) {

                if (def.hasOwnProperty("canvasWidth")) {
                    derived.canvasWidth = def.canvasWidth;
                }

                if (def.hasOwnProperty("canvasHeight")) {
                    derived.canvasHeight = def.canvasHeight;
                }

                if (def.hasOwnProperty("canvasOffsetX")) {
                    derived.canvasOffsetX = def.canvasOffsetX;
                }

                if (def.hasOwnProperty("canvasOffsetY")) {
                    derived.canvasOffsetY = def.canvasOffsetY;
                }
            }
        }


        if (def.hasOwnProperty("quality")) {
            if (!derived.hasOwnProperty("quality")) {
                derived.quality = def.quality;
            }
        }

        derived.id = def.id + ":" + basic.id;
        derived.assetPath = _getAssetPath(derived);
        derived.default = def;

        return derived;
    }
787683
def ndim(self):
        """"""
        if self.is_raster():
            return {
                FeatureType.DATA: 4,
                FeatureType.MASK: 4,
                FeatureType.SCALAR: 2,
                FeatureType.LABEL: 2,
                FeatureType.DATA_TIMELESS: 3,
                FeatureType.MASK_TIMELESS: 3,
                FeatureType.SCALAR_TIMELESS: 1,
                FeatureType.LABEL_TIMELESS: 1
            }[self]
        return None
566390
function(features) {
            if (!(features instanceof Array)) {
                features = [features];
            }
            var result = this.toTriangles().map(function(triPoly) {
                    return triPoly.getTetraFeatures(features);
                })
                .reduce(function(pv, v) {
                    return v.map(function(feat, i) {
                        return feat + (pv === 0 ? 0 : pv[i]);
                    });
                }, 0);
            return (result.length == 1) ? result[0] : result;
        }
757194
static void detectAdjacentAndPositionPatterns(int N, QrCodeCodeWordLocations matrix, FoundFeatures features) {

		for (int foo = 0; foo < 2; foo++) {
			for (int row = 0; row < N; row++) {
				int index = row * N;
				for (int col = 1; col < N; col++, index++) {
					if (matrix.data[index] == matrix.data[index + 1])
						features.adjacent++;
				}
				index = row * N;
				for (int col = 6; col < N; col++, index++) {
					if (matrix.data[index] && !matrix.data[index + 1] &&
							matrix.data[index + 2] && matrix.data[index + 3] && matrix.data[index + 4] &&
							!matrix.data[index + 5] && matrix.data[index + 6])
						features.position++;
				}
			}
			CommonOps_BDRM.transposeSquare(matrix);
		}

		// subtract out false positives by the mask applied to position patterns, timing, mode
		features.adjacent -= 8*9 + 2*9*8 + (N-18)*2;
	}
1171836
def recursive_derived(self):
        """"""
        if self._recursive_derived is None:
            to_go = self.derived[:]
            all_derived = []
            while to_go:
                derive = to_go.pop()
                if derive not in all_derived:
                    all_derived.append(derive)
                    to_go.extend(derive.related_class.derived)
            self._recursive_derived = all_derived
        return self._recursive_derived
457628
def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]:
        """"""
        if not identities:
            return set()
        res = self.derived_from(identities[0])
        for id in identities[1:]:
            res &= self.derived_from(id)
        return res
396381
def _get_features(self):
        """"""
        if self._satellite:
            return [("water", [], [])]
        elif self._zoom <= 2:
            return [
                ("water", [], []),
                ("marine_label", [], [1]),
            ]
        elif self._zoom <= 7:
            return [
                ("admin", [], []),
                ("water", [], []),
                ("road", ["motorway"], []),
                ("country_label", [], []),
                ("marine_label", [], [1]),
                ("state_label", [], []),
                ("place_label", [], ["city", "town"]),
            ]
        elif self._zoom <= 10:
            return [
                ("admin", [], []),
                ("water", [], []),
                ("road", ["motorway", "motorway_link", "trunk"], []),
                ("country_label", [], []),
                ("marine_label", [], [1]),
                ("state_label", [], []),
                ("place_label", [], ["city", "town"]),
            ]
        else:
            return [
                ("landuse", ["agriculture", "grass", "park"], []),
                ("water", [], []),
                ("waterway", ["river", "canal"], []),
                ("building", [], []),
                ("road",
                 ["motorway", "motorway_link", "trunk", "primary", "secondary"]
                 if self._zoom <= 14 else
                 ["motorway", "motorway_link", "trunk", "primary", "secondary", "tertiary",
                  "link", "street", "tunnel"],
                 []),
                ("poi_label", [], []),
            ]
936848
def variation(self,parents):
        """"""
        # downselect to features that are important
        if (self.valid(parents) and
            self.ml_type != 'SVC' and self.ml_type != 'SVR'):
            # this is needed because svm has a bug that throws valueerror on
            # attribute check
            if hasattr(self.pipeline.named_steps['ml'],'coef_'):
                # for l1 regularization, filter individuals with 0 coefficients
                if self.weight_parents:
                    weights = self.pipeline.named_steps['ml'].coef_
                    if len(weights.shape)>1: # handle multi-coefficient models
                        weights = [np.mean(abs(c)) for c in weights.transpose()]
                    # softmax transformation of the weights
                    weights = np.exp(weights)/np.sum(np.exp(weights))
                    offspring = copy.deepcopy(
                        list(self.random_state.choice(self.valid(parents),
                                              self.population_size, p=weights)))
                else:
                    offspring = copy.deepcopy(list(
                        x for i,x in zip(self.pipeline.named_steps['ml'].coef_,
                                         self.valid(parents)) if  (i != 0).any()))
            elif hasattr(self.pipeline.named_steps['ml'],'feature_importances_'):
                # for tree methods, filter our individuals with 0 feature importance
                if self.weight_parents:
                    weights = self.pipeline.named_steps['ml'].feature_importances_
                    # softmax transformation of the weights
                    weights = np.exp(weights)/np.sum(np.exp(weights))
                    offspring = copy.deepcopy(list(
                        self.random_state.choice(self.valid(parents),
                                         self.population_size, p=weights)))
                else:
                    offspring = copy.deepcopy(list(
                        x for i,x in zip(self.pipeline.named_steps['ml'].feature_importances_,
                                         self.valid(parents)) if  i != 0))
            else:
                offspring = copy.deepcopy(self.valid(parents))
        else:
            offspring = copy.deepcopy(self.valid(parents))

        if self.elitism: # keep a copy of the elite individual
            elite_index = np.argmin([x.fitness for x in parents])
            elite = copy.deepcopy(parents[elite_index])

        # Apply crossover and mutation on the offspring
        if self.verbosity > 2: print("variation...")
        for child1, child2 in it.zip_longest(offspring[::2], offspring[1::2],
                                             fillvalue=None):

            if self.random_state.rand() < self.crossover_rate and child2 != None:
            # crossover
                self.cross(child1.stack, child2.stack, self.max_depth)
                # update ids
                child1.parentid = [child1.id,child2.id]
                child1.id = uuid.uuid4()
                child2.parentid = [child1.id,child2.id]
                child2.id = uuid.uuid4()
                # set default fitness
                child1.fitness = -1
                child2.fitness = -1
            elif child2 == None:
            # single mutation
                self.mutate(child1.stack,self.func_set,self.term_set)
                # update ids
                child1.parentid = [child1.id]
                child1.id = uuid.uuid4()
                # set default fitness
                child1.fitness = -1
            else:
            #double mutation
                self.mutate(child1.stack,self.func_set,self.term_set)
                self.mutate(child2.stack,self.func_set,self.term_set)
                # update ids
                child1.parentid = [child1.id]
                child1.id = uuid.uuid4()
                child2.parentid = [child2.id]
                child2.id = uuid.uuid4()
                # set default fitness
                child1.fitness = -1
                child2.fitness = -1

        while len(offspring) < self.population_size:
            #make new offspring to replace the invalid ones
            offspring.append(Ind())
            self.make_program(offspring[-1].stack,self.func_set,self.term_set,
                              self.random_state.randint(self.min_depth,
                                                        self.max_depth+1),
                              self.otype)
            offspring[-1].stack = list(reversed(offspring[-1].stack))
        
        return offspring,elite,elite_index
734462
private Map<Feature, Feature> diffFeatures(List<Feature> pcm1Features, List<Feature> pcm2Features, PCMElementComparator comparator, DiffResult result) {
        List<Feature> commonFeatures = new ArrayList<Feature>();
        List<Feature> featuresOnlyInPCM1 = new ArrayList<Feature>();
        List<Feature> featuresOnlyInPCM2 = new ArrayList<Feature>(pcm2Features);

        Map<Feature, Feature> equivalentFeatures = new HashMap<Feature, Feature>();

        for (Feature f1 : pcm1Features) {
            boolean similarFeature = false;
            for (Feature f2 : pcm2Features) {
                similarFeature = comparator.similarFeature(f1, f2);
                if (similarFeature) {
                    commonFeatures.add(f1);
                    featuresOnlyInPCM2.remove(f2);
                    equivalentFeatures.put(f1, f2);
                    break;
                }
            }

            if (!similarFeature) {
                featuresOnlyInPCM1.add(f1);
            }
        }

        result.setCommonFeatures(commonFeatures);
        result.setFeaturesOnlyInPCM1(featuresOnlyInPCM1);
        result.setFeaturesOnlyInPCM2(featuresOnlyInPCM2);

        return equivalentFeatures;
    }
245638
def _feature_file(self, parallel = None, index = None):
    """"""
    if index is None:
      index = 0 if parallel is None or "SGE_TASK_ID" not in os.environ else int(os.environ["SGE_TASK_ID"])
    return os.path.join(self.feature_directory, "Features_%02d.hdf5" % index)
852388
function FeatureCollection(input){
    if(input && input.type === "FeatureCollection" && input.features){
      extend(this, input);
    } else if(isArray(input)) {
      this.features = input;
    } else {
      throw "Terraformer: invalid input for Terraformer.FeatureCollection";
    }

    this.type = "FeatureCollection";
  }
106075
def features(self):
        """"""
        mycols = []
        for col in dfn.feature_names:
            if col in self:
                mycols.append(col)
        mycols.sort()
        return mycols
882904
def getFeatureID(self, location):
    
    if not self.contains(location):
      return self.EMPTY_FEATURE

    return self.SPHERICAL_SURFACE
386828
void get_basic_features(final Context ctx,
                            final List<Integer> forms,
                            final List<Integer> postags,
                            final List<Integer> deprels,
                            List<Integer> features)
    {
        PUSH(features, FORM(forms, ctx.S0));
        PUSH(features, POSTAG(postags, ctx.S0));
        PUSH(features, FORM(forms, ctx.S1));
        PUSH(features, POSTAG(postags, ctx.S1));
        PUSH(features, FORM(forms, ctx.S2));
        PUSH(features, POSTAG(postags, ctx.S2));
        PUSH(features, FORM(forms, ctx.N0));
        PUSH(features, POSTAG(postags, ctx.N0));
        PUSH(features, FORM(forms, ctx.N1));
        PUSH(features, POSTAG(postags, ctx.N1));
        PUSH(features, FORM(forms, ctx.N2));
        PUSH(features, POSTAG(postags, ctx.N2));
        PUSH(features, FORM(forms, ctx.S0L));
        PUSH(features, POSTAG(postags, ctx.S0L));
        PUSH(features, DEPREL(deprels, ctx.S0L));
        PUSH(features, FORM(forms, ctx.S0R));
        PUSH(features, POSTAG(postags, ctx.S0R));
        PUSH(features, DEPREL(deprels, ctx.S0R));
        PUSH(features, FORM(forms, ctx.S0L2));
        PUSH(features, POSTAG(postags, ctx.S0L2));
        PUSH(features, DEPREL(deprels, ctx.S0L2));
        PUSH(features, FORM(forms, ctx.S0R2));
        PUSH(features, POSTAG(postags, ctx.S0R2));
        PUSH(features, DEPREL(deprels, ctx.S0R2));
        PUSH(features, FORM(forms, ctx.S0LL));
        PUSH(features, POSTAG(postags, ctx.S0LL));
        PUSH(features, DEPREL(deprels, ctx.S0LL));
        PUSH(features, FORM(forms, ctx.S0RR));
        PUSH(features, POSTAG(postags, ctx.S0RR));
        PUSH(features, DEPREL(deprels, ctx.S0RR));
        PUSH(features, FORM(forms, ctx.S1L));
        PUSH(features, POSTAG(postags, ctx.S1L));
        PUSH(features, DEPREL(deprels, ctx.S1L));
        PUSH(features, FORM(forms, ctx.S1R));
        PUSH(features, POSTAG(postags, ctx.S1R));
        PUSH(features, DEPREL(deprels, ctx.S1R));
        PUSH(features, FORM(forms, ctx.S1L2));
        PUSH(features, POSTAG(postags, ctx.S1L2));
        PUSH(features, DEPREL(deprels, ctx.S1L2));
        PUSH(features, FORM(forms, ctx.S1R2));
        PUSH(features, POSTAG(postags, ctx.S1R2));
        PUSH(features, DEPREL(deprels, ctx.S1R2));
        PUSH(features, FORM(forms, ctx.S1LL));
        PUSH(features, POSTAG(postags, ctx.S1LL));
        PUSH(features, DEPREL(deprels, ctx.S1LL));
        PUSH(features, FORM(forms, ctx.S1RR));
        PUSH(features, POSTAG(postags, ctx.S1RR));
        PUSH(features, DEPREL(deprels, ctx.S1RR));
    }
98862
function(features) {
        var feature;
        if (features.constructor == Array)
            feature = features[0];
        else
            feature = features;

        var geometry = feature.geometry;
        var type = geometry.CLASS_NAME.split('.')[2].toLowerCase();

        var pointGeometries;
        if (type == "point")
            pointGeometries = new Array(geometry);
        else if (type == "linestring" ||
                 type == "linearring" ||
                 type == "multipoint")
            pointGeometries = geometry.components;
        else if (type == "polygon")
            pointGeometries = geometry.components[0].components;
        else
            return null;

        var flatPoints = [];

        var pointGeometriesLength = pointGeometries.length;
        for (var i = 0; i < pointGeometriesLength; ++i) {
            var pointGeometry = pointGeometries[i];
            flatPoints.push(pointGeometry.y);
            flatPoints.push(pointGeometry.x);
        }

        return this.encodeDeltas(flatPoints, 2);
    }