Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rita Kurban authored and Rita Kurban committed Jan 13, 2025
1 parent c40eced commit 5de4151
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/eva/text/data/datasets/classification/test_pubmedqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import shutil
from typing import Literal

import pytest
import torch
Expand All @@ -12,18 +11,15 @@


@pytest.fixture(scope="function")
def pubmedqa_dataset(
split: None
) -> datasets.PubMedQA:
def pubmedqa_dataset(split: None) -> datasets.PubMedQA:
"""PubMedQA dataset fixture."""
dataset = datasets.PubMedQA(split=split)
dataset.prepare_data()
return dataset


@pytest.fixture(scope="function")
def pubmedqa_dataset_with_cache(
tmp_path, split: None) -> datasets.PubMedQA:
def pubmedqa_dataset_with_cache(tmp_path, split: None) -> datasets.PubMedQA:
"""PubMedQA dataset fixture with caching enabled."""
root = tmp_path / "pubmed_qa_cache"
dataset = datasets.PubMedQA(root=str(root), split=split, download=True)
Expand Down Expand Up @@ -82,12 +78,14 @@ def test_classes(pubmedqa_dataset: datasets.PubMedQA) -> None:
assert pubmedqa_dataset.classes == ["no", "yes", "maybe"]
assert pubmedqa_dataset.class_to_idx == {"no": 0, "yes": 1, "maybe": 2}


@pytest.mark.parametrize("split", [None])
def test_prepare_data_no_root(pubmedqa_dataset: datasets.PubMedQA) -> None:
"""Tests dataset preparation without specifying a root directory."""
assert isinstance(pubmedqa_dataset.dataset, Dataset)
assert len(pubmedqa_dataset) > 0


@pytest.mark.parametrize("split", [None])
def test_prepare_data_with_cache(pubmedqa_dataset_with_cache: datasets.PubMedQA) -> None:
"""Tests dataset preparation with caching."""
Expand All @@ -100,10 +98,9 @@ def test_prepare_data_with_cache(pubmedqa_dataset_with_cache: datasets.PubMedQA)
assert os.path.exists(cache_dir)
assert any(os.scandir(cache_dir))


@pytest.mark.parametrize("split", [None])
def test_prepare_data_without_download(
tmp_path, split
) -> None:
def test_prepare_data_without_download(tmp_path, split) -> None:
"""Tests dataset preparation when download is disabled and cache is missing."""
root = tmp_path / "pubmed_qa_cache"
dataset = datasets.PubMedQA(root=str(root), split=split, download=False)
Expand Down

0 comments on commit 5de4151

Please sign in to comment.