def create_other_case_generic(rcdl, direct_other, shunt, flip_added, flip_removed, op, all_set_totaller=wrapped_len, direct_other_totaller=None, shunt_totaller=None, flip_added_totaller=None, flip_removed_totaller=None): direct_other_totaller = direct_other_totaller or all_set_totaller shunt_totaller = shunt_totaller or all_set_totaller flip_added_totaller = flip_added_totaller or all_set_totaller flip_removed_totaller = flip_removed_totaller or all_set_totaller if not (shunt is pos or shunt is neg): raise Exception("shunt was neither negative or positive") big_op = Plus if shunt is pos else Minus return g(big_op(Total(SplitterHider(lambda s, *args, **kwargs: sum((direct_other(comp_sum(s.do, 'added', rcdl, direct_other_totaller, **kwargs)), flip_added(comp_sum(s.f, 'added', rcdl, flip_added_totaller, **kwargs)), flip_removed(comp_sum(s.f, 'removed', rcdl, flip_removed_totaller, **kwargs)))))), Any(SplitterHider(lambda s, *args, **kwargs: comp_sum(s.s, 'removed', rcdl, shunt_totaller, **kwargs)))), op=op)
def generate_measure_constructor(self): # Note, won't contain self.quantity_goal, since this isn't really in the measure if self.locality_kv[0] == 'Global': raise NotImplementedError() all_comp_measure_constructors = [] for rcdl_set_kv in self.rcdl_sets_kvs: comp_measurer = self.cross_label_aggregator_kv[1](SplitterHider( lambda s, *args, **kwargs: comp_sum(s.dn, 'added', rcdl_set_kv[1], partial(self.set_item_score_seq_generator_kv[1], op=self.set_item_score_combiner_kv[1]), **kwargs))) measure_constructor = partial(GenericCompetenceMeasure, comp_measurer) if self.density_inclusion_kv[1]: measure_constructor = Measure.create_measure_constructor(average, [measure_constructor, self.density_inclusion_kv[1]]) all_comp_measure_constructors.append(measure_constructor) if len(all_comp_measure_constructors) > 1: measure_constructor = Measure.create_measure_constructor(self.measure_reducer_kv[1], all_comp_measure_constructors) return measure_constructor