Skip to content

Commit

Permalink
remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBinder committed Nov 29, 2023
1 parent ecf0c73 commit 34ec602
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions tests/taskmodules/test_pointer_network_for_joint_taskmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@

# FIXTURES_DIR = FIXTURES_ROOT / "taskmodules" / "gmam_taskmodule"

DUMP_FIXTURE_DATA = False


def _config_to_str(cfg: Dict[str, str]) -> str:
result = "-".join([f"{k}={cfg[k]}" for k in sorted(cfg)])
return result


CONFIGS = [
{"span_end_mode": "first_token_of_last_word"},
{"span_end_mode": "last_token"},
]
CONFIGS_DICT = {_config_to_str(cfg): cfg for cfg in CONFIGS}

DUMP_FIXTURE_DATA = False
CONFIGS = [{}, {"partition_layer_name": "sentences"}]
CONFIG_DICT = {_config_to_str(cfg): cfg for cfg in CONFIGS}


@pytest.fixture(scope="module", params=CONFIGS_DICT.keys())
def config(request):
return CONFIGS_DICT[request.param]
@pytest.fixture(scope="module", params=CONFIG_DICT.keys())
def config_str(request):
return request.param


@pytest.fixture(scope="module")
def config_str(config):
return _config_to_str(config)
def config(config_str):
return CONFIG_DICT[config_str]


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -87,20 +84,6 @@ def test_document(document):
assert str(sentences[1]) == "Trust me."


CONFIGS = [{}, {"partition_layer_name": "sentences"}]
CONFIG_DICT = {_config_to_str(cfg): cfg for cfg in CONFIGS}


@pytest.fixture(scope="module", params=CONFIG_DICT.keys())
def config_str(request):
return request.param


@pytest.fixture(scope="module")
def config(config_str):
return CONFIG_DICT[config_str]


@pytest.fixture(scope="module")
def taskmodule(document, config):
taskmodule = PointerNetworkForJointTaskModule(
Expand Down

0 comments on commit 34ec602

Please sign in to comment.