Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
himoto committed Oct 16, 2024
1 parent f6113dd commit 2788960
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.9]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

NUM_THREADS = "1"
os.environ["OMP_NUM_THREADS"] = NUM_THREADS
2 changes: 1 addition & 1 deletion tests/test_coad_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_patient_model_simulations():
# Execute patient-specific models
simulations = PatientModelSimulations(models.colon.__package__, random.sample(TCGA_ID, 3))
start = time.time()
assert simulations.run() is None
assert simulations.run(n_proc=2) is None
elapsed = time.time() - start
print(f"Computation time for simulating 3 patients: {elapsed/60:.1f} [min]")

Expand Down
22 changes: 9 additions & 13 deletions tests/test_patient_specific_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ def test_model_construction():
shutil.rmtree(os.path.join(PATH_TO_MODELS, "TCGA_3C_AALK_01A"))
except FileNotFoundError:
pass
shutil.move(
os.path.join("models", "erbb_network"),
os.path.join(PATH_TO_MODELS, "TCGA_3C_AALK_01A")
)
shutil.move(os.path.join("models", "erbb_network"), os.path.join(PATH_TO_MODELS, "TCGA_3C_AALK_01A"))
assert os.path.isdir(path_to_patient("TCGA_3C_AALK_01A"))
try:
from models.breast import TCGA_3C_AALK_01A
Expand All @@ -138,7 +135,7 @@ def test_patient_model_simulations(
n_patients: int = 3,
dynamical_feature: Optional[List[str]] = None,
):
if not 1<= n_patients <= 6:
if not 1 <= n_patients <= 6:
raise ValueError("`n_patients` must be lie within [1, 6].")
# Initialization
for patient in TCGA_ID:
Expand Down Expand Up @@ -170,12 +167,12 @@ def test_patient_model_simulations(
random.sample(TNBC_ID, n_patients),
)
start = time.time()
assert simulations.run() is None
assert simulations.run(n_proc=2) is None
elapsed = time.time() - start
print(f"Computation time for simulating {n_patients} patients: {elapsed/60:.1f} [min]")
# Add new response characteristics
get_droprate: Callable[[np.ndarray], float] = (
lambda time_course: -(time_course[-1] - np.max(time_course)) / (len(time_course) - np.argmax(time_course))
get_droprate: Callable[[np.ndarray], float] = lambda time_course: -(time_course[-1] - np.max(time_course)) / (
len(time_course) - np.argmax(time_course)
)
simulations.response_characteristics["droprate"] = get_droprate
# Extract response characteristics and visualize patient classification
Expand All @@ -202,11 +199,9 @@ def test_patient_model_analyses():
analyses = PatientModelAnalyses(
models.breast.__package__,
patients,
biomass_kws={
"metric": "maximum", "style": "heatmap", "options": {"excluded_initials": ["PIP2"]}
},
biomass_kws={"metric": "maximum", "style": "heatmap", "options": {"excluded_initials": ["PIP2"]}},
)
assert analyses.run() is None
assert analyses.run(n_proc=2) is None
for patient in patients:
assert os.path.isfile(
os.path.join(
Expand All @@ -218,13 +213,14 @@ def test_patient_model_analyses():
)
)


def test_four_breast_cancer_cell_line_models():
cell_lines: List[str] = []
for model in os.listdir(os.path.join("models", "breast")):
if model.endswith("_BREAST"):
cell_lines.append(model)
simulations = PatientModelSimulations(models.breast.__package__, cell_lines)
assert simulations.run() is None
assert simulations.run(n_proc=2) is None
for model in cell_lines:
simulated_values = np.load(
os.path.join(
Expand Down

0 comments on commit 2788960

Please sign in to comment.