Skip to content

adds available_device to test_cohen_kappa.py #3335 #3355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tests/ignite/metrics/test_cohen_kappa.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ def test_data_binary(request):

@pytest.mark.parametrize("n_times", range(5))
@pytest.mark.parametrize("weights", [None, "linear", "quadratic"])
def test_binary_input(n_times, weights, test_data_binary):
def test_binary_input(n_times, weights, test_data_binary, available_device):
y_pred, y, batch_size = test_data_binary
ck = CohenKappa(weights)
ck = CohenKappa(weights=weights, device=available_device)
assert ck._device == torch.device(available_device)

ck.reset()
if batch_size > 1:
n_iters = y.shape[0] // batch_size + 1
Expand Down Expand Up @@ -135,7 +137,7 @@ def test_data_integration_binary(request):

@pytest.mark.parametrize("n_times", range(5))
@pytest.mark.parametrize("weights", [None, "linear", "quadratic"])
def test_integration_binary_input(n_times, weights, test_data_integration_binary):
def test_integration_binary_input(n_times, weights, test_data_integration_binary, available_device):
y_pred, y, batch_size = test_data_integration_binary

def update_fn(engine, batch):
Expand All @@ -146,7 +148,9 @@ def update_fn(engine, batch):

engine = Engine(update_fn)

ck_metric = CohenKappa(weights=weights)
ck_metric = CohenKappa(weights=weights, device=available_device)
assert ck_metric._device == torch.device(available_device)

ck_metric.attach(engine, "ck")

np_y = y.numpy()
Expand Down
Loading