PythonSkills icon indicating copy to clipboard operation
PythonSkills copied to clipboard

Casting mutliple `Match()` as `Matches()` strips the `rank` property from each `Match()``

Open ReagentX opened this issue 8 years ago • 3 comments

match_stats = [[Match([{Player(6667): GaussianRating(25.0, 8.333)}, {Player(4991): GaussianRating(25.0, 8.333)}], rank=[1, 2])], [Match([{Player(6615): GaussianRating(25.0, 8.333)}, {Player(7557): GaussianRating(25.0, 8.333)}], rank=[1, 2])]]

Cast match_stat as Matches():

Matches(match_stats)

This results in:

 [Match([{Player(6667): GaussianRating(25.0, 8.333)}, {Player(4991): GaussianRating(25.0, 8.333)}]), Match([{Player(6615): GaussianRating(25.0, 8.333)}, {Player(7557): GaussianRating(25.0, 8.333)}])]

As a result, using calculator will result in AttributeError: Match does not have a ranking.

ReagentX avatar Sep 15 '17 19:09 ReagentX

This is your example. You have a list of lists instead of a list of single match objects.

match_stats = [
    [Match([
        {Player(6667): GaussianRating(25.0, 8.333)}, 
        {Player(4991): GaussianRating(25.0, 8.333)}
    ], rank=[1, 2])],
    [Match([
        {Player(6615): GaussianRating(25.0, 8.333)},
        {Player(7557): GaussianRating(25.0, 8.333)}
    ], rank=[1, 2])]
]

Take off the extra brackets around the match objects:

match_stats = [
    Match([
        {Player(6667): GaussianRating(25.0, 8.333)}, 
        {Player(4991): GaussianRating(25.0, 8.333)}
    ], rank=[1, 2]),
    Match([
        {Player(6615): GaussianRating(25.0, 8.333)},
        {Player(7557): GaussianRating(25.0, 8.333)}
    ], rank=[1, 2])
]

I think it is confusing that you got back almost what you expected but without the rank. I'll have to decide if an error should be thrown or not.

McLeopold avatar Sep 16 '17 01:09 McLeopold

Thanks for your clarification–not sure how I missed that. I will have to rethink how I am generating the Match objects.

As an aside: does the rank=[1, 2] mean the first item in the match "won" while the second item in the match "lost"? For example, in

match_stats = [
Match([
    {Player(6667): GaussianRating(25.0, 8.333)}, 
    {Player(4991): GaussianRating(25.0, 8.333)}
      ], rank=[1, 2])]

the rank=[1, 2] denotes that Player(6667) beat Player(4991)?

ReagentX avatar Sep 16 '17 01:09 ReagentX

Yes. It's 2 lists that get matched up by order. Lowest number wins. Remember you can have more than 2 teams.

McLeopold avatar Sep 20 '17 07:09 McLeopold