def initialize_market()

in simulation/decai/simulation/contract/incentive/prediction_market.py [0:0]


    def initialize_market(self, msg: Msg,
                          test_dataset_hashes: List[str],
                          # Ending criteria:
                          min_length_s: int, min_num_contributions: int) -> int:
        """
        Initialize the prediction market.

        :param msg: Indicates the one posting the bounty and the amount being committed for the bounty.
            The total bounty should be an integer since it also represents the number of "rounds" in the PM.
        :param test_dataset_hashes: The committed hashes for the portions of the test set.
        :param min_length_s: The minimum length in seconds of the market.
        :param min_num_contributions: The minimum number of contributions before ending the market.

        :return: The index of the test set that must be revealed.
        """
        assert self._market_earliest_end_time_s is None
        assert self._next_data_index is None, "The market end has already been triggered."
        assert self.state is None

        self.bounty_provider = msg.sender
        self.total_bounty = msg.value
        self.remaining_bounty_rounds = self.total_bounty
        self.test_set_hashes = test_dataset_hashes
        assert len(self.test_set_hashes) > 1
        self.test_reveal_index = random.randrange(len(self.test_set_hashes))
        self.next_test_set_index_to_verify = 0
        if self.next_test_set_index_to_verify == self.test_reveal_index:
            self.next_test_set_index_to_verify += 1

        self._market_data: List[_Contribution] = []
        self.min_num_contributions = min_num_contributions
        self._market_earliest_end_time_s = self._time() + min_length_s

        self.reward_phase_end_time_s = None

        self.prev_acc = None
        self.original_acc = None

        # Pay the owner since it will be the owner distributing funds using `handle_refund` and `handle_reward` later.
        self._balances.send(self.bounty_provider, self.owner, self.total_bounty)

        self.state = MarketPhase.INITIALIZATION

        return self.test_reveal_index