Check that the feature has a fit/transform/fit_tranform interface
967466
def check(self, feature):
        """"""
        assert hasattr(feature.transformer, 'fit')
        assert hasattr(feature.transformer, 'transform')
        assert hasattr(feature.transformer, 'fit_transform')
1139291
def hasFeature(self, prop, check_softs=False):
        """"""

        return prop in self.props or (check_softs and
                                      any([fs.hasFeature(prop) for fs in self.props.get(SoftFeatures.SOFT, [])]))
893186
def set_transform_interface_params(spec, input_features, output_features, are_optional = False):
    
    input_features = _fm.process_or_validate_features(input_features)
    output_features = _fm.process_or_validate_features(output_features)

    # Add input and output features
    for (fname, ftype) in input_features:
        input_ = spec.description.input.add()
        input_.name = fname
        datatypes._set_datatype(input_.type, ftype)
        if are_optional:
            input_.type.isOptional = are_optional

    for (fname, ftype) in output_features:
        output_ = spec.description.output.add()
        output_.name = fname
        datatypes._set_datatype(output_.type, ftype)

    return spec
87044
def is_transform_generator(fn):
    """"""
    try:
        if six.PY2:
            fn.func_dict['is_transform_generator'] = True
        else:
            # py3
            return fn.__dict__.get('is_transform_generator', False)
    except AttributeError:
        return False
20217
def checkForChanges(f, sde, isTable):
    
    # try simple feature count first
    fCount = int(arcpy.GetCount_management(f).getOutput(0))
    sdeCount = int(arcpy.GetCount_management(sde).getOutput(0))
    if fCount != sdeCount:
        return True

    fields = [fld.name for fld in arcpy.ListFields(f)]

    # filter out shape fields
    if not isTable:
        fields = filter_fields(fields)

        d = arcpy.Describe(f)
        shapeType = d.shapeType
        if shapeType == 'Polygon':
            shapeToken = 'SHAPE@AREA'
        elif shapeType == 'Polyline':
            shapeToken = 'SHAPE@LENGTH'
        elif shapeType == 'Point':
            shapeToken = 'SHAPE@XY'
        else:
            shapeToken = 'SHAPE@JSON'
        fields.append(shapeToken)

        def parseShape(shapeValue):
            if shapeValue is None:
                return 0
            elif shapeType in ['Polygon', 'Polyline']:
                return shapeValue
            elif shapeType == 'Point':
                if shapeValue[0] is not None and shapeValue[1] is not None:
                    return shapeValue[0] + shapeValue[1]
                else:
                    return 0
            else:
                return shapeValue

        outputSR = arcpy.Describe(f).spatialReference
    else:
        outputSR = None

    changed = False
    with arcpy.da.SearchCursor(f, fields, sql_clause=(None, 'ORDER BY OBJECTID')) as fCursor, \
            arcpy.da.SearchCursor(sde, fields, sql_clause=(None, 'ORDER BY OBJECTID'),
                                  spatial_reference=outputSR) as sdeCursor:
        for fRow, sdeRow in izip(fCursor, sdeCursor):
            if fRow != sdeRow:
                # check shapes first
                if fRow[-1] != sdeRow[-1] and not isTable:
                    if shapeType not in ['Polygon', 'Polyline', 'Point']:
                        changed = True
                        break
                    fShape = parseShape(fRow[-1])
                    sdeShape = parseShape(sdeRow[-1])
                    try:
                        assert_almost_equal(fShape, sdeShape, -1)
                        # trim off shapes
                        fRow = list(fRow[:-1])
                        sdeRow = list(sdeRow[:-1])
                    except AssertionError:
                        changed = True
                        break

                # trim microseconds since they can be off by one between file and sde databases
                for i in range(len(fRow)):
                    if type(fRow[i]) is datetime:
                        fRow = list(fRow)
                        sdeRow = list(sdeRow)
                        fRow[i] = fRow[i].replace(microsecond=0)
                        try:
                            sdeRow[i] = sdeRow[i].replace(microsecond=0)
                        except:
                            pass

                # compare all values except OBJECTID
                if fRow[1:] != sdeRow[1:]:
                    changed = True
                    break

    return changed
965022
def check(self, radl):
        """"""
        SIMPLE_FEATURES = {
            "name": (str, lambda x, _: bool(x.value)),
            "path": (str, lambda x, _: bool(x.value)),
            "version": (str, is_version),
            "preinstalled": (str, ["YES", "NO"])
        }
        self.check_simple(SIMPLE_FEATURES, radl)
1308287
def _validate(self):
        '''
        
        '''
        if self.f_labels is None:
            raise NotFittedError('FeatureRepMix')

        if not self.transformers:
            return

        names, transformers, _ = zip(*self.transformers)

        # validate names
        self._validate_names(names)

        # validate transformers
        for trans in transformers:
            if not isinstance(trans, FeatureRep):
                raise TypeError("All transformers must be an instance of FeatureRep."
                                " '%s' (type %s) doesn't." % (trans, type(trans)))
121488
def p_feature_simple(self, t):
        """"""

        if len(t) == 6:
            t[0] = Feature(t[1], t[2], t[4], line=t.lineno(1))
        elif len(t) == 5:
            t[0] = Feature(t[1], t[2], t[3], unit=t[4], line=t.lineno(1))
        elif len(t) == 4:
            t[0] = Feature(t[1], t[2], t[3], line=t.lineno(1))
166027
def is_defined(self, objtxt, force_import=False):
        """"""
        return self.interpreter.is_defined(objtxt, force_import)
1215300
boolean containFeature(Map<String, ProvisioningFeatureDefinition> installedFeatures, String feature) {
        if (installedFeatures.containsKey(feature))
            return true;
        for (ProvisioningFeatureDefinition pfd : installedFeatures.values()) {
            String shortName = InstallUtils.getShortName(pfd);
            if (shortName != null && shortName.equalsIgnoreCase(feature))
                return true;
        }
        return false;
    }
339764
def get (self, feature):
        
        if type(feature) == type([]):
            feature = feature[0]
        if not isinstance(feature, b2.build.feature.Feature):
            feature = b2.build.feature.get(feature)
        assert isinstance(feature, b2.build.feature.Feature)

        if self.feature_map_ is None:
            self.feature_map_ = {}

            for v in self.all_:
                if v.feature not in self.feature_map_:
                    self.feature_map_[v.feature] = []
                self.feature_map_[v.feature].append(v.value)

        return self.feature_map_.get(feature, [])
280036
def check(self):
        """"""
        for name, valItem, dtype in self.values:
            val = valItem.text()
            if dtype:
                try:
                    val = dtype(val)
                except:
                    msgBox = QtWidgets.QMessageBox()
                    msgBox.setText(
                        'attribute %s has not the right dtype(%s)' %
                        (name, str(dtype)))
                    msgBox.exec_()
            self.args[name] = val
        self.accept()
167649
def check_specs(specs, renamings, types):
    '''
    
    '''
    from pythran.types.tog import unify, clone, tr
    from pythran.types.tog import Function, TypeVariable, InferenceError

    functions = {renamings.get(k, k): v for k, v in specs.functions.items()}
    for fname, signatures in functions.items():
        ftype = types[fname]
        for signature in signatures:
            sig_type = Function([tr(p) for p in signature], TypeVariable())
            try:
                unify(clone(sig_type), clone(ftype))
            except InferenceError:
                raise PythranSyntaxError(
                    "Specification for `{}` does not match inferred type:\n"
                    "expected `{}`\n"
                    "got `Callable[[{}], ...]`".format(
                        fname,
                        ftype,
                        ", ".join(map(str, sig_type.types[:-1])))
                )
170637
void checkRmModelConformance() {
        final AmVisitor<AmObject, AmConstraintContext> visitor = AmVisitors.preorder(new ConformanceVisitor());
        ArchetypeWalker.walkConstraints(visitor, archetype, new AmConstraintContext());
    }
793599
def check(self, diff):
        
        """
        filename = pathlib.Path(diff.b_path).parts[-1]
        is_valid_feature_module_name = re_test(
            FEATURE_MODULE_NAME_REGEX, filename)
        is_valid_init_module_name = filename == '__init__.py'
        assert is_valid_feature_module_name or is_valid_init_module_name
835995
def _check_fit_data(self, X):
        """"""
        X = check_array(X, accept_sparse="csr", dtype=[np.float64, np.float32])
        n_samples, n_features = X.shape
        if X.shape[0] < self.n_clusters:
            raise ValueError(
                "n_samples=%d should be >= n_clusters=%d"
                % (X.shape[0], self.n_clusters)
            )

        for ee in range(n_samples):
            if sp.issparse(X):
                n = sp.linalg.norm(X[ee, :])
            else:
                n = np.linalg.norm(X[ee, :])

            if np.abs(n - 1.) > 1e-4:
                raise ValueError("Data l2-norm must be 1, found {}".format(n))

        return X
1041341
def _check_feature_dependences(self):
        """"""
        for mid in self.modules:
            for fst in self.modules[mid].statement.find_all("feature"):
                fn, fid = self.resolve_pname(fst.argument, mid)
                if fn not in self.modules[fid].features:
                    continue
                if not self.if_features(fst, mid):
                    raise FeaturePrerequisiteError(*fn)