Skip to content

Commit

Permalink
fix python to match interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Nov 1, 2024
1 parent dffe2c3 commit a3b8e9f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pybmds/bmdscore.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class python_multitumor_result:
nmodels: list[int]
selectedModelIndex: list[int]
slopeFactor: float
validResult: list[bool]
validResult: bool
def __init__(self) -> None: ...
def setSlopeFactor(self, arg0: float) -> None: ...

Expand Down
2 changes: 1 addition & 1 deletion src/pybmds/models/multi_tumor.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def execute(self):
self.structs.execute()
for i, models in enumerate(self.structs.result.models):
for j, model in enumerate(models):
if model.bmdsRes.BMD > 0:
if model.bmdsRes.validResult:
bmr = self.structs.analysis.models[i][j].BMR
model.bmdsRes.setSlopeFactor(bmr)
self.results = MultitumorResult.from_model(self)
Expand Down
2 changes: 1 addition & 1 deletion src/pybmds/types/multi_tumor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MultitumorResult(BaseModel):
models: list[list[BmdModelDichotomousSchema]] # all degrees for all datasets
selected_model_indexes: list[int | None]
slope_factor: float
valid_result: list[bool]
valid_result: bool

@classmethod
def from_model(cls, model) -> Self:
Expand Down
5 changes: 2 additions & 3 deletions tests/test_pybmds/models/test_multi_tumor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import pytest

import pybmds

Expand Down Expand Up @@ -57,6 +56,7 @@ def test_one_no_recommend(self, rewrite_data_files, data_path):
session.execute()
assert session.results.selected_model_indexes == [0, None]
assert np.isclose(session.results.bmd, 37.69, atol=0.01)
assert session.results.valid_result is True

# check we can build reports w/ none
text = session.text()
Expand All @@ -68,10 +68,8 @@ def test_one_no_recommend(self, rewrite_data_files, data_path):
df.to_excel(data_path / "reports/multitumor-no-selection.xlsx", index=False)
docx.save(data_path / "reports/multitumor-no-selection.docx")

@pytest.mark.skip(reason="currently segfaults; we need to fix at lower level")
def test_all_no_recommend(self):
# Check case all datasets have no model recommendation
# TODO - REMOVE pytest.mark.skip; assert that recommended_model is None for some cases
datasets = [
pybmds.DichotomousDataset(
doses=[0, 50, 100, 200, 400],
Expand All @@ -83,3 +81,4 @@ def test_all_no_recommend(self):
session.execute()

assert session.results.selected_model_indexes == [None]
assert session.results.valid_result is False

0 comments on commit a3b8e9f

Please sign in to comment.