Skip to content

Commit

Permalink
Use os.path.join to create file names.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzwanenburg committed Apr 4, 2024
1 parent 6988ee5 commit 4b9cac3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions test/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ def test_xml_configurations(tmp_path):
mask.text = str(os.path.join(CURRENT_DIR, "data", "sts_images"))

# Save as temporary xml file.
tree.write(tmp_path / "temp_test_config_data.xml")
tree.write(os.path.join(tmp_path, "temp_test_config_data.xml"))

data = extract_features(
write_features=False,
export_features=True,
image=str(tmp_path / "temp_test_config_data.xml"),
image=os.path.join(tmp_path, "temp_test_config_data.xml"),
settings=os.path.join(CURRENT_DIR, "data", "configuration_files", "test_config_settings.xml")
)

Expand Down
21 changes: 7 additions & 14 deletions test/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_general_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_general_settings()
Expand Down Expand Up @@ -85,8 +84,7 @@ def test_post_processing_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_post_processing_settings()
Expand Down Expand Up @@ -156,8 +154,7 @@ def test_interpolation_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

# All default settings.
Expand Down Expand Up @@ -263,8 +260,7 @@ def test_perturbation_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_perturbation_settings()
Expand Down Expand Up @@ -334,8 +330,7 @@ def test_mask_resegmentation_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_mask_resegmentation_settings()
Expand Down Expand Up @@ -405,8 +400,7 @@ def test_feature_extraction_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_feature_extraction_settings()
Expand Down Expand Up @@ -479,8 +473,7 @@ def test_image_transformation_settings_configuration(tmp_path):
from mirp.settings.import_config_parameters import create_settings_object
from mirp.settings.generic import SettingsClass

temp_file = tmp_path / "settings.xml"

temp_file = os.path.join(tmp_path, "settings.xml")
get_settings_xml(tmp_path)

settings_definitions = get_image_transformation_settings()
Expand Down
4 changes: 2 additions & 2 deletions test/export_image_and_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_basic_ct_feature_extraction(tmp_path):

extract_features_and_images(
write_features=True,
export_features=True,
export_features=False,
write_images=True,
export_images=False,
write_dir=tmp_path,
Expand All @@ -25,7 +25,7 @@ def test_basic_ct_feature_extraction(tmp_path):
)

# Check that files exist.
file_names = [file for file in os.listdir(tmp_path) if (tmp_path / file).is_file()]
file_names = [file for file in os.listdir(tmp_path) if os.path.isfile(os.path.join(tmp_path, file))]

assert len(file_names) == 3
assert len([file for file in file_names if file.endswith(".csv")]) == 1
Expand Down
2 changes: 1 addition & 1 deletion test/import_image_and_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def test_failure_multiple_image_and_mask_import_data_xml(tmp_path):
from xml.etree import ElementTree as ElemTree
from mirp import get_data_xml

target_file = str(tmp_path / "data.xml")
target_file = os.path.join(tmp_path, "data.xml")

# Start with a clean slate.
if os.path.exists(target_file):
Expand Down
5 changes: 3 additions & 2 deletions test/read_image_and_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,11 @@ def test_read_dicom_image_and_mask_data_xml(tmp_path):
mask.text = str(os.path.join(CURRENT_DIR, "data", "sts_images"))

# Save as temporary xml file.
tree.write(tmp_path / "temp_test_config_data.xml")
file = os.path.join(tmp_path, "temp_test_config_data.xml")
tree.write(file)

image_list = import_image_and_mask(
image=str(tmp_path / "temp_test_config_data.xml")
image=file
)

image, roi_list = read_image_and_masks(image=image_list[0])
Expand Down
4 changes: 2 additions & 2 deletions test/xml_file_copy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def test_copy_settings_xml(tmp_path):
target_file = tmp_path / "settings.xml"
target_file = os.path.join(tmp_path, "settings.xml")

# Start with a clean slate.
if os.path.exists(target_file):
Expand All @@ -20,7 +20,7 @@ def test_copy_settings_xml(tmp_path):


def test_copy_data_xml(tmp_path):
target_file = tmp_path / "data.xml"
target_file = os.path.join(tmp_path, "data.xml")

# Start with a clean slate.
if os.path.exists(target_file):
Expand Down

0 comments on commit 4b9cac3

Please sign in to comment.