geolysis 0.2.0__py3-none-any.whl → 0.4.2__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/utils.py CHANGED
@@ -1,106 +1,78 @@
1
- import functools
2
- import math
3
- from math import ceil, exp, isclose, log10
4
- from math import pi as PI
5
- from math import sqrt
6
- from statistics import fmean as mean
7
- from typing import Callable, TypeAlias
8
-
9
- __all__ = [
10
- "deg2rad",
11
- "rad2deg",
12
- "tan",
13
- "cot",
14
- "sin",
15
- "cos",
16
- "arctan",
17
- "round_",
18
- ]
19
-
20
- FloatOrInt: TypeAlias = float | int
21
-
22
-
23
- def deg2rad(__x: FloatOrInt, /) -> float:
24
- """
25
- Convert angle x from degrees to radians.
26
- """
27
- return math.radians(__x)
28
-
29
-
30
- def rad2deg(__x: FloatOrInt, /) -> float:
31
- """
32
- Convert angle x from radians to degrees.
33
- """
34
- return math.degrees(__x)
35
-
36
-
37
- def tan(__x: FloatOrInt, /) -> float:
38
- """
39
- Return the tangent of x (measured in degrees).
40
- """
41
- return math.tan(deg2rad(__x))
42
-
43
-
44
- def cot(__x: FloatOrInt, /) -> float:
45
- """
46
- Return the cotangent of x (measured in degrees).
47
- """
48
- return 1 / tan(__x)
49
-
50
-
51
- def sin(__x: FloatOrInt, /) -> float:
52
- """
53
- Return the sine of x (measured in degrees).
54
- """
55
- return math.sin(deg2rad(__x))
56
-
57
-
58
- def cos(__x: FloatOrInt, /) -> float:
59
- """
60
- Return the cosine of x (measured in degrees).
61
- """
62
- return math.cos(deg2rad(__x))
63
-
64
-
65
- def arctan(__x: FloatOrInt, /) -> float:
66
- """
67
- Return the arc tangent (measured in degrees) of x.
68
- """
69
- return rad2deg(math.atan(__x))
70
-
71
-
72
- def round_(ndigits: int) -> Callable:
73
- """
74
- A decorator that rounds the result of a function to a specified number of
75
- decimal places.
76
-
77
- :param int ndigits: The number of decimal places to round to.
78
-
79
- :return: A decorator that rounds the result of the wrapped function.
80
- :rtype: Callable[..., float]
81
-
82
- :raises TypeError: If precision is not an int.
83
-
84
- .. note::
85
-
86
- This decorator can only be used with functions that return a float or a
87
- datatype that implements ``__round__``.
88
- """
89
-
90
- def dec(
91
- func: Callable[..., float],
92
- /,
93
- *,
94
- ndigits: int,
95
- ) -> Callable[..., float]:
96
- @functools.wraps(func)
97
- def wrapper(*args, **kwargs) -> float:
98
- return round(func(*args, **kwargs), ndigits=ndigits)
99
-
100
- return wrapper
101
-
102
- if isinstance(ndigits, int):
103
- return functools.partial(dec, ndigits=ndigits) # return decorator
104
-
105
- err_msg = "ndigits should be an int."
106
- raise TypeError(err_msg)
1
+ import functools
2
+ import math
3
+ from math import exp, inf, isclose, log10, pi, sqrt
4
+ from statistics import fmean as mean
5
+ from typing import Callable, SupportsRound
6
+
7
+ __all__ = ["inf", "pi", "deg2rad", "rad2deg", "tan", "cot", "sin", "cos",
8
+ "arctan", "round_", "mean", "exp", "isclose", "log10", "sqrt"]
9
+
10
+
11
+ def deg2rad(x: float, /) -> float:
12
+ """Convert angle x from degrees to radians."""
13
+ return math.radians(x)
14
+
15
+
16
+ def rad2deg(x: float, /) -> float:
17
+ """Convert angle x from radians to degrees."""
18
+ return math.degrees(x)
19
+
20
+
21
+ def tan(x: float, /) -> float:
22
+ """Return the tangent of x (measured in degrees)."""
23
+ return math.tan(deg2rad(x))
24
+
25
+
26
+ def cot(x: float, /) -> float:
27
+ """Return the cotangent of x (measured in degrees)."""
28
+ return 1 / tan(x)
29
+
30
+
31
+ def sin(x: float, /) -> float:
32
+ """Return the sine of x (measured in degrees)."""
33
+ return math.sin(deg2rad(x))
34
+
35
+
36
+ def cos(x: float, /) -> float:
37
+ """Return the cosine of x (measured in degrees)."""
38
+ return math.cos(deg2rad(x))
39
+
40
+
41
+ def arctan(x: float, /) -> float:
42
+ """Return the arc tangent (measured in degrees) of x."""
43
+ return rad2deg(math.atan(x))
44
+
45
+
46
+ def round_(ndigits: int | Callable[..., SupportsRound]) -> Callable:
47
+ """A decorator that rounds the result of a callable to a specified number
48
+ of decimal places.
49
+
50
+ The returned value of the callable should support the ``__round__`` dunder
51
+ method and should be a numeric value. ``ndigits`` can either be an int
52
+ which will indicate the number of decimal places to round to or a
53
+ callable. If ``ndigits`` is callable the default decimal places is 2.
54
+
55
+ TypeError is raised when ``ndigits`` is neither an int nor a callable.
56
+ """
57
+
58
+ default_dp = 2
59
+
60
+ def dec(fn) -> Callable[..., float]:
61
+ @functools.wraps(fn)
62
+ def wrapper(*args, **kwargs) -> float:
63
+ dp = ndigits if not callable(ndigits) else default_dp
64
+ res = fn(*args, **kwargs)
65
+ return round(res, ndigits=dp)
66
+
67
+ return wrapper
68
+
69
+ # See if we're being called as @round_ or @round_().
70
+ # We're called with parens.
71
+ if isinstance(ndigits, int):
72
+ return dec
73
+
74
+ # We're called as @round_ without parens.
75
+ if callable(ndigits):
76
+ return dec(ndigits)
77
+
78
+ raise TypeError("ndigits must be an int or a callable")
geolysis/validators.py ADDED
@@ -0,0 +1,54 @@
1
+ import operator
2
+ from typing import Callable, TypeAlias
3
+
4
+
5
+ class _NumberValidator:
6
+ def __init__(self, bound: float,
7
+ compare_op: str,
8
+ compare_fn: Callable,
9
+ exc_type=ValueError,
10
+ err_msg=None) -> None:
11
+ self.bound = bound
12
+ self.compare_op = compare_op
13
+ self.compare_fn = compare_fn
14
+ self.exc_type = exc_type
15
+ self.err_msg = err_msg
16
+
17
+ def __call__(self, fn):
18
+ def wrapper(obj, val):
19
+ if not self.compare_fn(val, self.bound):
20
+ if self.err_msg:
21
+ msg = self.err_msg
22
+ else:
23
+ msg = f"{fn.__name__} must be {self.compare_op} {self.bound}"
24
+ raise self.exc_type(msg)
25
+ return fn(obj, val)
26
+
27
+ return wrapper
28
+
29
+
30
+ Number: TypeAlias = int | float
31
+
32
+
33
+ def lt(val: Number, /, *, exc_type=ValueError, err_msg=None):
34
+ return _NumberValidator(val, "<", operator.lt, exc_type, err_msg)
35
+
36
+
37
+ def le(val: Number, /, *, exc_type=ValueError, err_msg=None):
38
+ return _NumberValidator(val, "<=", operator.le, exc_type, err_msg)
39
+
40
+
41
+ def eq(val: Number, /, *, exc_type=ValueError, err_msg=None):
42
+ return _NumberValidator(val, "==", operator.eq, exc_type, err_msg)
43
+
44
+
45
+ def ne(val: Number, /, *, exc_type=ValueError, err_msg=None):
46
+ return _NumberValidator(val, "!=", operator.ne, exc_type, err_msg)
47
+
48
+
49
+ def ge(val: Number, /, *, exc_type=ValueError, err_msg=None):
50
+ return _NumberValidator(val, ">=", operator.ge, exc_type, err_msg)
51
+
52
+
53
+ def gt(val: Number, /, *, exc_type=ValueError, err_msg=None):
54
+ return _NumberValidator(val, ">", operator.gt, exc_type, err_msg)
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 geolysis
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 geolysis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.2
2
+ Name: geolysis
3
+ Version: 0.4.2
4
+ Summary: geolysis.core is an opensource software for geotechnical engineering analysis and modeling.
5
+ Author-email: Patrick Boateng <boatengpato.pb@gmail.com>
6
+ License: MIT License
7
+ Project-URL: Homepage, https://github.com/patrickboateng/geolysis
8
+ Project-URL: Documentation, https://geolysis.readthedocs.org
9
+ Project-URL: Repository, https://github.com/patrickboateng/geolysis
10
+ Project-URL: Discussions, https://github.com/patrickboateng/geolysis/discussions
11
+ Project-URL: Issue Tracker, https://github.com/patrickboateng/geolysis/issues
12
+ Keywords: geotechnical-engineering,soil-classification,settlement-analysis,bearing-capacity-analysis
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Natural Language :: English
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE.txt
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest; extra == "dev"
29
+ Requires-Dist: pytest-cov; extra == "dev"
30
+ Requires-Dist: coverage; extra == "dev"
31
+
32
+ <h1 align="center">
33
+ <img src="https://raw.githubusercontent.com/patrickboateng/geolysis/dev/docs/source/_static/branding/geolysislogo.svg"
34
+ alt="geolysislogo" width="75%" />
35
+ </h1><br>
36
+
37
+ <div align="center">
38
+
39
+ [![PyPI Latest Release](https://img.shields.io/pypi/v/geolysis?style=flat&logo=pypi)](https://pypi.org/project/geolysis/)
40
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/geolysis.svg?logo=python&style=flat)](https://pypi.python.org/pypi/geolysis/)
41
+ [![license](https://img.shields.io/pypi/l/geolysis?style=flat&logo=opensourceinitiative)](https://opensource.org/license/mit/)
42
+
43
+ ![Coveralls Status](https://img.shields.io/coverallsCoverage/github/patrickboateng/geolysis?logo=coveralls)
44
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/17f88084c6a84a08a20f9d8da1438107)](https://app.codacy.com/gh/patrickboateng/geolysis/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
45
+ [![Unit-Tests](https://github.com/patrickboateng/geolysis/actions/workflows/geolysis-unit-tests.yml/badge.svg)](https://github.com/patrickboateng/geolysis/actions/workflows/unit-tests.yml)
46
+ [![Documentation Status](https://readthedocs.org/projects/geolysis/badge/?version=latest)](https://geolysis.readthedocs.io/en/latest/?badge=latest)
47
+
48
+ </div>
49
+
50
+ `geolysis` is an open-source library for geotechnical analysis and modeling.
51
+ It offers tools for soil classification, Standard Penetration Test (SPT)
52
+ analysis, and bearing capacity estimation, among others.
53
+
54
+ The `geolysis` library is among four main projects: `geolysis.gui`,
55
+ `geolysis.excel`, and `geolysis.ai`. The geolysis library powers all of these
56
+ projects.
57
+
58
+ **_The `geolysis` projects are currently under developement and not yet
59
+ publicly available_**.
60
+
61
+ **_Active development of `geolysis` occurs on the `dev` branch. For more
62
+ information on the latest features of `geolysis`, switch to the
63
+ `dev` branch_**.
64
+
65
+ Here are brief descriptions of these projects:
66
+
67
+ <table>
68
+ <tr>
69
+ <td>
70
+ <strong>geolysis.gui</strong>
71
+ </td>
72
+ <td>A graphical user interface that allows users to interact with the
73
+ geolysis library. Through this interface, users can view generated reports
74
+ and visualizations, such as Particle Size Distribution (PSD) curves,
75
+ Atterberg Limits plots, and Compaction curves, among others.
76
+ Additionally, it enables users to conduct foundation analysis and
77
+ design, among other functionalities.
78
+ </td>
79
+ </tr>
80
+ <tr>
81
+ <td>
82
+ <strong>geolysis.excel</strong>
83
+ </td>
84
+ <td>An add-in for Microsoft Excel that performs simple geotechnical
85
+ analysis. It offers some features similar to <code>geolysis.gui</code>
86
+ within Microsoft Excel.
87
+ </td>
88
+ </tr>
89
+ <tr>
90
+ <td>
91
+ <strong>geolysis.ai</strong>
92
+ </td>
93
+ <td>Offers machine learning models that are trained using geotechnical data.
94
+ </td>
95
+ </tr>
96
+ </table>
97
+
98
+ ## Project Structure
99
+
100
+ .
101
+ ├── .github # GitHub Actions
102
+ ├── docs # Documentation files
103
+ ├── geolysis # Source files
104
+ ├── tests # Automated tests
105
+ └── README.md
106
+
107
+ ## Table of Contents
108
+
109
+ - [Installation](#installation)
110
+ - [Usage Example](#usage-example)
111
+ - [Features](#features)
112
+ - [Documentation](#documentation)
113
+ - [Contributing](#contributing)
114
+ - [License](#license)
115
+ - [Contact](#contact)
116
+
117
+ ## Installation
118
+
119
+ **_Note: Work on the latest update is still in progress, so the usage example
120
+ below
121
+ will not function if installed._**
122
+
123
+ ```shell
124
+ pip install geolysis
125
+ ```
126
+
127
+ ## Usage Example
128
+
129
+ ```python
130
+
131
+ >> > from geolysis.soil_classifier import create_soil_classifier
132
+ >> > uscs_clf = create_soil_classifier(liquid_limit=34.1,
133
+ ...
134
+ plastic_limit = 21.1,
135
+ ...
136
+ fines = 47.88,
137
+ ...
138
+ sand = 37.84,
139
+ ...
140
+ clf_type = "USCS")
141
+ >> > clf = uscs_clf.classify()
142
+ >> > clf
143
+ SoilClf(symbol='SC', description='Clayey sands')
144
+ >> > clf.symbol
145
+ 'SC'
146
+ >> > clf.description
147
+ 'Clayey sands'
148
+
149
+ ```
150
+
151
+ ```python
152
+
153
+ >> > from geolysis.soil_classifier import create_soil_classifier
154
+ >> > aashto_clf = create_soil_classifier(liquid_limit=34.1,
155
+ ...
156
+ plastic_limit = 21.1,
157
+ ...
158
+ fines = 47.88,
159
+ ...
160
+ sand = 37.84, # Sand is optional for AASHTO classification
161
+ ...
162
+ clf_type = "AASHTO")
163
+ >> > clf = aashto_clf.classify()
164
+ >> > clf
165
+ SoilClf(symbol='A-6(4)', description='Clayey soils')
166
+ >> > clf.symbol
167
+ 'A-6(4)'
168
+ >> > clf.description
169
+ 'Clayey soils'
170
+
171
+ ```
172
+
173
+ ## Features
174
+
175
+ <table>
176
+ <tr>
177
+ <td rowspan="2">
178
+ <strong>Soil Classification</strong>
179
+ </td>
180
+ <td>AASHTO Classification System</td>
181
+ </tr>
182
+ <tr>
183
+ <td>Unified Soil Classification System</td>
184
+ </tr>
185
+ <tr>
186
+ <td rowspan="4">
187
+ <strong>Standard Penetration Test (SPT) Analysis</strong>
188
+ </td>
189
+ <td>SPT Energy Correction</td>
190
+ </tr>
191
+ <tr>
192
+ <td>SPT Overburden Pressure Correction</td>
193
+ </tr>
194
+ <tr>
195
+ <td>Dilatancy Correction</td>
196
+ </tr>
197
+ <tr>
198
+ <td>SPT N-Design Calculation</td>
199
+ </tr>
200
+ <tr>
201
+ <td rowspan="2">
202
+ <strong>Bearing Capacity Estimation</strong>
203
+ </td>
204
+ <td>Allowable Bearing Capacity Estimation</td>
205
+ </tr>
206
+ <tr>
207
+ <td>Ultimate Bearing Capacity Estimation</td>
208
+ </tr>
209
+ </table>
210
+
211
+ ## Documentation
212
+
213
+ Full documentation is available [here](https://www.geolysis.readthedocs.io)
214
+
215
+ **_Note: Work on the latest documentation is still ongoing._**
216
+
217
+ ## Contributing
218
+
219
+ ## License
220
+
221
+ This project is licensed under the MIT License - see the
222
+ [LICENSE](https://github.com/patrickboateng/geolysis/blob/main/LICENSE.txt)
223
+ file for more details.
224
+
225
+ ## Contact
226
+
227
+ For questions or feedback, please contact us at
228
+ [boatengpato.pb@gmail.com](mailto:boatengpato.pb@gmail.com)
@@ -0,0 +1,11 @@
1
+ geolysis/__init__.py,sha256=XZTtMHzfsLe7mt08DNl_2Qui1xPYU8f504pS-Q8yKzY,77
2
+ geolysis/foundation.py,sha256=aZVLOrRSx1ALwJwQwrnCQOMc4fQf4gAoBmHjI0tyNLo,9548
3
+ geolysis/soil_classifier.py,sha256=FhfWYEo5dIQ1QWL83u5lX19AfMCCsnf0Klb67ekOLHc,26133
4
+ geolysis/spt.py,sha256=jlO2gIGpM-sKhBQRSaCe3iNFZ8xKq9XiZnxVcxzhyBg,13647
5
+ geolysis/utils.py,sha256=lonWt3VIB-zQjplCTzwUSIBxah4sB4fBh1l92iXE-NY,2313
6
+ geolysis/validators.py,sha256=j6ek90_si4caeVmPMEPTvSxBh0LnxiqXWKzUjF0Htbc,1662
7
+ geolysis-0.4.2.dist-info/LICENSE.txt,sha256=ap6sMs3lT7ICbEXBhgihwH1BTCVcjmCQkIkwVnil1Ak,1065
8
+ geolysis-0.4.2.dist-info/METADATA,sha256=yjsbp0sU4JTVH_S63ncjIyCruTBs1eucjd6ktoUIzNs,7059
9
+ geolysis-0.4.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ geolysis-0.4.2.dist-info/top_level.txt,sha256=9mnQgOaCRr11dtXff8X-q3FfXjRONd6kHseSy5q2y8g,9
11
+ geolysis-0.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1 +0,0 @@
1
- from . import abc