From ee8635556891d4cf5bb5053f53c484a1b564f2ae Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Wed, 28 May 2025 12:48:45 +1000 Subject: [PATCH 1/3] fix: hide surfe warning --- LoopStructural/interpolators/__init__.py | 1 - LoopStructural/interpolators/_interpolator_factory.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LoopStructural/interpolators/__init__.py b/LoopStructural/interpolators/__init__.py index 7fdc3ade..66713047 100644 --- a/LoopStructural/interpolators/__init__.py +++ b/LoopStructural/interpolators/__init__.py @@ -83,7 +83,6 @@ class InterpolatorType(IntEnum): try: from ..interpolators._surfe_wrapper import SurfeRBFInterpolator except ImportError: - logger.warning("Surfe is not installed, SurfeRBFInterpolator will not be available") SurfeRBFInterpolator = None interpolator_map = { InterpolatorType.BASE: GeologicalInterpolator, diff --git a/LoopStructural/interpolators/_interpolator_factory.py b/LoopStructural/interpolators/_interpolator_factory.py index 83fa9472..17ee1d87 100644 --- a/LoopStructural/interpolators/_interpolator_factory.py +++ b/LoopStructural/interpolators/_interpolator_factory.py @@ -39,6 +39,8 @@ def create_interpolator( element_volume=element_volume, buffer=buffer, ) + if interpolator_map.get(interpolatortype) is None: + raise ValueError(f"Interpolator type {interpolatortype} is not supported or available, please choose another interpolator type.") return interpolator_map[interpolatortype](support) @staticmethod From 7033da976d28d96e5cfeefd438d3405d7d4f353b Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Wed, 28 May 2025 12:53:18 +1000 Subject: [PATCH 2/3] fix: hide processor import error until its used --- LoopStructural/modelling/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/LoopStructural/modelling/__init__.py b/LoopStructural/modelling/__init__.py index 4e3e30d0..c25e12f0 100644 --- a/LoopStructural/modelling/__init__.py +++ b/LoopStructural/modelling/__init__.py @@ -22,6 +22,14 @@ try: from ..modelling.input.project_file import LoopProjectfileProcessor except (LoopImportError, ImportError): - logger.warning( - "Cannot use LoopProjectfileProcessor: Loop project file cannot be imported, try installing LoopProjectFile" - ) + class LoopProjectfileProcessor(ProcessInputData): + """ + Dummy class to handle the case where LoopProjectFile is not installed. + This will raise a warning when used. + """ + + def __init__(self, *args, **kwargs): + raise LoopImportError( + "LoopProjectFile cannot be imported. Please install LoopProjectFile." + ) + From 9bc025edcd5e7be6b1211479f216d03f2bbc04a4 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Wed, 28 May 2025 12:54:49 +1000 Subject: [PATCH 3/3] fix: change surfe import behaviour warning --- LoopStructural/interpolators/__init__.py | 11 ++++++++++- LoopStructural/interpolators/_interpolator_factory.py | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/LoopStructural/interpolators/__init__.py b/LoopStructural/interpolators/__init__.py index 66713047..56e68480 100644 --- a/LoopStructural/interpolators/__init__.py +++ b/LoopStructural/interpolators/__init__.py @@ -83,7 +83,16 @@ class InterpolatorType(IntEnum): try: from ..interpolators._surfe_wrapper import SurfeRBFInterpolator except ImportError: - SurfeRBFInterpolator = None + class SurfeRBFInterpolator(GeologicalInterpolator): + """ + Dummy class to handle the case where Surfe is not installed. + This will raise a warning when used. + """ + + def __init__(self, *args, **kwargs): + raise ImportError( + "Surfe cannot be imported. Please install Surfe. pip install surfe/ conda install -c loop3d surfe" + ) interpolator_map = { InterpolatorType.BASE: GeologicalInterpolator, InterpolatorType.BASE_DISCRETE: DiscreteInterpolator, diff --git a/LoopStructural/interpolators/_interpolator_factory.py b/LoopStructural/interpolators/_interpolator_factory.py index 17ee1d87..83fa9472 100644 --- a/LoopStructural/interpolators/_interpolator_factory.py +++ b/LoopStructural/interpolators/_interpolator_factory.py @@ -39,8 +39,6 @@ def create_interpolator( element_volume=element_volume, buffer=buffer, ) - if interpolator_map.get(interpolatortype) is None: - raise ValueError(f"Interpolator type {interpolatortype} is not supported or available, please choose another interpolator type.") return interpolator_map[interpolatortype](support) @staticmethod