diff --git a/FoldOptLib/__init__.py b/FoldOptLib/__init__.py index 8b329b4..dc3c6ab 100644 --- a/FoldOptLib/__init__.py +++ b/FoldOptLib/__init__.py @@ -1,10 +1,2 @@ -# from .fold_modelling import FoldModel, BaseFoldFrameBuilder -from .helper import _helper, utils -from .input import CheckInputData, InputDataProcessor -from .objective_functions import GeologicalKnowledgeFunctions, VonMisesFisher, LeastSquaresFunctions, \ - loglikelihood_fourier_series, loglikelihood_axial_surface, gaussian_log_likelihood, loglikelihood, \ - is_axial_plane_compatible -from .optimisers import FourierSeriesOptimiser, AxialSurfaceOptimiser -from .splot import SPlotProcessor -from .ipywidgets_interface import create_value_widgets, on_add_button_click, on_constraint_change, \ - on_sub_constraint_change, display_dict_selection +"""FoldOptLib package.""" +from .version import __version__ diff --git a/FoldOptLib/fold_modelling_plugin/__init__.py b/FoldOptLib/fold_modelling_plugin/__init__.py new file mode 100644 index 0000000..4aef8da --- /dev/null +++ b/FoldOptLib/fold_modelling_plugin/__init__.py @@ -0,0 +1,11 @@ +# Compatibility wrapper to support legacy import paths used in tests. +# Re-export objects from the main package modules. +# Avoid importing heavy modules at import time. Instead expose them lazily by +# referencing the corresponding modules from the main package when accessed. +from importlib import import_module + + +def __getattr__(name): + return import_module(f"FoldOptLib.{name}") + +__all__ = [] diff --git a/FoldOptLib/fold_modelling_plugin/input/__init__.py b/FoldOptLib/fold_modelling_plugin/input/__init__.py new file mode 100644 index 0000000..84d2cf5 --- /dev/null +++ b/FoldOptLib/fold_modelling_plugin/input/__init__.py @@ -0,0 +1 @@ +from ...input import * diff --git a/FoldOptLib/fold_modelling_plugin/input/input_data_checker.py b/FoldOptLib/fold_modelling_plugin/input/input_data_checker.py new file mode 100644 index 0000000..fca4799 --- /dev/null +++ b/FoldOptLib/fold_modelling_plugin/input/input_data_checker.py @@ -0,0 +1 @@ +from ...input.input_data_checker import * diff --git a/FoldOptLib/helper/__init__.py b/FoldOptLib/helper/__init__.py index c6872dd..4cf59bd 100644 --- a/FoldOptLib/helper/__init__.py +++ b/FoldOptLib/helper/__init__.py @@ -1,2 +1,9 @@ -from ._helper import * +# Import helper modules. Some of these rely on optional dependencies from +# LoopStructural. To allow using parts of this package without those +# heavy dependencies, guard the imports with try/except blocks. +try: + from ._helper import * +except Exception: # pragma: no cover - optional dependency may be missing + pass + from .utils import * diff --git a/FoldOptLib/input/__init__.py b/FoldOptLib/input/__init__.py index 17fe0f4..9264c72 100644 --- a/FoldOptLib/input/__init__.py +++ b/FoldOptLib/input/__init__.py @@ -1,2 +1,10 @@ from .input_data_checker import CheckInputData -from .input_data_processor import InputDataProcessor + +# Import InputDataProcessor lazily so that optional heavy dependencies used in +# this module do not interfere with lightweight parts of the package such as the +# tests for ``CheckInputData``. This avoids importing ``helper._helper`` at +# package import time. +try: + from .input_data_processor import InputDataProcessor +except Exception: # pragma: no cover - optional dependency may be missing + InputDataProcessor = None diff --git a/FoldOptLib/input/input_data_checker.py b/FoldOptLib/input/input_data_checker.py index 2df529f..68ff5c9 100644 --- a/FoldOptLib/input/input_data_checker.py +++ b/FoldOptLib/input/input_data_checker.py @@ -117,7 +117,7 @@ def check_bounding_box(self): if self.bounding_box.size == 0: raise ValueError("bounding_box array is empty.") # check if the bounding box has the correct format - if not len(self.bounding_box[0]) == 3 and not len(self.bounding_box[1]) == 3: + if len(self.bounding_box[0]) != 3 or len(self.bounding_box[1]) != 3: raise ValueError("Bounding box must have the following format: [[minX, maxX, minY], [maxY, minZ, maxZ]]") # write a function that checks all the input data