From 4650234872259658359a667b0bb58ce392fdc83a Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:03:15 +0000 Subject: [PATCH] style: format code with isort and Yapf This commit fixes the style issues introduced in 624133b according to the output from isort and Yapf. Details: None --- tests/test_hsf.py | 86 ++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/tests/test_hsf.py b/tests/test_hsf.py index fb33221..d73552f 100644 --- a/tests/test_hsf.py +++ b/tests/test_hsf.py @@ -59,14 +59,22 @@ def config(models_path): "execution_providers": [ [ "CUDAExecutionProvider", - {"device_id": 0, "gpu_mem_limit": 2147483648}, + { + "device_id": 0, + "gpu_mem_limit": 2147483648 + }, ], "CPUExecutionProvider", ], - "batch_size": 1, + "batch_size": + 1, }, }, - "roiloc": {"roi": "hippocampus", "contrast": "t2", "margin": [2, 0, 2]}, + "roiloc": { + "roi": "hippocampus", + "contrast": "t2", + "margin": [2, 0, 2] + }, "augmentation": { "flip": { "axes": ["LR"], @@ -89,18 +97,24 @@ def config(models_path): "multispectrality": { "pattern": None, "same_space": True, - "registration": {"type_of_transform": "AffineFast"}, + "registration": { + "type_of_transform": "AffineFast" + }, }, "segmentation": { "ca_mode": "1/2/3", "models_path": str(models_path), "models": { "model.onnx": { - "url": "https://zenodo.org/record/6457484/files/arunet_3.0.0_single.onnx?download=1", + "url": + "https://zenodo.org/record/6457484/files/arunet_3.0.0_single.onnx?download=1", "xxh3_64": "71edec9011f7f304", } }, - "segmentation": {"test_time_augmentation": True, "test_time_num_aug": 5}, + "segmentation": { + "test_time_augmentation": True, + "test_time_num_aug": 5 + }, }, } @@ -112,9 +126,9 @@ def deepsparse_inference_engines(models_path): """Tests that models can be loaded using DeepSparse""" settings = DictConfig({"num_cores": 0, "batch_size": 2}) - engines = hsf.engines.get_inference_engines( - models_path, engine_name="deepsparse", engine_settings=settings - ) + engines = hsf.engines.get_inference_engines(models_path, + engine_name="deepsparse", + engine_settings=settings) return list(engines) @@ -157,13 +171,16 @@ def test_roiloc(models_path): mri, mask = hsf.roiloc_wrapper.get_mri(mris[0], mask_pattern="mask.nii.gz") assert isinstance(mask, ants.ANTsImage) - mri, mask = hsf.roiloc_wrapper.get_mri(mris[0], mask_pattern="no_mask.nii.gz") + mri, mask = hsf.roiloc_wrapper.get_mri(mris[0], + mask_pattern="no_mask.nii.gz") assert isinstance(mri, ants.ANTsImage) assert mask is None - _, right, left = hsf.roiloc_wrapper.get_hippocampi( - mri, {"contrast": "t2", "margin": [2, 0, 2], "roi": "hippocampus"}, mask - ) + _, right, left = hsf.roiloc_wrapper.get_hippocampi(mri, { + "contrast": "t2", + "margin": [2, 0, 2], + "roi": "hippocampus" + }, mask) assert isinstance(right, ants.ANTsImage) assert isinstance(left, ants.ANTsImage) @@ -195,33 +212,40 @@ def test_segment(models_path, config, deepsparse_inference_engines): def test_multispectrality(models_path): """Tests that we can co-locate hippocampi in another contrast.""" - config = DictConfig( - { - "files": {"output_dir": str(models_path)}, - "multispectrality": { - "pattern": "sub0_tse.nii.gz", - "same_space": False, - "registration": {"type_of_transform": "AffineFast"}, + config = DictConfig({ + "files": { + "output_dir": str(models_path) + }, + "multispectrality": { + "pattern": "sub0_tse.nii.gz", + "same_space": False, + "registration": { + "type_of_transform": "AffineFast" }, - } - ) + }, + }) - mri = hsf.roiloc_wrapper.load_from_config(models_path, "sub0_tse.nii.gz")[0] - second_contrast = hsf.multispectrality.get_second_contrast(mri, "sub0_tse.nii.gz") + mri = hsf.roiloc_wrapper.load_from_config(models_path, + "sub0_tse.nii.gz")[0] + second_contrast = hsf.multispectrality.get_second_contrast( + mri, "sub0_tse.nii.gz") registered = hsf.multispectrality.register( - mri, second_contrast, DictConfig({"multispectrality": {"same_space": True}}) - ) + mri, second_contrast, + DictConfig({"multispectrality": { + "same_space": True + }})) registered = hsf.multispectrality.register(mri, second_contrast, config) img = ants.image_read(str(mri), reorient="LPI") - locator, _, _ = hsf.roiloc_wrapper.get_hippocampi( - img, {"contrast": "t2", "margin": [2, 0, 2], "roi": "hippocampus"}, None - ) + locator, _, _ = hsf.roiloc_wrapper.get_hippocampi(img, { + "contrast": "t2", + "margin": [2, 0, 2], + "roi": "hippocampus" + }, None) _, _ = hsf.multispectrality.get_additional_hippocampi( - mri, registered, locator, config - ) + mri, registered, locator, config) def test_uncertainty():