-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update convert model units to infer model resolution (#72)
* Update convert model units to estimate ds and dt * Add docstrings to convert model units task * Add tests for convert model units * Move conversions to separate methods * Clean up docstring table * Fix centroid conversions
- Loading branch information
1 parent
f03c17e
commit ef56271
Showing
2 changed files
with
257 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/arcade_collection/output/test_convert_model_units.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import random | ||
import unittest | ||
|
||
from arcade_collection.output.convert_model_units import ( | ||
estimate_spatial_resolution, | ||
estimate_temporal_resolution, | ||
) | ||
|
||
|
||
class TestExtractVoxelContours(unittest.TestCase): | ||
def test_estimate_temporal_resolution_missing_temporal_key(self): | ||
self.assertEqual(1, estimate_temporal_resolution("")) | ||
self.assertEqual(1, estimate_temporal_resolution("A")) | ||
self.assertEqual(1, estimate_temporal_resolution("A_B")) | ||
self.assertEqual(1, estimate_temporal_resolution("A_B_C")) | ||
|
||
def test_estimate_temporal_resolution_valid_temporal_key(self): | ||
dt = int(random.random() * 10) | ||
dt_key = f"DT{dt:03d}" | ||
|
||
self.assertEqual(dt / 60, estimate_temporal_resolution(f"{dt_key}_B_C")) | ||
self.assertEqual(dt / 60, estimate_temporal_resolution(f"A_{dt_key}_C")) | ||
self.assertEqual(dt / 60, estimate_temporal_resolution(f"A_B_{dt_key}")) | ||
|
||
def test_estimate_temporal_resolution_invalid_temporal_key(self): | ||
dt = int(random.random() * 10) | ||
dt_key = f"DT{dt:03d}x" | ||
|
||
self.assertEqual(1, estimate_temporal_resolution(f"{dt_key}_B_C")) | ||
self.assertEqual(1, estimate_temporal_resolution(f"A_{dt_key}_C")) | ||
self.assertEqual(1, estimate_temporal_resolution(f"A_B_{dt_key}")) | ||
|
||
def test_estimate_spatial_resolution_missing_spatial_key(self): | ||
self.assertEqual(1, estimate_spatial_resolution("")) | ||
self.assertEqual(1, estimate_spatial_resolution("A")) | ||
self.assertEqual(1, estimate_spatial_resolution("A_B")) | ||
self.assertEqual(1, estimate_spatial_resolution("A_B_C")) | ||
|
||
def test_estimate_spatial_resolution_valid_spatial_key(self): | ||
ds = int(random.random() * 10) | ||
ds_key = f"DS{ds:03d}" | ||
|
||
self.assertEqual(ds, estimate_spatial_resolution(f"{ds_key}_B_C")) | ||
self.assertEqual(ds, estimate_spatial_resolution(f"A_{ds_key}_C")) | ||
self.assertEqual(ds, estimate_spatial_resolution(f"A_B_{ds_key}")) | ||
|
||
def test_estimate_spatial_resolution_invalid_spatiall_key(self): | ||
ds = int(random.random() * 10) | ||
ds_key = f"DS{ds:03d}x" | ||
|
||
self.assertEqual(1, estimate_spatial_resolution(f"{ds_key}_B_C")) | ||
self.assertEqual(1, estimate_spatial_resolution(f"A_{ds_key}_C")) | ||
self.assertEqual(1, estimate_spatial_resolution(f"A_B_{ds_key}")) |