geolysis 0.6.2__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geolysis/__init__.py +1 -1
- geolysis/bearing_capacity/abc/cohl/__init__.py +25 -21
- geolysis/bearing_capacity/abc/cohl/_core.py +2 -8
- geolysis/bearing_capacity/ubc/__init__.py +17 -14
- geolysis/bearing_capacity/ubc/_core.py +2 -2
- geolysis/foundation.py +8 -3
- geolysis/soil_classifier.py +11 -8
- geolysis/spt.py +57 -40
- geolysis/utils/__init__.py +0 -22
- geolysis/utils/exceptions.py +36 -0
- geolysis/utils/validators.py +37 -16
- {geolysis-0.6.2.dist-info → geolysis-0.7.1.dist-info}/METADATA +5 -1
- geolysis-0.7.1.dist-info/RECORD +24 -0
- {geolysis-0.6.2.dist-info → geolysis-0.7.1.dist-info}/WHEEL +1 -1
- geolysis-0.6.2.dist-info/RECORD +0 -23
- {geolysis-0.6.2.dist-info → geolysis-0.7.1.dist-info}/licenses/LICENSE.txt +0 -0
- {geolysis-0.6.2.dist-info → geolysis-0.7.1.dist-info}/top_level.txt +0 -0
geolysis/__init__.py
CHANGED
@@ -3,10 +3,12 @@ allowable bearing capacity calculations using methods like Bowles, Meyerhof,
|
|
3
3
|
and Terzaghi for various foundation types and shapes.
|
4
4
|
"""
|
5
5
|
import enum
|
6
|
+
from codecs import backslashreplace_errors
|
6
7
|
from typing import Optional
|
7
8
|
|
8
9
|
from geolysis.foundation import FoundationType, Shape, create_foundation
|
9
|
-
from geolysis.utils import
|
10
|
+
from geolysis.utils import enum_repr, inf
|
11
|
+
from geolysis.utils.exceptions import EnumErrorMsg
|
10
12
|
|
11
13
|
from ._core import AllowableBearingCapacity
|
12
14
|
from .bowles_abc import BowlesABC4MatFoundation, BowlesABC4PadFoundation
|
@@ -22,6 +24,22 @@ class ABCType(enum.StrEnum):
|
|
22
24
|
TERZAGHI = enum.auto()
|
23
25
|
|
24
26
|
|
27
|
+
abc_classes = {
|
28
|
+
ABCType.BOWLES: {
|
29
|
+
FoundationType.PAD: BowlesABC4PadFoundation,
|
30
|
+
FoundationType.MAT: BowlesABC4MatFoundation,
|
31
|
+
},
|
32
|
+
ABCType.MEYERHOF: {
|
33
|
+
FoundationType.PAD: MeyerhofABC4PadFoundation,
|
34
|
+
FoundationType.MAT: MeyerhofABC4MatFoundation,
|
35
|
+
},
|
36
|
+
ABCType.TERZAGHI: {
|
37
|
+
FoundationType.PAD: TerzaghiABC4PadFoundation,
|
38
|
+
FoundationType.MAT: TerzaghiABC4MatFoundation,
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
|
25
43
|
def create_allowable_bearing_capacity(corrected_spt_n_value: float,
|
26
44
|
tol_settlement: float,
|
27
45
|
depth: float,
|
@@ -81,9 +99,9 @@ def create_allowable_bearing_capacity(corrected_spt_n_value: float,
|
|
81
99
|
:raises ValueError: Raised if an invalid footing ``shape`` is provided.
|
82
100
|
"""
|
83
101
|
|
84
|
-
msg =
|
85
|
-
|
86
|
-
|
102
|
+
msg = EnumErrorMsg(param_name="abc_type",
|
103
|
+
param_value=abc_type,
|
104
|
+
param_type=ABCType)
|
87
105
|
|
88
106
|
if abc_type is None:
|
89
107
|
raise ValueError(msg)
|
@@ -96,9 +114,9 @@ def create_allowable_bearing_capacity(corrected_spt_n_value: float,
|
|
96
114
|
try:
|
97
115
|
foundation_type = FoundationType(str(foundation_type).casefold())
|
98
116
|
except ValueError as e:
|
99
|
-
msg =
|
100
|
-
|
101
|
-
|
117
|
+
msg = EnumErrorMsg(param_name="foundation_type",
|
118
|
+
param_value=foundation_type,
|
119
|
+
param_type=FoundationType)
|
102
120
|
raise ValueError(msg) from e
|
103
121
|
|
104
122
|
# exception from create_foundation will automaatically propagate
|
@@ -110,20 +128,6 @@ def create_allowable_bearing_capacity(corrected_spt_n_value: float,
|
|
110
128
|
ground_water_level=ground_water_level,
|
111
129
|
foundation_type=foundation_type,
|
112
130
|
shape=shape)
|
113
|
-
abc_classes = {
|
114
|
-
ABCType.BOWLES: {
|
115
|
-
FoundationType.PAD: BowlesABC4PadFoundation,
|
116
|
-
FoundationType.MAT: BowlesABC4MatFoundation,
|
117
|
-
},
|
118
|
-
ABCType.MEYERHOF: {
|
119
|
-
FoundationType.PAD: MeyerhofABC4PadFoundation,
|
120
|
-
FoundationType.MAT: MeyerhofABC4MatFoundation,
|
121
|
-
},
|
122
|
-
ABCType.TERZAGHI: {
|
123
|
-
FoundationType.PAD: TerzaghiABC4PadFoundation,
|
124
|
-
FoundationType.MAT: TerzaghiABC4MatFoundation,
|
125
|
-
}
|
126
|
-
}
|
127
131
|
|
128
132
|
abc_class = abc_classes[abc_type][fnd_size.foundation_type]
|
129
133
|
abc = abc_class(corrected_spt_n_value=corrected_spt_n_value,
|
@@ -1,13 +1,7 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
|
3
3
|
from geolysis.foundation import FoundationSize
|
4
|
-
from geolysis.utils import validators
|
5
|
-
|
6
|
-
|
7
|
-
class SettlementError(ValueError):
|
8
|
-
"""Raised when tolerable settlement is greater than the maximum
|
9
|
-
allowable settlement.
|
10
|
-
"""
|
4
|
+
from geolysis.utils import validators, exceptions as exc
|
11
5
|
|
12
6
|
|
13
7
|
class AllowableBearingCapacity(ABC):
|
@@ -37,7 +31,7 @@ class AllowableBearingCapacity(ABC):
|
|
37
31
|
return self._tol_settlement
|
38
32
|
|
39
33
|
@tol_settlement.setter
|
40
|
-
@validators.le(25.4, exc_type=SettlementError)
|
34
|
+
@validators.le(25.4, exc_type=exc.SettlementError)
|
41
35
|
def tol_settlement(self, tol_settlement: float) -> None:
|
42
36
|
self._tol_settlement = tol_settlement
|
43
37
|
|
@@ -7,7 +7,8 @@ import enum
|
|
7
7
|
from typing import Optional
|
8
8
|
|
9
9
|
from geolysis.foundation import Shape, create_foundation
|
10
|
-
from geolysis.utils import
|
10
|
+
from geolysis.utils import enum_repr
|
11
|
+
from geolysis.utils.exceptions import EnumErrorMsg
|
11
12
|
|
12
13
|
from ._core import UltimateBearingCapacity
|
13
14
|
from .hansen_ubc import HansenUltimateBearingCapacity
|
@@ -34,6 +35,16 @@ class UBCType(enum.StrEnum):
|
|
34
35
|
VESIC = enum.auto()
|
35
36
|
|
36
37
|
|
38
|
+
ubc_classes = {
|
39
|
+
UBCType.HANSEN: HansenUltimateBearingCapacity,
|
40
|
+
UBCType.TERZAGHI: {Shape.STRIP: TerzaghiUBC4StripFooting,
|
41
|
+
Shape.CIRCLE: TerzaghiUBC4CircularFooting,
|
42
|
+
Shape.SQUARE: TerzaghiUBC4SquareFooting,
|
43
|
+
Shape.RECTANGLE: TerzaghiUBC4RectangularFooting},
|
44
|
+
UBCType.VESIC: VesicUltimateBearingCapacity,
|
45
|
+
}
|
46
|
+
|
47
|
+
|
37
48
|
def create_ultimate_bearing_capacity(friction_angle: float,
|
38
49
|
cohesion: float,
|
39
50
|
moist_unit_wgt: float,
|
@@ -43,8 +54,8 @@ def create_ultimate_bearing_capacity(friction_angle: float,
|
|
43
54
|
eccentricity: float = 0.0,
|
44
55
|
ground_water_level: Optional[
|
45
56
|
float] = None,
|
46
|
-
load_angle=0.0,
|
47
|
-
apply_local_shear=False,
|
57
|
+
load_angle: float = 0.0,
|
58
|
+
apply_local_shear: bool = False,
|
48
59
|
shape: Shape | str = Shape.SQUARE,
|
49
60
|
ubc_type: Optional[UBCType | str] = None,
|
50
61
|
) -> UltimateBearingCapacity:
|
@@ -105,9 +116,9 @@ def create_ultimate_bearing_capacity(friction_angle: float,
|
|
105
116
|
:raises ValueError: Raised if an invalid footing shape is provided.
|
106
117
|
"""
|
107
118
|
|
108
|
-
msg =
|
109
|
-
|
110
|
-
|
119
|
+
msg = EnumErrorMsg(param_name="ubc_type",
|
120
|
+
param_value=ubc_type,
|
121
|
+
param_type=UBCType)
|
111
122
|
|
112
123
|
if ubc_type is None:
|
113
124
|
raise ValueError(msg)
|
@@ -125,14 +136,6 @@ def create_ultimate_bearing_capacity(friction_angle: float,
|
|
125
136
|
eccentricity=eccentricity,
|
126
137
|
ground_water_level=ground_water_level,
|
127
138
|
shape=shape)
|
128
|
-
ubc_classes = {
|
129
|
-
UBCType.HANSEN: HansenUltimateBearingCapacity,
|
130
|
-
UBCType.TERZAGHI: {Shape.STRIP: TerzaghiUBC4StripFooting,
|
131
|
-
Shape.CIRCLE: TerzaghiUBC4CircularFooting,
|
132
|
-
Shape.SQUARE: TerzaghiUBC4SquareFooting,
|
133
|
-
Shape.RECTANGLE: TerzaghiUBC4RectangularFooting},
|
134
|
-
UBCType.VESIC: VesicUltimateBearingCapacity,
|
135
|
-
}
|
136
139
|
|
137
140
|
if ubc_type == UBCType.TERZAGHI:
|
138
141
|
ubc_class = ubc_classes[ubc_type][fnd_size.footing_shape]
|
@@ -9,8 +9,8 @@ class UltimateBearingCapacity(ABC):
|
|
9
9
|
cohesion: float,
|
10
10
|
moist_unit_wgt: float,
|
11
11
|
foundation_size: FoundationSize,
|
12
|
-
load_angle=0.0,
|
13
|
-
apply_local_shear=False) -> None:
|
12
|
+
load_angle: float = 0.0,
|
13
|
+
apply_local_shear: bool = False) -> None:
|
14
14
|
r"""
|
15
15
|
:param friction_angle: Internal angle of friction for general shear
|
16
16
|
failure (degrees).
|
geolysis/foundation.py
CHANGED
@@ -4,7 +4,8 @@ import enum
|
|
4
4
|
from abc import ABC, abstractmethod
|
5
5
|
from typing import Optional, TypeVar
|
6
6
|
|
7
|
-
from .utils import
|
7
|
+
from .utils import enum_repr, inf, isclose, validators
|
8
|
+
from .utils.exceptions import EnumErrorMsg, ErrorMsg
|
8
9
|
|
9
10
|
__all__ = ["create_foundation",
|
10
11
|
"FoundationSize",
|
@@ -319,7 +320,9 @@ class FoundationSize:
|
|
319
320
|
"""Returns the :attr:`effective_width`, :attr:`length`, and
|
320
321
|
:attr:`footing_shape` of the foundation footing.
|
321
322
|
"""
|
322
|
-
width, length, shape = self.effective_width,
|
323
|
+
width, length, shape = (self.effective_width,
|
324
|
+
self.length,
|
325
|
+
self.footing_shape)
|
323
326
|
|
324
327
|
if not isclose(width, length) and shape != Shape.STRIP:
|
325
328
|
shape = Shape.RECTANGLE
|
@@ -373,7 +376,9 @@ def create_foundation(depth: float,
|
|
373
376
|
try:
|
374
377
|
shape = Shape(str(shape).casefold())
|
375
378
|
except ValueError as e:
|
376
|
-
msg =
|
379
|
+
msg = EnumErrorMsg(param_name="shape",
|
380
|
+
param_value=shape,
|
381
|
+
param_type=Shape)
|
377
382
|
raise ValueError(msg) from e
|
378
383
|
|
379
384
|
if shape is Shape.STRIP:
|
geolysis/soil_classifier.py
CHANGED
@@ -4,7 +4,8 @@ USCS and AASHTO, based on particle size distribution and Atterberg limits.
|
|
4
4
|
import enum
|
5
5
|
from typing import NamedTuple, Optional, Sequence
|
6
6
|
|
7
|
-
from .utils import
|
7
|
+
from .utils import enum_repr, isclose, round_, validators
|
8
|
+
from .utils.exceptions import EnumErrorMsg, ErrorMsg
|
8
9
|
|
9
10
|
__all__ = ["ClfType",
|
10
11
|
"AtterbergLimits",
|
@@ -220,7 +221,9 @@ class _SizeDistribution:
|
|
220
221
|
Features obtained from the Particle Size Distribution graph.
|
221
222
|
"""
|
222
223
|
|
223
|
-
def __init__(self, d_10: float = 0
|
224
|
+
def __init__(self, d_10: float = 0.0,
|
225
|
+
d_30: float = 0.0,
|
226
|
+
d_60: float = 0.0):
|
224
227
|
self.d_10 = d_10
|
225
228
|
self.d_30 = d_30
|
226
229
|
self.d_60 = d_60
|
@@ -382,7 +385,7 @@ class AASHTO:
|
|
382
385
|
"""
|
383
386
|
|
384
387
|
def __init__(self, atterberg_limits: AtterbergLimits,
|
385
|
-
fines: float, add_group_idx=True):
|
388
|
+
fines: float, add_group_idx: bool = True):
|
386
389
|
"""
|
387
390
|
:param atterberg_limits: Atterberg limits of soil sample.
|
388
391
|
:type atterberg_limits: AtterbergLimits
|
@@ -710,9 +713,9 @@ def create_soil_classifier(liquid_limit: float,
|
|
710
713
|
:raises ValueError: Raises ValueError if ``sand`` is not provided for
|
711
714
|
:class:`USCS` classification.
|
712
715
|
"""
|
713
|
-
msg =
|
714
|
-
|
715
|
-
|
716
|
+
msg = EnumErrorMsg(param_name="clf_type",
|
717
|
+
param_value=clf_type,
|
718
|
+
param_type=ClfType)
|
716
719
|
|
717
720
|
if clf_type is None:
|
718
721
|
raise ValueError(msg)
|
@@ -732,8 +735,8 @@ def create_soil_classifier(liquid_limit: float,
|
|
732
735
|
return clf
|
733
736
|
|
734
737
|
# USCS classification
|
735
|
-
if sand
|
736
|
-
msg = ErrorMsg(
|
738
|
+
if not sand:
|
739
|
+
msg = ErrorMsg("sand must be specified for USCS classification")
|
737
740
|
raise ValueError(msg)
|
738
741
|
|
739
742
|
psd = PSD(fines=fines, sand=sand, d_10=d_10, d_30=d_30, d_60=d_60)
|
geolysis/spt.py
CHANGED
@@ -4,10 +4,10 @@ as well as calculating design N-values.
|
|
4
4
|
"""
|
5
5
|
import enum
|
6
6
|
from abc import abstractmethod
|
7
|
-
from typing import Final, Sequence
|
7
|
+
from typing import Final, Sequence, Literal
|
8
8
|
|
9
|
-
from .utils import
|
10
|
-
|
9
|
+
from .utils import enum_repr, isclose, log10, mean, round_, sqrt, validators
|
10
|
+
from .utils.exceptions import EnumErrorMsg, ErrorMsg
|
11
11
|
|
12
12
|
__all__ = ["SPTNDesign",
|
13
13
|
"HammerType",
|
@@ -35,13 +35,15 @@ class SPTNDesign:
|
|
35
35
|
N-value from the base.
|
36
36
|
"""
|
37
37
|
|
38
|
-
def __init__(self, corrected_spt_n_values: Sequence[float]
|
38
|
+
def __init__(self, corrected_spt_n_values: Sequence[float],
|
39
|
+
method: Literal["min", "avg", "wgt"] = "wgt") -> None:
|
39
40
|
"""
|
40
41
|
:param corrected_spt_n_values: Corrected SPT N-values within the
|
41
42
|
foundation influence zone.
|
42
43
|
:type corrected_spt_n_values: Sequence[float]
|
43
44
|
"""
|
44
45
|
self.corrected_spt_n_values = corrected_spt_n_values
|
46
|
+
self.method = method
|
45
47
|
|
46
48
|
@property
|
47
49
|
def corrected_spt_n_values(self) -> Sequence[float]:
|
@@ -53,44 +55,58 @@ class SPTNDesign:
|
|
53
55
|
def corrected_spt_n_values(self, val: Sequence[float]) -> None:
|
54
56
|
self._corrected_spt_n_values = val
|
55
57
|
|
56
|
-
@
|
57
|
-
def
|
58
|
-
|
59
|
-
foundation influence zone.
|
60
|
-
"""
|
61
|
-
return mean(self.corrected_spt_n_values)
|
62
|
-
|
63
|
-
@round_(ndigits=1)
|
64
|
-
def minimum_spt_n_design(self):
|
65
|
-
"""The lowest SPT N-value within the influence zone can be taken as the
|
66
|
-
:math:`N_{design}` as suggested by ``Terzaghi & Peck (1948)``.
|
67
|
-
"""
|
68
|
-
return min(self.corrected_spt_n_values)
|
58
|
+
@staticmethod
|
59
|
+
def _avg_spt_n_design(vals) -> float:
|
60
|
+
return mean(vals)
|
69
61
|
|
70
|
-
@
|
71
|
-
def
|
72
|
-
|
73
|
-
within the foundation influence zone.
|
62
|
+
@staticmethod
|
63
|
+
def _min_spt_n_design(vals):
|
64
|
+
return min(vals)
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
.. math::
|
78
|
-
|
79
|
-
N_{design} = \dfrac{\sum_{i=1}^{n} \frac{N_i}{i^2}}
|
80
|
-
{\sum_{i=1}^{n}\frac{1}{i^2}}
|
81
|
-
"""
|
66
|
+
@staticmethod
|
67
|
+
def _wgt_spt_n_design(vals):
|
82
68
|
|
83
69
|
sum_total = 0.0
|
84
70
|
sum_wgts = 0.0
|
85
71
|
|
86
|
-
for i, corr_spt_n_val in enumerate(
|
87
|
-
start=1):
|
72
|
+
for i, corr_spt_n_val in enumerate(vals, start=1):
|
88
73
|
wgt = 1 / i ** 2
|
89
74
|
sum_total += wgt * corr_spt_n_val
|
90
75
|
sum_wgts += wgt
|
91
76
|
|
92
77
|
return sum_total / sum_wgts
|
93
78
|
|
79
|
+
@round_(ndigits=1)
|
80
|
+
def n_design(self):
|
81
|
+
r"""Calculates the SPT N-design within the foundation influence zone.
|
82
|
+
|
83
|
+
If ``method="min"``, it returns the minimum N-value within the foundation
|
84
|
+
influence zone as the SPT N-design value. This approach was suggested
|
85
|
+
by ``Terzaghi & Peck (1948)``.
|
86
|
+
|
87
|
+
if ``method="avg"``, it returns the average N-value within the foundation
|
88
|
+
influence zone as the SPT N-design value.
|
89
|
+
|
90
|
+
if ``method="wgt"``, it returns the weighted average N-value within the
|
91
|
+
foundation influence zone as the SPT N-design value.
|
92
|
+
|
93
|
+
:Equation:
|
94
|
+
|
95
|
+
.. math::
|
96
|
+
|
97
|
+
N_{design} = \dfrac{\sum_{i=1}^{n} \frac{N_i}{i^2}}
|
98
|
+
{\sum_{i=1}^{n}\frac{1}{i^2}}
|
99
|
+
"""
|
100
|
+
if self.method == "min":
|
101
|
+
return self._min_spt_n_design(self.corrected_spt_n_values)
|
102
|
+
elif self.method == "avg":
|
103
|
+
return self._avg_spt_n_design(self.corrected_spt_n_values)
|
104
|
+
elif self.method == "wgt":
|
105
|
+
return self._wgt_spt_n_design(self.corrected_spt_n_values)
|
106
|
+
else:
|
107
|
+
msg = ErrorMsg("method must be 'min', 'avg', or 'wgt'")
|
108
|
+
raise ValueError(msg)
|
109
|
+
|
94
110
|
|
95
111
|
@enum_repr
|
96
112
|
class HammerType(enum.StrEnum):
|
@@ -510,6 +526,13 @@ class OPCType(enum.StrEnum):
|
|
510
526
|
SKEMPTON = enum.auto()
|
511
527
|
|
512
528
|
|
529
|
+
_opctypes = {OPCType.GIBBS: GibbsHoltzOPC,
|
530
|
+
OPCType.BAZARAA: BazaraaPeckOPC,
|
531
|
+
OPCType.PECK: PeckOPC,
|
532
|
+
OPCType.LIAO: LiaoWhitmanOPC,
|
533
|
+
OPCType.SKEMPTON: SkemptonOPC}
|
534
|
+
|
535
|
+
|
513
536
|
def create_overburden_pressure_correction(std_spt_n_value: float, eop,
|
514
537
|
opc_type: OPCType | str = OPCType.GIBBS) -> OPC:
|
515
538
|
"""A factory function that encapsulates the creation of overburden
|
@@ -529,18 +552,12 @@ def create_overburden_pressure_correction(std_spt_n_value: float, eop,
|
|
529
552
|
try:
|
530
553
|
opc_type = OPCType(str(opc_type).casefold())
|
531
554
|
except ValueError as e:
|
532
|
-
msg =
|
533
|
-
|
534
|
-
|
555
|
+
msg = EnumErrorMsg(param_name="opc_type",
|
556
|
+
param_value=opc_type,
|
557
|
+
param_type=OPCType)
|
535
558
|
raise ValueError(msg) from e
|
536
559
|
|
537
|
-
|
538
|
-
OPCType.BAZARAA: BazaraaPeckOPC,
|
539
|
-
OPCType.PECK: PeckOPC,
|
540
|
-
OPCType.LIAO: LiaoWhitmanOPC,
|
541
|
-
OPCType.SKEMPTON: SkemptonOPC}
|
542
|
-
|
543
|
-
opc_class = opc_types[opc_type]
|
560
|
+
opc_class = _opctypes[opc_type]
|
544
561
|
opc_corr = opc_class(std_spt_n_value=std_spt_n_value, eop=eop)
|
545
562
|
|
546
563
|
return opc_corr
|
geolysis/utils/__init__.py
CHANGED
@@ -88,25 +88,3 @@ def round_(ndigits: int | Callable[..., SupportsRound]) -> Callable:
|
|
88
88
|
return wrapper
|
89
89
|
|
90
90
|
return dec
|
91
|
-
|
92
|
-
|
93
|
-
class _ErrorParams(TypedDict):
|
94
|
-
param_name: NotRequired[str]
|
95
|
-
param_value: NotRequired[Any]
|
96
|
-
param_type: NotRequired[Any]
|
97
|
-
|
98
|
-
|
99
|
-
class ErrorMsg(str):
|
100
|
-
|
101
|
-
@staticmethod
|
102
|
-
def __new__(cls, *args, msg: Optional[str] = None,
|
103
|
-
**kw: Unpack[_ErrorParams]):
|
104
|
-
if msg:
|
105
|
-
return super().__new__(cls, msg)
|
106
|
-
|
107
|
-
# Assume kwargs contains values for param_name, param_value,
|
108
|
-
# param_type, if not, KeyError exception is raised
|
109
|
-
|
110
|
-
msg = (f"Invalid value for {kw['param_name']}: {kw['param_value']}, "
|
111
|
-
f"Supported types are: {list(kw['param_type'])}")
|
112
|
-
return super().__new__(cls, msg)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from typing import Unpack, TypedDict, NotRequired, Any, Optional
|
2
|
+
|
3
|
+
|
4
|
+
class _ErrorParams(TypedDict):
|
5
|
+
param_name: NotRequired[str]
|
6
|
+
param_value: NotRequired[Any]
|
7
|
+
param_type: NotRequired[Any]
|
8
|
+
|
9
|
+
|
10
|
+
class ErrorMsg(str):
|
11
|
+
|
12
|
+
@staticmethod
|
13
|
+
def __new__(cls, msg):
|
14
|
+
return super().__new__(cls, msg)
|
15
|
+
|
16
|
+
|
17
|
+
class EnumErrorMsg(ErrorMsg):
|
18
|
+
|
19
|
+
@staticmethod
|
20
|
+
def __new__(cls, *args, msg: Optional[str] = None,
|
21
|
+
**kwargs: Unpack[_ErrorParams]):
|
22
|
+
err_msg = msg if msg else (
|
23
|
+
f"Invalid value for {kwargs['param_name']}: {kwargs['param_value']}, "
|
24
|
+
f"Supported types are: {list(kwargs['param_type'])}")
|
25
|
+
|
26
|
+
return super().__new__(cls, err_msg)
|
27
|
+
|
28
|
+
|
29
|
+
class ValidationError(ValueError):
|
30
|
+
"""Exception raised when a validation error occurs."""
|
31
|
+
|
32
|
+
|
33
|
+
class SettlementError(ValueError):
|
34
|
+
"""Raised when tolerable settlement is greater than the maximum
|
35
|
+
allowable settlement.
|
36
|
+
"""
|
geolysis/utils/validators.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
"""validators"""
|
2
2
|
import operator
|
3
|
-
from typing import Callable, TypeAlias
|
3
|
+
from typing import Callable, TypeAlias, Optional
|
4
|
+
from functools import wraps
|
5
|
+
|
6
|
+
from .exceptions import ValidationError
|
4
7
|
|
5
8
|
Number: TypeAlias = int | float
|
6
9
|
|
@@ -8,8 +11,10 @@ Number: TypeAlias = int | float
|
|
8
11
|
def _num_validator(bound: float, /, *,
|
9
12
|
compare_symbol: str,
|
10
13
|
compare_fn: Callable,
|
11
|
-
exc_type: Callable,
|
14
|
+
exc_type: Callable,
|
15
|
+
err_msg: str):
|
12
16
|
def dec(fn):
|
17
|
+
@wraps(fn)
|
13
18
|
def wrapper(obj, val):
|
14
19
|
if not compare_fn(val, bound):
|
15
20
|
msg = f"{fn.__name__} must be {compare_symbol} {bound}"
|
@@ -24,8 +29,10 @@ def _num_validator(bound: float, /, *,
|
|
24
29
|
def _len_validator(bound: float, /, *,
|
25
30
|
compare_symbol: str,
|
26
31
|
compare_fn: Callable,
|
27
|
-
exc_type: Callable,
|
32
|
+
exc_type: Callable,
|
33
|
+
err_msg: str):
|
28
34
|
def dec(fn):
|
35
|
+
@wraps(fn)
|
29
36
|
def wrapper(obj, val):
|
30
37
|
_len = len(val)
|
31
38
|
if not compare_fn(_len, bound):
|
@@ -38,43 +45,57 @@ def _len_validator(bound: float, /, *,
|
|
38
45
|
return dec
|
39
46
|
|
40
47
|
|
41
|
-
def min_len(m_len: int, /, *,
|
48
|
+
def min_len(m_len: int, /, *,
|
49
|
+
exc_type=ValidationError,
|
50
|
+
err_msg: Optional[str] = None):
|
42
51
|
return _len_validator(m_len, compare_symbol=">=",
|
43
52
|
compare_fn=operator.ge,
|
44
53
|
exc_type=exc_type, err_msg=err_msg)
|
45
54
|
|
46
55
|
|
47
|
-
def lt(val: Number, /, *, exc_type=
|
56
|
+
def lt(val: Number, /, *, exc_type=ValidationError,
|
57
|
+
err_msg: Optional[str] = None):
|
48
58
|
return _num_validator(val, compare_symbol="<",
|
49
59
|
compare_fn=operator.lt,
|
50
|
-
exc_type=exc_type,
|
60
|
+
exc_type=exc_type,
|
61
|
+
err_msg=err_msg)
|
51
62
|
|
52
63
|
|
53
|
-
def le(val: Number, /, *, exc_type=
|
64
|
+
def le(val: Number, /, *, exc_type=ValidationError,
|
65
|
+
err_msg: Optional[str] = None):
|
54
66
|
return _num_validator(val, compare_symbol="<=",
|
55
67
|
compare_fn=operator.le,
|
56
|
-
exc_type=exc_type,
|
68
|
+
exc_type=exc_type,
|
69
|
+
err_msg=err_msg)
|
57
70
|
|
58
71
|
|
59
|
-
def eq(val: Number, /, *, exc_type=
|
72
|
+
def eq(val: Number, /, *, exc_type=ValidationError,
|
73
|
+
err_msg: Optional[str] = None):
|
60
74
|
return _num_validator(val, compare_symbol="==",
|
61
75
|
compare_fn=operator.eq,
|
62
|
-
exc_type=exc_type,
|
76
|
+
exc_type=exc_type,
|
77
|
+
err_msg=err_msg)
|
63
78
|
|
64
79
|
|
65
|
-
def ne(val: Number, /, *, exc_type=
|
80
|
+
def ne(val: Number, /, *, exc_type=ValidationError,
|
81
|
+
err_msg: Optional[str] = None):
|
66
82
|
return _num_validator(val, compare_symbol="!=",
|
67
83
|
compare_fn=operator.ne,
|
68
|
-
exc_type=exc_type,
|
84
|
+
exc_type=exc_type,
|
85
|
+
err_msg=err_msg)
|
69
86
|
|
70
87
|
|
71
|
-
def ge(val: Number, /, *, exc_type=
|
88
|
+
def ge(val: Number, /, *, exc_type=ValidationError,
|
89
|
+
err_msg: Optional[str] = None):
|
72
90
|
return _num_validator(val, compare_symbol=">=",
|
73
91
|
compare_fn=operator.ge,
|
74
|
-
exc_type=exc_type,
|
92
|
+
exc_type=exc_type,
|
93
|
+
err_msg=err_msg)
|
75
94
|
|
76
95
|
|
77
|
-
def gt(val: Number, /, *, exc_type=
|
96
|
+
def gt(val: Number, /, *, exc_type=ValidationError,
|
97
|
+
err_msg: Optional[str] = None):
|
78
98
|
return _num_validator(val, compare_symbol=">",
|
79
99
|
compare_fn=operator.gt,
|
80
|
-
exc_type=exc_type,
|
100
|
+
exc_type=exc_type,
|
101
|
+
err_msg=err_msg)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: geolysis
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.1
|
4
4
|
Summary: geolysis is an opensource software for geotechnical engineering analysis and modeling.
|
5
5
|
Author-email: Patrick Boateng <boatengpato.pb@gmail.com>
|
6
6
|
License: MIT License
|
@@ -97,6 +97,10 @@ Here are brief descriptions of these projects:
|
|
97
97
|
</tr>
|
98
98
|
</table>
|
99
99
|
|
100
|
+
# Microsoft Excel Example
|
101
|
+
|
102
|
+

|
103
|
+
|
100
104
|
## Project Structure
|
101
105
|
|
102
106
|
.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
geolysis/__init__.py,sha256=doEthTEMHHK5V-a9L90VQf2YQ_nWHKbtT0fuyV19j38,122
|
2
|
+
geolysis/foundation.py,sha256=gxI6bLbUrxQNhoKJis5glDysnI6PgqBkMM9m5CQztsg,11695
|
3
|
+
geolysis/soil_classifier.py,sha256=2C-4hpgXNo2DUgXKcokUh3qjAH70qvgOCnxsL_NnmTw,26880
|
4
|
+
geolysis/spt.py,sha256=7C8FPwwUej_YLkLAMMyUVhWYoh9FH4__6g5_G8NSas0,17507
|
5
|
+
geolysis/bearing_capacity/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
geolysis/bearing_capacity/abc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
geolysis/bearing_capacity/abc/cohl/__init__.py,sha256=sWhQJj5klrenbwgaBAWRM23BQCcudZM4Ztwg8auxNw8,5399
|
8
|
+
geolysis/bearing_capacity/abc/cohl/_core.py,sha256=ZQrjK4d89OMNhLRg9PczRpwkT6xiRRcn2sq603Fsobc,1627
|
9
|
+
geolysis/bearing_capacity/abc/cohl/bowles_abc.py,sha256=kUAZWR5exvRNoOB6pXoxmyOiQorPNtnZwBoaXCk9z0I,4096
|
10
|
+
geolysis/bearing_capacity/abc/cohl/meyerhof_abc.py,sha256=3iriC_pQCKRf_4QtDm8163lnKNZUvJ9M7c7ZyRRrID8,4056
|
11
|
+
geolysis/bearing_capacity/abc/cohl/terzaghi_abc.py,sha256=EOGfA7_IM0vCa5gLBaBOiEgop4nKBtghoA5EZC7k9dM,5308
|
12
|
+
geolysis/bearing_capacity/ubc/__init__.py,sha256=Q9VJhjgcz1heFjj0zgvASUFekNS683_BZBfTJsfxPcE,5983
|
13
|
+
geolysis/bearing_capacity/ubc/_core.py,sha256=xia-ygcbjF3a9eVh6hzp61LPVJfHHCiztb1J8_W2apE,6177
|
14
|
+
geolysis/bearing_capacity/ubc/hansen_ubc.py,sha256=exkYLUG4W8AecJVbYC4lnE58KbssVUsjI0lJ7Mu5pqw,7170
|
15
|
+
geolysis/bearing_capacity/ubc/terzaghi_ubc.py,sha256=zoTf2pVTd1zN_6-yuNK9njo-8rn4o3CSccAEiivc2AE,6514
|
16
|
+
geolysis/bearing_capacity/ubc/vesic_ubc.py,sha256=zlFI26tY_L1LCb6T7q4NY4E0pTivdjYyTttp-VcIlvk,7405
|
17
|
+
geolysis/utils/__init__.py,sha256=713rJNWVFLrP4CNon4i-xUf5rF5eA40Ydg-F1UV8o-0,2339
|
18
|
+
geolysis/utils/exceptions.py,sha256=ivuyxqz0B7nmA5sXMfw4o7KPnQHoaGbLHmJCEiCEaAc,929
|
19
|
+
geolysis/utils/validators.py,sha256=g18NIlLaNSIjlBwRLkUQr68qcYnwzo5qcfY5y_GoO1Y,3205
|
20
|
+
geolysis-0.7.1.dist-info/licenses/LICENSE.txt,sha256=ap6sMs3lT7ICbEXBhgihwH1BTCVcjmCQkIkwVnil1Ak,1065
|
21
|
+
geolysis-0.7.1.dist-info/METADATA,sha256=Ul3uVbiX7sIty2eYbxzNuQV0yVH46HLIQwhQARR91JQ,7450
|
22
|
+
geolysis-0.7.1.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
23
|
+
geolysis-0.7.1.dist-info/top_level.txt,sha256=9mnQgOaCRr11dtXff8X-q3FfXjRONd6kHseSy5q2y8g,9
|
24
|
+
geolysis-0.7.1.dist-info/RECORD,,
|
geolysis-0.6.2.dist-info/RECORD
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
geolysis/__init__.py,sha256=alTIUitHv3ycqyUd5oyvqfDXUO18StbWiT2LXd6lF6Q,122
|
2
|
-
geolysis/foundation.py,sha256=bZ0LnONv1xvouhEesbAs9oGTg2YP4d_JEXDPx9Um19c,11528
|
3
|
-
geolysis/soil_classifier.py,sha256=dH1JdmnJpnqxwFRhI19hPkCdCUQaGqEyIyycWOcKVMk,26786
|
4
|
-
geolysis/spt.py,sha256=-9yJwzu2qEMbXogoozvDpwlWA0u6D1aNajgCzcY6ZrA,16901
|
5
|
-
geolysis/bearing_capacity/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
geolysis/bearing_capacity/abc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
geolysis/bearing_capacity/abc/cohl/__init__.py,sha256=VwCd0zm5adeUP3T5lJr6ANzXNp2vaFttT1wtlG5ebpo,5345
|
8
|
-
geolysis/bearing_capacity/abc/cohl/_core.py,sha256=ddyVTCTIqolllOwcX7s-czYO2bPAmKTlkvFAj3LNRqc,1744
|
9
|
-
geolysis/bearing_capacity/abc/cohl/bowles_abc.py,sha256=kUAZWR5exvRNoOB6pXoxmyOiQorPNtnZwBoaXCk9z0I,4096
|
10
|
-
geolysis/bearing_capacity/abc/cohl/meyerhof_abc.py,sha256=3iriC_pQCKRf_4QtDm8163lnKNZUvJ9M7c7ZyRRrID8,4056
|
11
|
-
geolysis/bearing_capacity/abc/cohl/terzaghi_abc.py,sha256=EOGfA7_IM0vCa5gLBaBOiEgop4nKBtghoA5EZC7k9dM,5308
|
12
|
-
geolysis/bearing_capacity/ubc/__init__.py,sha256=7Ud0JbaIBiI0xmw-aRhG9lR6ZT0DMCel7lPtwKCBJNs,5943
|
13
|
-
geolysis/bearing_capacity/ubc/_core.py,sha256=CmhJyGi_GTy4DupX7m-PXlEdVmxZOgc2BVF9owByxOg,6160
|
14
|
-
geolysis/bearing_capacity/ubc/hansen_ubc.py,sha256=exkYLUG4W8AecJVbYC4lnE58KbssVUsjI0lJ7Mu5pqw,7170
|
15
|
-
geolysis/bearing_capacity/ubc/terzaghi_ubc.py,sha256=zoTf2pVTd1zN_6-yuNK9njo-8rn4o3CSccAEiivc2AE,6514
|
16
|
-
geolysis/bearing_capacity/ubc/vesic_ubc.py,sha256=zlFI26tY_L1LCb6T7q4NY4E0pTivdjYyTttp-VcIlvk,7405
|
17
|
-
geolysis/utils/__init__.py,sha256=AY0FHUCElIqveYsB2uGl6OEpaesWVoRIDY0nHejB-0A,2989
|
18
|
-
geolysis/utils/validators.py,sha256=nMZi044cbAcsgiH4yxKDELhIFuUMy7Rn8kgGzXWjEcA,2674
|
19
|
-
geolysis-0.6.2.dist-info/licenses/LICENSE.txt,sha256=ap6sMs3lT7ICbEXBhgihwH1BTCVcjmCQkIkwVnil1Ak,1065
|
20
|
-
geolysis-0.6.2.dist-info/METADATA,sha256=vcECcPdALMlUhaUVhwVJ_C4aMq6X7cm9NrkYeBr0IJo,7368
|
21
|
-
geolysis-0.6.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
22
|
-
geolysis-0.6.2.dist-info/top_level.txt,sha256=9mnQgOaCRr11dtXff8X-q3FfXjRONd6kHseSy5q2y8g,9
|
23
|
-
geolysis-0.6.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|