Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/interpcore/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def __init__(
Parameters
----------
path_to_src_folder : str
path where the input cloud points are stored
path where the input cloud points are stored. Also a single
file is accepted.
path_to_dest_mesh : str
path to the mechanical mesh file
config : InterpolationConfig
Expand Down Expand Up @@ -51,16 +52,9 @@ def __init__(
# parse all value files to interpolate
src_values = {}

# raise an error if folder does not exist or is empty
if not os.path.exists(path_to_src_folder):
raise FileNotFoundError(
f"Source folder {path_to_src_folder} does not exist."
)
if len(os.listdir(path_to_src_folder)) == 0:
raise FileNotFoundError(f"Source folder {path_to_src_folder} is empty.")

for file in os.listdir(path_to_src_folder):
file_path = Path(path_to_src_folder, file)
# allow also a file
if os.path.isfile(path_to_src_folder):
file_path = Path(path_to_src_folder)
name = file_path.stem
src_coordinates, values = parse_values(
file_path,
Expand All @@ -69,6 +63,25 @@ def __init__(
n_components=config.num_components,
)
src_values[name] = values
else:
# raise an error if folder does not exist or is empty
if not os.path.exists(path_to_src_folder):
raise FileNotFoundError(
f"Source folder {path_to_src_folder} does not exist."
)
if len(os.listdir(path_to_src_folder)) == 0:
raise FileNotFoundError(f"Source folder {path_to_src_folder} is empty.")

for file in os.listdir(path_to_src_folder):
file_path = Path(path_to_src_folder, file)
name = file_path.stem
src_coordinates, values = parse_values(
file_path,
load_type=config.interpolated_load,
file_idx=file_idx,
n_components=config.num_components,
)
src_values[name] = values

self.src_values = src_values

Expand Down
1 change: 1 addition & 0 deletions tests/test_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def create_sample_htc_files(temp_dir):
class TestInterpolator:
"""Tests for Interpolator class"""


def test_initialization_with_valid_inputs(
self, create_sample_mesh_files, sample_config_heat_flux
):
Expand Down
Loading