moe.tests.bandit package

Submodules

moe.tests.bandit.bandit_interface_test module

Test bandit interface implementation.

class moe.tests.bandit.bandit_interface_test.TestBanditInterface[source]

Bases: moe.tests.bandit.bandit_test_case.BanditTestCase

Verify that different historical infos return correct results.

test_empty_arm_invalid()[source]

Test empty arms_to_allocations causes an ValueError.

test_one_arm()[source]

Check that the one-arm case always returns the given arm as the winning arm.

test_three_arms_two_winners()[source]

Check that the three-arms cases with two winners return one of the two winners.

test_two_arms_one_winner()[source]

Check that the two-arms case with one winner always returns the winning arm.

moe.tests.bandit.bandit_interface_test.disable_logging(request)[source]

Disable logging (for the duration of this test case).

moe.tests.bandit.bandit_test_case module

Base test case class for bandit tests; includes different historical infos (different sampled arms).

class moe.tests.bandit.bandit_test_case.BanditTestCase[source]

Bases: object

Base test case for the bandit library.

This sets up arms for test cases and includes an integration test case for verifying that default values do not throw an error.

bandit_class = None

Set up arms for test cases.

bernoulli_historical_infos_to_test = [<moe.bandit.data_containers.HistoricalData object at 0x11a880980>, <moe.bandit.data_containers.HistoricalData object at 0x11a8809b8>, <moe.bandit.data_containers.HistoricalData object at 0x11a8809f0>]
historical_infos_to_test = [<moe.bandit.data_containers.HistoricalData object at 0x11a880a28>, <moe.bandit.data_containers.HistoricalData object at 0x11a880a60>, <moe.bandit.data_containers.HistoricalData object at 0x11a880a98>, <moe.bandit.data_containers.HistoricalData object at 0x11a880ad0>, <moe.bandit.data_containers.HistoricalData object at 0x11a880b08>, <moe.bandit.data_containers.HistoricalData object at 0x11a880980>, <moe.bandit.data_containers.HistoricalData object at 0x11a8809b8>, <moe.bandit.data_containers.HistoricalData object at 0x11a8809f0>]
one_arm_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880980>
three_arms_float_payoffs_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880a60>
three_arms_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880a28>
three_arms_two_winners_no_unsampled_arm_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880ad0>
three_arms_two_winners_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880a98>
three_arms_with_variance_no_unsampled_arm_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a880b08>
two_arms_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a8809f0>
two_unsampled_arms_test_case = <moe.bandit.data_containers.HistoricalData object at 0x11a8809b8>

moe.tests.bandit.data_containers_test module

Tests for functions in SampleArm and HistoricalData.

class moe.tests.bandit.data_containers_test.TestDataContainers[source]

Bases: moe.tests.bandit.bandit_test_case.BanditTestCase

Tests functions in moe.bandit.data_containers.SampleArm and moe.bandit.data_containers.HistoricalData.

test_historical_data_append_arms()[source]

Test that appending arms to HistoricalData updates historical info correctly.

test_historical_data_append_arms_with_variance_invalid()[source]

Test that adding arms with variance causes a ValueError.

test_historical_data_append_unsampled_arm()[source]

Test that adding an unsampled arm (already exists in historical info) to HistoricalData does not change anything.

test_historical_data_str()[source]

Test HistoricalData’s __str__ overload operator.

test_sample_arm_add()[source]

Test SampleArm’s __add__ overload operator.

test_sample_arm_add_arm_with_variance_invalid()[source]

Test that adding arms with variance causes a ValueError. Neither of the arms can have non-None variance.

test_sample_arm_iadd()[source]

Test SampleArm’s __iadd__ overload operator.

Verify that after x += y, x gets the new value x + y and still retains its old id.

test_sample_arm_str()[source]

Test SampleArm’s __str__ overload operator.

moe.tests.bandit.data_containers_test.disable_logging(request)[source]

Disable logging (for the duration of this test case).

moe.tests.bandit.linkers_test module

Tests that linkers contain all possible types defined in constants.

class moe.tests.bandit.linkers_test.TestLinkers[source]

Bases: object

Tests that linkers contain all possible types defined in constants.

Test each bandit endpoint is in a linker, and every linker key is a bandit endpoint.

Test each epsilon subtype is in a linker, and every linker key is an epsilon subtype.

Test each UCB subtype is in a linker, and every linker key is a UCB subtype.

moe.tests.bandit.utils_test module

Tests for functions in utils.

class moe.tests.bandit.utils_test.TestUtils[source]

Bases: moe.tests.bandit.bandit_test_case.BanditTestCase

Tests moe.bandit.utils.get_winning_arm_names_from_payoff_arm_name_list() and moe.bandit.utils.get_equal_arm_allocations().

test_get_equal_arm_allocations_empty_arm_invalid()[source]

Test empty arms_sampled causes an ValueError.

test_get_equal_arm_allocations_no_winner()[source]

Test allocations split among all sample arms when there is no winner.

test_get_equal_arm_allocations_one_winner()[source]

Test all allocation given to the winning arm.

test_get_equal_arm_allocations_two_winners()[source]

Test allocations split between two winning arms.

test_get_winning_arm_names_from_payoff_arm_name_list_empty_list_invalid()[source]

Test empty payoff_arm_name_list causes an ValueError.

test_get_winning_arm_names_from_payoff_arm_name_list_one_winner()[source]

Test winning arm name matches the winner.

test_get_winning_arm_names_from_payoff_arm_name_list_two_winners()[source]

Test winning arm names match the winners.

moe.tests.bandit.utils_test.disable_logging(request)[source]

Disable logging (for the duration of this test case).

Module contents

Testing code for the (Python) bandit library.

Testing is done via the Testify package: https://github.com/Yelp/Testify

This package includes:

This package includes:

  • Test cases/test setup files
  • Tests for classes and utils in moe.bandit

Files in this package