Returns a list that associates all the winners of a profile under The Borda-mean rule.

        :ivar Profile profile: A Profile object that represents an election profile.
343131
def Borda_mean_winners(self, profile):
        
        n_candidates = profile.numCands
        prefcounts = profile.getPreferenceCounts()
        len_prefcounts = len(prefcounts)
        rankmaps = profile.getRankMaps()
        values = zeros([len_prefcounts, n_candidates], dtype=int)
        if min(list(rankmaps[0].keys())) == 0:
            delta = 0
        else:
            delta = 1
        for i in range(len_prefcounts):
            for j in range(delta, n_candidates + delta):
                values[i][j - delta] = rankmaps[i][j]
        # print("values=", values)
        mat0 = self._build_mat(values, n_candidates, prefcounts)
        borda = [0 for i in range(n_candidates)]
        for i in range(n_candidates):
            borda[i] = sum([mat0[i, j] for j in range(n_candidates)])
        borda_mean = mean(borda)
        bin_winners_list = [int(borda[i] >= borda_mean) for i in range(n_candidates)]
        return bin_winners_list
909787
def PluRunOff_cowinners(self, profile):
        

        # Currently, we expect the profile to contain complete ordering over candidates. Ties are
        # allowed however.
        elecType = profile.getElecType()
        if elecType != "soc" and elecType != "toc" and elecType != "csv":
            print("ERROR: unsupported election type")
            exit()

        # Initialization
        prefcounts = profile.getPreferenceCounts()
        len_prefcounts = len(prefcounts)
        rankmaps = profile.getRankMaps()
        ranking = MechanismPlurality().getRanking(profile)

        known_winners = set()
        # 1st round: find the top 2 candidates in plurality scores
        top_2_combinations = []
        if len(ranking[0][0]) > 1:
            for cand1, cand2 in itertools.combinations(ranking[0][0], 2):
                top_2_combinations.append([cand1, cand2])
        else:
            max_cand = ranking[0][0][0]
            if len(ranking[0][1]) > 1:
                for second_max_cand in ranking[0][1]:
                    top_2_combinations.append([max_cand, second_max_cand])
            else:
                second_max_cand = ranking[0][1][0]
                top_2_combinations.append([max_cand, second_max_cand])

        # 2nd round: find the candidate with maximum plurality score
        for top_2 in top_2_combinations:
            dict_top2 = {top_2[0]: 0, top_2[1]: 0}
            for i in range(len_prefcounts):
                vote_top2 = {key: value for key, value in rankmaps[i].items() if key in top_2}
                top_position = min(vote_top2.values())
                keys = [x for x in vote_top2.keys() if vote_top2[x] == top_position]
                for key in keys:
                    dict_top2[key] += prefcounts[i]

            max_value = max(dict_top2.values())
            winners = [y for y in dict_top2.keys() if dict_top2[y] == max_value]
            known_winners = known_winners | set(winners)

        return sorted(known_winners)
440776
async def get_profile(self, *tags):
        ''''''
        url = '{0.BASE}/profile/{1}'.format(self, ','.join(tags))

        data = await self.request(url)
                
        if isinstance(data, list):
            return [Profile(self, c) for c in data]
        else:
            return Profile(self, data)
280850
def _item_list(profile=None):
    '''
    
    '''
    g_client = _auth(profile)
    ret = []
    for item in g_client.items.list():
        ret.append(item.__dict__)
        #ret[item.name] = {
        #        'name': item.name,
        #    }
    return ret
660070
def get_all_outcome_links_for_context_accounts(self, account_id, outcome_group_style=None, outcome_style=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # OPTIONAL - outcome_style
        """The detail level of the outcomes. Defaults to "abbrev".
        Specify "full" for more information."""
        if outcome_style is not None:
            params["outcome_style"] = outcome_style

        # OPTIONAL - outcome_group_style
        """The detail level of the outcome groups. Defaults to "abbrev".
        Specify "full" for more information."""
        if outcome_group_style is not None:
            params["outcome_group_style"] = outcome_group_style

        self.logger.debug("GET /api/v1/accounts/{account_id}/outcome_group_links with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/accounts/{account_id}/outcome_group_links".format(**path), data=data, params=params, all_pages=True)
1059065
def CopelandWinner(profile, alpha=0.5):
    

    # Currently, we expect the profile to contain complete ordering over candidates.
    elecType = profile.getElecType()
    if elecType != "soc" and elecType != "toc":
        print("ERROR: unsupported profile type")
        exit()

    copelandscores = getCopelandScores(profile, alpha)
    winner = max(copelandscores.items(), key=lambda x: x[1])[0]
    return winner
890930
def profile(self, fields=None, sex=None):
        
        if fields is None:
            fields = []

        d = {
            "job": self.generator.job(),
            "company": self.generator.company(),
            "ssn": self.generator.ssn(),
            "residence": self.generator.address(),
            "current_location": (self.generator.latitude(), self.generator.longitude()),
            "blood_group": "".join(self.random_element(list(itertools.product(["A", "B", "AB", "O"], ["+", "-"])))),
            "website": [self.generator.url() for _ in range(1, self.random_int(2, 5))],
        }

        d = dict(d, **self.generator.simple_profile(sex))
        # field selection
        if len(fields) > 0:
            d = {k: v for k, v in d.items() if k in fields}

        return d
482057
def show_profiles(name, server, org_vm):
    
    rows = []
    for profile_inst in server.profiles:
        pn = profile_name(org_vm, profile_inst)
        deps = get_associated_profile_names(
            profile_inst.path, "dependent", org_vm, server,
            include_classnames=False)
        dep_refs = get_references(profile_inst.path, "antecedent", pn, server)
        ants = get_associated_profile_names(
            profile_inst.path, "antecedent", org_vm, server,
            include_classnames=False)
        ant_refs = get_references(profile_inst.path, "dependent",
                                  profile_name, server)

        # get unique class names
        dep_ref_clns = set([ref.classname for ref in dep_refs])
        ant_ref_clns = set([ref.classname for ref in ant_refs])
        row = (pn,
               fold_list(deps),
               fold_list(list(dep_ref_clns)),
               fold_list(ants),
               fold_list(list(ant_ref_clns)))
        rows.append(row)

        # append this server to the  dict of servers for this profile
        SERVERS_FOR_PROFILE[profile_name].append(name)

    title = '%s: Advertised profiles showing Profiles associations' \
        'Dependencies are Associators, AssocClass=CIM_ReferencedProfile' \
        'This table shows the results for ' % name
    headers = ['Profile',
               'Assoc CIMReferencedProfile\nResultRole\nDependent',
               'Ref classes References\nRole=Dependent',
               'Assoc CIMReferencedProfile\nResultRole\nAntecedent',
               'Ref classesReferences\nRole=Dependent']
    print_table(title, headers, rows, sort_columns=[1, 0])
904991
private RESCarListType getListOfAvailableCars(RESProfileType profile) {
		/*
		 * <xsd:enumeration value="NONE" /> <xsd:enumeration value="NORMAL" />
		 * <xsd:enumeration value="GOLD" /> <xsd:enumeration value="PLATINUM" />
		 */
		RESCarListType carList = resFactory.createRESCarListType();

		CRMStatusType status = profile.getCrmStatus();
		if (status == CRMStatusType.NONE) {
			carList.getCar().add(
					createCar("01-001-00099", "Panda", "Basic", "Fiat",
							"30.00", "45.00", "25.00"));
		} else if (status == CRMStatusType.NORMAL) {
			carList.getCar().add(
					createCar("01-001-00099", "Panda", "Basic", "Fiat",
							"30.00", "45.00", "25.00"));
			carList.getCar().add(
					createCar("01-002-00079", "Fiesta", "Basic", "Ford",
							"40.00", "55.00", "35.00"));
			carList.getCar().add(
					createCar("01-004-00022", "Golf", "Standard", "VW",
							"50.00", "75.00", "40.00"));
		} else if (status == CRMStatusType.GOLD) {
			carList.getCar().add(
					createCar("01-002-00079", "Fiesta", "Basic", "Ford",
							"40.00", "55.00", "35.00"));
			carList.getCar().add(
					createCar("01-004-00022", "Golf", "Standard", "VW",
							"50.00", "75.00", "40.00"));
			carList.getCar().add(
					createCar("01-008-00102", "320i", "Sport", "BMW", "60.00",
							"90.00", "45.00"));
			carList.getCar().add(
					createCar("01-015-00002", "MX5", "Sport", "Mazda", "65.00",
							"95.00", "50.00"));
		} else if (status == CRMStatusType.PLATINUM) {
			carList.getCar().add(
					createCar("01-004-00022", "Golf", "Standard", "VW",
							"50.00", "75.00", "40.00"));
			carList.getCar().add(
					createCar("01-004-00022", "320i", "Sport", "BMW", "60.00",
							"90.00", "45.00"));
			carList.getCar().add(
					createCar("01-004-00022", "MX5", "Sport", "Mazda", "65.00",
							"95.00", "50.00"));
			carList.getCar().add(
					createCar("01-004-00022", "LX400", "SUV", "Lexus", "85.00",
							"120.00", "100.00"));
			carList.getCar().add(
					createCar("01-004-00022", "E320", "Delux", "Mercedes",
							"95.00", "140.00", "100.00"));
		}

		return carList;
	}
1233221
def angprofile(self, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        self._replace_none(kwargs_copy)        
        localpath = NameFactory.angprofile_format.format(**kwargs_copy)
        if kwargs.get('fullpath', False):
            return self.fullpath(localpath=localpath)
        return localpath
1214203
def simple_profile(self, sex=None):
        
        SEX = ["F", "M"]
        if sex not in SEX:
            sex = self.random_element(SEX)
        if sex == 'F':
            name = self.generator.name_female()
        elif sex == 'M':
            name = self.generator.name_male()
        return {
            "username": self.generator.user_name(),
            "name": name,
            "sex": sex,
            "address": self.generator.address(),
            "mail": self.generator.free_email(),
            "birthdate": self.generator.date_of_birth(),
        }
836731
def show_count_associators(nickname, server, org_vm):
    
    d_assoc = fast_count_associators(server)

    svr_profiles_dict = {prof.path: prof for prof in server.profiles}

    headers = ('profile', 'ants', 'deps')
    rows = []

    assoc_dict = {}
    for prof_key, values in d_assoc.items():
        pn = profile_name(org_vm, svr_profiles_dict[prof_key])
        assoc_dict[pn] = (values['ant'], values['dep'])

    rows = []
    title = 'Display antecedent and dependent counts for possible ' \
        'autonomous and component profiles using fast method.\nDisplays the ' \
        'number of instances returned by\nAssociators request on profile for ' \
        'possible autonomous profiles. Algorithm is to enumerate ' \
        'ReferencedProfile and count Dependents/Antecedents with target path'
    headers = ('profile', 'Dependent\nCount', 'Antecedent\nCount')
    for pn, value in assoc_dict.items():
        rows.append((pn, value[1], value[0]))

    print_table(title, headers, rows, sort_columns=[0])

    g_rows = [(nickname, key, value[0], value[1])
              for key, value in assoc_dict.items()]
    ASSOC_PROPERTY_COUNTS.extend(g_rows)
633609
def baldwinsoc_winners(self, profile):
        
        ordering = profile.getOrderVectors()
        m = profile.numCands
        prefcounts = profile.getPreferenceCounts()
        if min(ordering[0]) == 0:
            startstate = set(range(m))
        else:
            startstate = set(range(1, m + 1))
        wmg = self.getWmg2(prefcounts, ordering, startstate, normalize=False)
        known_winners = set()
        # ----------Some statistics--------------
        hashtable2 = set()

        # push the node of start state into the priority queue
        root = Node(value=startstate)
        stackNode = []
        stackNode.append(root)

        while stackNode:
            # ------------pop the current node-----------------
            node = stackNode.pop()
            # -------------------------------------------------
            state = node.value.copy()

            # goal state 1: if the state set contains only 1 candidate, then stop
            if len(state) == 1 and list(state)[0] not in known_winners:
                known_winners.add(list(state)[0])
                continue
            # goal state 2 (pruning): if the state set is subset of the known_winners set, then stop
            if state <= known_winners:
                continue
            # ----------Compute plurality score for the current remaining candidates--------------
            plural_score = dict()
            for cand in state:
                plural_score[cand] = 0
            for cand1, cand2 in itertools.permutations(state, 2):
                plural_score[cand1] += wmg[cand1][cand2]

            # if current state satisfies one of the 3 goal state, continue to the next loop

            # After using heuristics, generate children and push them into priority queue
            # frontier = [val for val in known_winners if val in state] + list(set(state) - set(known_winners))

            minscore = min(plural_score.values())
            for to_be_deleted in state:
                if plural_score[to_be_deleted] == minscore:
                    child_state = state.copy()
                    child_state.remove(to_be_deleted)
                    tpc = tuple(sorted(child_state))
                    if tpc in hashtable2:
                        continue
                    else:
                        hashtable2.add(tpc)
                        child_node = Node(value=child_state)
                        stackNode.append(child_node)
        return sorted(known_winners)
1112754
public SortedMap<Variable, Integer> variableProfile(final BDD bdd) {
    final int[] varProfile = this.kernel.varProfile(bdd.index());
    final SortedMap<Variable, Integer> profile = new TreeMap<>();
    for (int i = 0; i < varProfile.length; i++) {
      profile.put(this.idx2var.get(i), varProfile[i]);
    }
    return profile;
  }
333784
def find_tie_breaker(self, candidate_ids):
        
        for candidate_aggregates in reversed(self.round_candidate_aggregates):
            candidates_on_vote = defaultdict(int)
            for candidate_id in candidate_ids:
                votes = candidate_aggregates.get_vote_count(candidate_id)
                candidates_on_vote[votes] += 1
            if max(candidates_on_vote.values()) == 1:
                return candidate_aggregates
386290
def profiles(self):
        '''
        
        '''
        limit = []

        if self.is_admin():
            limit.append(_("Administrator"))
        limit.sort()

        return limit
1306157
def results(profile=nil, options={})
      query = loaded? ? Query.from_query(self) : self

      options, profile = profile, self.profile if profile.is_a?(Hash)

      query.profile = profile
      query.apply_options(self.basic_options.merge(options))
      query
    end