Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Oct 18, 2024
2 parents aa04ce1 + 7df7637 commit 62408c8
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 14 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/IndividualModel/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Summary extends Component {
data = [
["BMD", ff(model.results.bmd), model.results.bmd],
["BMDL", ff(model.results.bmdl), model.results.bmdl],
["BMDU", ff(model.results.bmdu), model.results.bmdu],
["AIC", ff(model.results.aic), model.results.aic],
[
<span key={0}>
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/Output/FrequentistResultTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const getModelBinLabel = function(output, index) {
},
getColWidths = function(store) {
if (store.isNestedDichotomous) {
return store.recommendationEnabled ? [20, 12, 12, 12, 12, 32] : [20, 20, 20, 20, 20];
return store.recommendationEnabled
? [20, 11, 11, 11, 11, 11, 25]
: [20, 16, 16, 16, 16, 16];
} else {
return store.recommendationEnabled
? [12, 8, 8, 8, 8, 8, 10, 10, 28]
Expand Down Expand Up @@ -248,6 +250,9 @@ class FrequentistRow extends Component {
<td>
<FloatingPointHover value={results.bmd} />
</td>
<td>
<FloatingPointHover value={results.bmdu} />
</td>
<td>{ff(results.combined_pvalue)}</td>
<td>
<FloatingPointHover value={results.aic} />
Expand Down Expand Up @@ -341,7 +346,7 @@ class FrequentistResultTable extends Component {
<th>Model</th>
<th>BMDL</th>
<th>BMD</th>
{isNestedDichotomous ? null : <th>BMDU</th>}
<th>BMDU</th>
<th>
<i>P</i>-Value
</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BootstrapResult extends Component {
["# Iterations", settings.bootstrap_iterations],
["Bootstrap Seed", ff(settings.bootstrap_seed)],
["Log-likelihood", ff(results.ll)],
["Observed Chi²", ff(results.obs_chi_sq)],
["Observed Chi²", ff(results.chi_squared)],
[
<span key={0}>
Combined <i>P</i>-Value
Expand Down
6 changes: 6 additions & 0 deletions tests/analysis/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def test_auth(self, complete_continuous):
response = client.patch(write_url, payload, format="json")
assert response.status_code == 200

def test_default_input(self):
client = APIClient()
url = reverse("api:analysis-default")
response = client.get(url, format="json")
assert response.json()["dataset_type"] == "C"

def test_patch_auth(self):
client = APIClient()
analysis = Analysis.objects.create()
Expand Down
26 changes: 26 additions & 0 deletions tests/analysis/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ def write_excel(data: dict, path: Path):
df.to_excel(writer, sheet_name=name, index=False)


@pytest.mark.django_db()
class TestAnalysis:
def test_maybe_hanging(self):
qs = Analysis.maybe_hanging(queryset=Analysis.objects.all())
assert qs.count() == 1
assert str(qs[0].id) == "bb5ada91-8f32-4a24-aedf-dcecbe5044f6"

def test_model_class_label(self):
a = Analysis.objects.get(id="cc3ca355-a57a-4fba-9dc3-99657562df68")
assert a.model_class_label == "Continuous"

def test_timestamp(self):
a = Analysis.objects.get(id="cc3ca355-a57a-4fba-9dc3-99657562df68")
assert str(a.timestamp) == "2021-12-15 18:42:49.109397+00:00"

def test_delete_old_analyses(self):
n_before = Analysis.objects.count()
assert Analysis.objects.filter(id="1b4360dd-27ae-46f1-ad7e-45796d44be8c").exists()

Analysis.delete_old_analyses()

n_after = Analysis.objects.count()
assert n_before - n_after == 1
assert not Analysis.objects.filter(id="1b4360dd-27ae-46f1-ad7e-45796d44be8c").exists()


@pytest.mark.django_db()
class TestExecution:
def test_continuous(self, complete_continuous, data_path, rewrite_data_files):
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_context(self):
"deleteUrl": f"http://testserver/analysis/{pk}/{pw}/delete/",
"executeUrl": f"/api/v1/analysis/{pk}/execute/",
"executeResetUrl": f"/api/v1/analysis/{pk}/execute-reset/",
"deleteDateStr": "June 14, 2022",
"deleteDateStr": "December 31, 2045",
"collections": [{"id": 1, "name": "Label #1"}],
},
}
Expand Down
223 changes: 213 additions & 10 deletions tests/data/db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1763,12 +1763,12 @@
created: 2021-12-15 18:42:28.857142+00:00
started: 2021-12-15 18:42:48.876358+00:00
ended: 2021-12-15 18:42:49.109397+00:00
deletion_date: 2022-06-14 18:42:49.109397+00:00
deletion_date: 2045-12-31 23:23:23.232323+00:00
- model: analysis.analysis
pk: ded15870-8986-4d5b-b924-ef9036b2e17e
fields:
created: 2024-05-14 19:17:13.442351+00:00
deletion_date: 2024-11-10 19:18:13.839491+00:00
deletion_date: 2045-12-31 23:23:23.232323+00:00
ended: 2024-05-14 19:18:13.839482+00:00
errors: []
inputs:
Expand Down Expand Up @@ -10294,7 +10294,6 @@
bmd: 13.190689586371025
cov: []
dof: 36.0
max: 0.0
bmdl: 9.824944175804669
bmdu: -9999.0
litter:
Expand Down Expand Up @@ -10855,7 +10854,6 @@
- 0.995
- 0.9973333333333333
fixed_lsc: 11.692307692307692
obs_chi_sq: 0.0
parameters:
- 0.144138836294475
- -4.7767358236974005
Expand Down Expand Up @@ -10956,7 +10954,6 @@
bmd: 13.190689586371025
cov: []
dof: 36.0
max: 0.0
bmdl: 9.824944175804765
bmdu: -9999.0
litter:
Expand Down Expand Up @@ -11517,7 +11514,6 @@
- 0.995
- 0.9973333333333333
fixed_lsc: 11.692307692307692
obs_chi_sq: 0.0
parameters:
- 0.144138836294475
- -4.7767358236974005
Expand Down Expand Up @@ -11618,7 +11614,6 @@
bmd: 12.951178803705256
cov: []
dof: 35.0
max: 0.0
bmdl: 9.646361865829302
bmdu: -9999.0
litter:
Expand Down Expand Up @@ -12179,7 +12174,6 @@
- 0.994
- 0.996
fixed_lsc: 11.692307692307692
obs_chi_sq: 0.0
parameters:
- 0.08472920680181548
- -4.1096589164749755
Expand Down Expand Up @@ -12280,7 +12274,6 @@
bmd: 12.951182313338903
cov: []
dof: 35.0
max: 0.0
bmdl: 9.646362099673082
bmdu: -9999.0
litter:
Expand Down Expand Up @@ -12841,7 +12834,6 @@
- 0.999
- 0.9996666666666667
fixed_lsc: 11.692307692307692
obs_chi_sq: 0.0
parameters:
- 0.08472962434038567
- -4.1096619680341115
Expand Down Expand Up @@ -14548,6 +14540,217 @@
deletion_date: null
starred: false
collections: [1]
- model: analysis.analysis
pk: 1b4360dd-27ae-46f1-ad7e-45796d44be8c
fields:
password: 8t47uf4epmuf
inputs:
analysis_name: should be deleted (expired)
dataset_options:
- dataset_id: 0
degree: 3
enabled: true
dataset_type: D
datasets:
- doses:
- 0
- 50
- 100
- 200
- 400
dtype: D
incidences:
- 0
- 0
- 1
- 4
- 11
metadata:
dose_name: Dose
dose_units: ''
id: 0
name: 'Dataset #1'
response_name: Incidence
response_units: ''
ns:
- 20
- 20
- 20
- 20
- 20
models:
bayesian:
- model: Multistage
prior_weight: 1
frequentist_restricted:
- LogLogistic
frequentist_unrestricted:
- LogProbit
options:
- bmr_type: 1
bmr_value: 0.1
confidence_level: 0.95
recommender:
enabled: true
recommend_questionable: false
recommend_viable: true
rules:
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: gof
threshold: 0.1
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: dof_zero
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: high_bmd
threshold: 1
- enabled_continuous: false
enabled_dichotomous: false
enabled_nested: false
failure_bin: 1
rule_class: warnings
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: high_bmdl
threshold: 1
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: roi_large
threshold: 2
- enabled_continuous: false
enabled_dichotomous: false
enabled_nested: false
failure_bin: 1
rule_class: gof_cancer
threshold: 0.05
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 2
rule_class: aic_missing
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 2
rule_class: bmd_missing
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 2
rule_class: roi_missing
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 2
rule_class: bmdl_missing
threshold: null
- enabled_continuous: false
enabled_dichotomous: false
enabled_nested: false
failure_bin: 1
rule_class: bmdu_missing
threshold: null
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: low_bmd_fail
threshold: 10
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: low_bmd_warn
threshold: 3
- enabled_continuous: true
enabled_dichotomous: false
enabled_nested: false
failure_bin: 1
rule_class: variance_fit
threshold: 0.05
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: low_bmdl_fail
threshold: 10
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: low_bmdl_warn
threshold: 3
- enabled_continuous: false
enabled_dichotomous: false
enabled_nested: false
failure_bin: 1
rule_class: variance_type
threshold: 0.05
- enabled_continuous: true
enabled_dichotomous: false
enabled_nested: false
failure_bin: 0
rule_class: control_stdev_fit
threshold: 1.5
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 1
rule_class: bmd_bmdl_ratio_fail
threshold: 20
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: bmd_bmdl_ratio_warn
threshold: 3
- enabled_continuous: true
enabled_dichotomous: true
enabled_nested: true
failure_bin: 0
rule_class: control_residual_high
threshold: 2
sufficiently_close_bmdl: 3
outputs: {}
errors: []
created: 2024-08-22 01:23:45.123456+00:00
last_updated: 2024-08-22 01:23:45.123456+00:00
started: 2024-08-22 01:23:45.123456+00:00
ended: 2024-08-22 01:23:45.123456+00:00
deletion_date: 2024-08-22 01:23:45.123456+00:00
starred: false
collections: []
- model: analysis.analysis
pk: bb5ada91-8f32-4a24-aedf-dcecbe5044f6
fields:
password: u1c1ekxgu1uq
inputs: {}
outputs: {}
errors: []
created: 2024-08-22 01:23:45.123456+00:00
last_updated: 2024-08-22 01:23:45.123456+00:00
started: 2024-08-22 01:23:45.123456+00:00
ended: null
deletion_date: null
starred: false
collections: []
- model: analysis.collection
pk: 1
fields:
Expand Down

0 comments on commit 62408c8

Please sign in to comment.