def process_features(self): """ Process loaded features. load_features must have been called. """ if self._features is None: self.features = None return if self.variance_filter is not None: self._filtered_feat = feature.filter_variance(self._features, self.variance_filter, self.plot_variance) else: self._filtered_feat = self._features if self.lda is not None: noise = self.lda.predict(self._filtered_feat) self._filtered_feat = [elem for elem, n in itertools.izip(self._filtered_feat, noise) if n == 0] if self.min_frames is not None: if len(self._filtered_feat) < self.min_frames: self.features = [] return if self.frame_split is not None: split = feature.split(self._filtered_feat, self.frame_split) else: split = [self._filtered_feat] self.features = split
def normalize_condition(property_sets): """ Expands subfeatures in each property set. e.g <toolset>gcc-3.2 will be converted to <toolset>gcc/<toolset-version>3.2 TODO: does this one belong here or in feature? """ result = [] for p in property_sets: split = feature.split(p) expanded = feature.expand_subfeatures(split) result.append('/'.join(expanded)) return result
def normalize_condition (property_sets): """ Expands subfeatures in each property set. e.g <toolset>gcc-3.2 will be converted to <toolset>gcc/<toolset-version>3.2 TODO: does this one belong here or in feature? """ result = [] for p in property_sets: split = feature.split (p) expanded = feature.expand_subfeatures (split) result.append ('/'.join (expanded)) return result
def __x_product_aux(property_sets, x_product_seen, x_product_used, feature_space): """ Implementation of __x_product. """ result = [] if property_sets: p = feature.split(property_sets[0]) else: p = [] f = set.difference(get_grist(p), feature.free_features()) seen = [] # No conflict with things used at a higher level? if not set.intersection(f, x_product_used): # don't mix in any conflicting features local_x_product_used = x_product_used + f local_x_product_seen = [] if len(property_sets) > 1: rest = __x_product_aux(property_sets[1:], local_x_product_seen, local_x_product_used, feature_space) result = [property_sets[0] + '/' + x for x in rest] if not result and property_sets: result = [property_sets[0]] # If we didn't encounter a conflicting feature lower down, # don't recurse again. if not set.intersection(f, local_x_product_seen): property_sets = [] seen = local_x_product_seen if len(property_sets) > 1: result.extend( __x_product_aux(property_sets[1:], x_product_seen, x_product_used, feature_space)) x_product_seen += f + seen # Note that we've seen these features so that higher levels will # recurse again without them set. return result
def __x_product_aux (property_sets, x_product_seen, x_product_used, feature_space): """ Implementation of __x_product. """ result = [] if property_sets: p = feature.split (property_sets [0]) else: p = [] f = set.difference (get_grist (p), feature.free_features ()) seen = [] # No conflict with things used at a higher level? if not set.intersection (f, x_product_used): # don't mix in any conflicting features local_x_product_used = x_product_used + f local_x_product_seen = [] if len (property_sets) > 1: rest = __x_product_aux (property_sets [1:], local_x_product_seen, local_x_product_used, feature_space) result = [ property_sets [0] + '/' + x for x in rest] if not result and property_sets: result = [property_sets [0]] # If we didn't encounter a conflicting feature lower down, # don't recurse again. if not set.intersection (f, local_x_product_seen): property_sets = [] seen = local_x_product_seen if len (property_sets) > 1: result.extend (__x_product_aux (property_sets [1:], x_product_seen, x_product_used, feature_space)) x_product_seen += f + seen # Note that we've seen these features so that higher levels will # recurse again without them set. return result
def find_property_subset(property_sets, properties): """Returns the first element of 'property-sets' which is a subset of 'properties', or an empty list if no such element exists.""" prop_keys = get_grist(properties) for s in property_sets: # Handle value-less properties like '<architecture>' (compare with # '<architecture>x86'). set = feature.split(s) # Find the set of features that # - have no property specified in required property set # - are omitted in build property set default_props = [] for i in set: # If $(i) is a value-less property it should match default # value of an optional property. See the first line in the # example below: # # property set properties result # <a> <b>foo <b>foo match # <a> <b>foo <a>foo <b>foo no match # <a>foo <b>foo <b>foo no match # <a>foo <b>foo <a>foo <b>foo match if not (get_value(i) or get_grist(i) in prop_keys): default_props.append(i) # FIXME: can this be expressed in a more pythonic way? has_all = 1 for i in set: if i not in (properties + default_props): has_all = 0 break if has_all: return s return None
def find_property_subset (property_sets, properties): """Returns the first element of 'property-sets' which is a subset of 'properties', or an empty list if no such element exists.""" prop_keys = get_grist(properties) for s in property_sets: # Handle value-less properties like '<architecture>' (compare with # '<architecture>x86'). set = feature.split(s) # Find the set of features that # - have no property specified in required property set # - are omitted in build property set default_props = [] for i in set: # If $(i) is a value-less property it should match default # value of an optional property. See the first line in the # example below: # # property set properties result # <a> <b>foo <b>foo match # <a> <b>foo <a>foo <b>foo no match # <a>foo <b>foo <b>foo no match # <a>foo <b>foo <a>foo <b>foo match if not (get_value(i) or get_grist(i) in prop_keys): default_props.append(i) # FIXME: can this be expressed in a more pythonic way? has_all = 1 for i in set: if i not in (properties + default_props): has_all = 0 break if has_all: return s return None
def __apply_to_property_set (f, property_set): """ Transform property_set by applying f to each component property. """ properties = feature.split (property_set) return '/'.join (f (properties))
def __apply_to_property_set(f, property_set): """ Transform property_set by applying f to each component property. """ properties = feature.split(property_set) return '/'.join(f(properties))