Skip to content

Matcher Objects

Creation

perfect_strangers.create_matcher(groups_per_round, group_size, participant_labels=None)

Create a groups matcher for the given experiment parameters.

Parameters:

Name Type Description Default
groups_per_round int

The number of groups per round of the experiment.

required
group_size int

The number of participants in each group.

required
participant_labels ParticipantLabels

A list of unique labels for the experiment participants. Must have groups_per_round * group_size unique elements.

None

Returns:

Type Description
BaseMatcher

A matcher object of a type which inherits from BaseMatcher.

Base Class

All matching methods inherit the interface of the BaseMatcher class.

perfect_strangers.BaseMatcher

Base class for all group matching methods.

max_rounds property

The maximum number of rounds this matcher will produce under perfect stranger matching conditions.

rounds property

A list of participant groupings for all rounds constructed by this matcher.

__iter__()

Allow for iterating over rounds in a for loop. For example:

matcher = create_matcher(groups_per_round, group_size)

for round in matcher:
    print(round)

groups_for_next_round()

Get the groups for the next round.

Returns:

Type Description
RoundGroups | None

A list of participants groupings for the next round, or None if there are no more rounds possible.

groups_for_round(round_index)

Get the groups for the round with a given index.

Parameters:

Name Type Description Default
round_index int

The index of the round to get groups for, an integer between 0 and self.max_rounds - 1.

required

Returns:

Type Description
RoundGroups

A list of participants groupings for the requested round.

restart()

Reset the matcher to the first round.

shuffle_sequence()

Shuffle the list of rounds produced by this matcher.

Types

perfect_strangers.base_matcher.ParticipantLabels = list | None module-attribute