Skip to content

Commit 65cb242

Browse files
Add compatibility package
1 parent 03a270f commit 65cb242

7 files changed

Lines changed: 33 additions & 13 deletions

File tree

FoldOptLib/__init__.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
# from .fold_modelling import FoldModel, BaseFoldFrameBuilder
2-
from .helper import _helper, utils
3-
from .input import CheckInputData, InputDataProcessor
4-
from .objective_functions import GeologicalKnowledgeFunctions, VonMisesFisher, LeastSquaresFunctions, \
5-
loglikelihood_fourier_series, loglikelihood_axial_surface, gaussian_log_likelihood, loglikelihood, \
6-
is_axial_plane_compatible
7-
from .optimisers import FourierSeriesOptimiser, AxialSurfaceOptimiser
8-
from .splot import SPlotProcessor
9-
from .ipywidgets_interface import create_value_widgets, on_add_button_click, on_constraint_change, \
10-
on_sub_constraint_change, display_dict_selection
1+
"""FoldOptLib package."""
2+
from .version import __version__
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Compatibility wrapper to support legacy import paths used in tests.
2+
# Re-export objects from the main package modules.
3+
# Avoid importing heavy modules at import time. Instead expose them lazily by
4+
# referencing the corresponding modules from the main package when accessed.
5+
from importlib import import_module
6+
7+
8+
def __getattr__(name):
9+
return import_module(f"FoldOptLib.{name}")
10+
11+
__all__ = []
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ...input import *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ...input.input_data_checker import *

FoldOptLib/helper/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
from ._helper import *
1+
# Import helper modules. Some of these rely on optional dependencies from
2+
# LoopStructural. To allow using parts of this package without those
3+
# heavy dependencies, guard the imports with try/except blocks.
4+
try:
5+
from ._helper import *
6+
except Exception: # pragma: no cover - optional dependency may be missing
7+
pass
8+
29
from .utils import *

FoldOptLib/input/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
from .input_data_checker import CheckInputData
2-
from .input_data_processor import InputDataProcessor
2+
3+
# Import InputDataProcessor lazily so that optional heavy dependencies used in
4+
# this module do not interfere with lightweight parts of the package such as the
5+
# tests for ``CheckInputData``. This avoids importing ``helper._helper`` at
6+
# package import time.
7+
try:
8+
from .input_data_processor import InputDataProcessor
9+
except Exception: # pragma: no cover - optional dependency may be missing
10+
InputDataProcessor = None

FoldOptLib/input/input_data_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def check_bounding_box(self):
117117
if self.bounding_box.size == 0:
118118
raise ValueError("bounding_box array is empty.")
119119
# check if the bounding box has the correct format
120-
if not len(self.bounding_box[0]) == 3 and not len(self.bounding_box[1]) == 3:
120+
if len(self.bounding_box[0]) != 3 or len(self.bounding_box[1]) != 3:
121121
raise ValueError("Bounding box must have the following format: [[minX, maxX, minY], [maxY, minZ, maxZ]]")
122122

123123
# write a function that checks all the input data

0 commit comments

Comments
 (0)