Skip to content

Commit

Permalink
Force synchronous (serial) computation in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daffidwilde committed Nov 28, 2023
1 parent 034fdca commit 02496f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/mst/test_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import platform
from unittest import mock

import dask
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -63,7 +64,9 @@ def test_measure(params, num_cliques):
population_type, area_type, dimensions, clique, table = params
mst = mocked_mst(population_type, area_type, dimensions)

with mock.patch("centhesus.mst.MST.get_marginal") as get_marginal:
with mock.patch(
"centhesus.mst.MST.get_marginal"
) as get_marginal, dask.config.set(scheduler="synchronous"):
get_marginal.return_value = table
measurements = mst.measure([clique] * num_cliques)

Expand Down
5 changes: 4 additions & 1 deletion tests/mst/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import platform
from unittest import mock

import dask
import networkx as nx
import pytest
from hypothesis import given, settings
Expand Down Expand Up @@ -71,7 +72,9 @@ def test_calculate_importances(params):
population_type, area_type, dimensions, domain, importances = params
mst = mocked_mst(population_type, area_type, dimensions, domain=domain)

with mock.patch("centhesus.mst.MST._calculate_importance_of_pair") as calc:
with mock.patch(
"centhesus.mst.MST._calculate_importance_of_pair"
) as calc, dask.config.set(scheduler="synchronous"):
calc.side_effect = importances
weights = mst._calculate_importances("interim")

Expand Down

0 comments on commit 02496f6

Please sign in to comment.