MatchMaker.match() — alfred3_interact

Skip to main content
`Ctrl`+`K`

# MatchMaker.match()

MatchMaker.match() → Group

  Shorthand method for conducting a match if there is only a single spec.

  Raises

    - ValueError – If there is more than one spec.

    - NoMatch – If a single matching effort was unsuccesful. This exception gets handled by `WaitingPage` and is part of a normal matching process.

  Returns

    The group object.

  Return type

    Group

  Examples

  Matching based on a single spec:

      import alfred3 as al
      import alfred3_interact as ali

      exp = al.Experiment()

      @exp.setup
      def setup(exp):
          spec = ali.SequentialSpec("a", "b", nslots=10, name="spec1")
          exp.plugins.mm = ali.MatchMaker(spec, exp=exp)

      @exp.member
      class Match(ali.WaitingPage):

          def wait_for(self):
              group = self.exp.plugins.mm.match()
              self.exp.plugins.group = group
              return True

      @exp.member
      class Success(al.Page):

          def on_first_show(self):
              group = self.exp.plugins.group
              role = group.me.role

              self += al.Text(f"Successfully matched to role: {role}")