Returns a dictionary that associates integer representations of each candidate with their
    Copeland score.

    :ivar Profile profile: A Profile object that represents an election profile.
483401
def getMaximinScores(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":
        print("ERROR: unsupported election type")
        exit()

    wmgMap = profile.getWmg()
    # Initialize each Copeland score as infinity.
    maximinscores = {}
    for cand in wmgMap.keys():
        maximinscores[cand] = float("inf")

    # For each pair of candidates, calculate the number of votes in which one beat the other.

    # For each pair of candidates, calculate the number of times each beats the other.
    for cand1, cand2 in itertools.combinations(wmgMap.keys(), 2):
        if cand2 in wmgMap[cand1].keys():
            maximinscores[cand1] = min(maximinscores[cand1], wmgMap[cand1][cand2])
            maximinscores[cand2] = min(maximinscores[cand2], wmgMap[cand2][cand1])

    return maximinscores
1290130
def get_polnum(self, obj):
        """"""
        ap_id = obj.candidate_election.candidate.ap_candidate_id
        if 'polnum-' in ap_id:
            return ap_id.replace('polnum-', '')
        return None
247374
def _get_profile(self):
        
        url = PROFILE_URL + self.hash + '.json'
        try:
            profile = json.load(urlopen(url))
            # set the profile as an instance variable
            self._profile = profile['entry'][0]
        except:
            self._profile = {}
1091617
def get_iterarg(self, name, index):
    
    plural = self._profile.iterargs[name]
    return self._values[plural][index]
609158
def PluRunOff_single_winner(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)

        # 1st round: find the top 2 candidates in plurality scores
        # Compute the 1st-place candidate in plurality scores
        # print(ranking)
        max_cand = ranking[0][0][0]

        # Compute the 2nd-place candidate in plurality scores
        # Automatically using tie-breaking rule--numerically increasing order
        if len(ranking[0][0]) > 1:
            second_max_cand = ranking[0][0][1]
        else:
            second_max_cand = ranking[0][1][0]

        top_2 = [max_cand, second_max_cand]
        # 2nd round: find the candidate with maximum plurality score
        dict_top2 = {max_cand: 0, second_max_cand: 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]

        # print(dict_top2)
        winner = max(dict_top2.items(), key=lambda x: x[1])[0]

        return winner
996609
def getCandScoresMap(self, profile):
        

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

        # Initialize our dictionary so that all candidates have a score of zero.
        candScoresMap = dict()
        for cand in profile.candMap.keys():
            candScoresMap[cand] = 0.0

        rankMaps = profile.getRankMaps()
        rankMapCounts = profile.getPreferenceCounts()
        scoringVector = self.getScoringVector(profile)

        # Go through the rankMaps of the profile and increment each candidates score appropriately.
        for i in range(0, len(rankMaps)):
            rankMap = rankMaps[i]
            rankMapCount = rankMapCounts[i]
            for cand in rankMap.keys():
                candScoresMap[cand] += scoringVector[rankMap[cand] - 1] * rankMapCount

        # print("candScoresMap=", candScoresMap)
        return candScoresMap
264584
def get_candidates(self, obj):
        
        return CandidateElectionSerializer(
            obj.candidate_elections.all(), many=True
        ).data
625436
def MaximinWinner(profile):
    

    # 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()

    maximinscores = getMaximinScores(profile)
    winner = max(maximinscores.items(), key=lambda x: x[1])[0]
    return winner
218069
def get_associated_profiles(self):
        
        uri = "{}/associatedProfiles".format(self.data['uri'])
        return self._helper.do_get(uri)
6345
def envvar_profile(
    profile_root: str,
    profile_properties: typing.Dict[str, typing.Optional[str]] = None,
    **profile_properties_as_kwargs,
) -> EnvvarProfile:
    
    if profile_properties:
        profile_properties_as_kwargs.update(profile_properties)
    return type(f"{profile_root}Profile", (EnvvarProfile,), {
        "profile_root": profile_root.lower(),
        "profile_properties": list(profile_properties_as_kwargs.keys()),
        **{
            k: EnvvarProfileProperty(name=k, default=v, type_=str)
            for k, v in profile_properties_as_kwargs.items()
        },
    })()
1118488
def black_winner(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()

        wmg = profile.getWmg()
        m = profile.numCands
        for cand1 in wmg.keys():
            outgoing = 0
            for cand2 in wmg[cand1].keys():
                if wmg[cand1][cand2] > 0:
                    outgoing += 1
            if outgoing == m - 1:
                return [cand1]

        Borda_winner = MechanismBorda().getWinners(profile)
        return Borda_winner
1172636
def getCandScoresMap(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":
            print("ERROR: unsupported election type")
            exit()

        wmg = profile.getWmg()

        # Initialize the maximin score for each candidate as infinity.
        maximinScores = dict()
        for cand in wmg.keys():
            maximinScores[cand] = float("inf")

        # For each pair of candidates, calculate the number of times each beats the other.
        for cand1, cand2 in itertools.combinations(wmg.keys(), 2):
            if cand2 in wmg[cand1].keys():
                maximinScores[cand1] = min(maximinScores[cand1], wmg[cand1][cand2])
                maximinScores[cand2] = min(maximinScores[cand2], wmg[cand2][cand1])

        return maximinScores
744014
def network_profiles(self, obj):
        """"""

        profile_name_list = self.network_profile_name_list(obj)

        profile_list = []
        for profile_name in profile_name_list:
            profile = Profile()
            flags = DWORD()
            access = DWORD()
            xml = LPWSTR()
            self._wlan_get_profile(self._handle, obj['guid'],
                                   profile_name, byref(xml), byref(flags),
                                   byref(access))
            # fill profile info
            profile.ssid = re.search(r'<name>(.*)</name>', xml.value).group(1)
            auth = re.search(r'<authentication>(.*)</authentication>',
                                 xml.value).group(1).upper()

            profile.akm = []
            if auth not in akm_str_to_value_dict:
                if auth not in auth_str_to_value_dict:
                    profile.auth = AUTH_ALG_OPEN
                else:
                    profile.auth = auth_str_to_value_dict[auth]
                    profile.akm.append(AKM_TYPE_NONE)
            else:
                    profile.auth = AUTH_ALG_OPEN
                    profile.akm.append(akm_str_to_value_dict[auth])

            profile_list.append(profile)

        return profile_list
372298
protected int getCurrentSelection() {
        if (mCurrentProfile != null && mProfiles != null) {
            int i = 0;
            for (IProfile profile : mProfiles) {
                if (profile == mCurrentProfile) {
                    return i;
                }
                i++;
            }
        }
        return -1;
    }
1185718
def _get_player_profile(self, player_handle):
        
        url = self.pubg_url + player_handle
        response = requests.request("GET", url, headers=self.headers)
        data = json.loads(response.text)
        return data
164530
def getScoringVector(self, profile):
        

        scoringVector = []
        scoringVector.append(1)
        for i in range(1, profile.numCands):
            scoringVector.append(0)
        return scoringVector
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