Skip to content

Commit 8a9597b

Browse files
committed
Remove types from docstrings
1 parent 5f0ec60 commit 8a9597b

File tree

9 files changed

+72
-86
lines changed

9 files changed

+72
-86
lines changed

src/bedrock_ge/gi/ags.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@ def ags_to_brgi_db_mapping(
1717
"""Map AGS 3 or AGS 4 data to the Bedrock GI data model.
1818
1919
Args:
20-
source (str | Path | IO[str] | IO[bytes] | bytes): The AGS file (str or Path)
21-
or a file-like object that represents the AGS file.
22-
projected_crs (CRS): Projected Coordinate Reference System (CRS). For example:
20+
source: The AGS file (str or Path) or a file-like object that represents the AGS file.
21+
projected_crs: Projected Coordinate Reference System (CRS). For example:
2322
- OSGB36 / British National Grid: `pyproj.CRS("EPSG:27700")`
2423
- Hong Kong 1980 Grid System: `pyproj.CRS("EPSG:2326")`
25-
vertical_crs (CRS, optional): Vertical CRS. Defaults to EGM2008 height, EPSG:3855
24+
vertical_crs: Vertical CRS. Defaults to EGM2008 height, EPSG:3855,
2625
which measures the orthometric height w.r.t. the Earth Gravitational Model 2008.
2726
- Ordnance Datum Newlyn (ODN) Height: `pyproj.CRS("EPSG:5701")`
2827
- Hong Kong Principle Datum (HKPD) Height: `pyproj.CRS("EPSG:5738")`
29-
encoding (str | None, optional): Encoding of the text file or bytes stream.
30-
Defaults to None. An attempt at detecting the encoding will be made if None.
28+
encoding: Encoding of the text file or bytes stream. Defaults to None.
29+
An attempt at detecting the encoding will be made if None.
3130
3231
Raises:
3332
ValueError: If the data does not match AGS 3 or AGS 4 format.
3433
3534
Returns:
36-
BedrockGIDatabaseMapping: Object that maps AGS 3 or AGS 4 data to Bedrock GI data model.
35+
Object that maps AGS 3 or AGS 4 data to Bedrock GI data model.
3736
"""
3837
if not encoding:
3938
encoding = detect_encoding(source)

src/bedrock_ge/gi/ags4.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ def ags4_to_dfs(
1111
"""Converts AGS 4 data to a dictionary of pandas DataFrames.
1212
1313
Args:
14-
source (str | Path | IO[str] | IO[bytes] | bytes): The AGS4 file (str or Path) or a file-like
15-
object that represents and AGS4 file.
14+
source: The AGS4 file (str or Path) or a file-like object that represents and AGS 4 file.
1615
1716
Returns:
18-
dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key
19-
represents a group name from AGS 4 data, and the corresponding value is a
20-
pandas DataFrame containing the data for that group.
17+
A dictionary of pandas DataFrames, where each key represents a group name
18+
from AGS 4 data, and the corresponding value is a pandas DataFrame
19+
containing the data for that group.
2120
"""
2221
ags4_tups = AGS4.AGS4_to_dataframe(source)
2322

src/bedrock_ge/gi/ags_schemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ def check_ags_proj_group(ags_proj: pd.DataFrame) -> bool:
77
"""Checks if the AGS 3 or AGS 4 PROJ group is correct.
88
99
Args:
10-
ags_proj (pd.DataFrame): The DataFrame with the PROJ group.
10+
ags_proj: The DataFrame with the PROJ group.
1111
1212
Raises:
1313
ValueError: If AGS 3 of AGS 4 PROJ group is not correct.
1414
1515
Returns:
16-
bool: Returns True if the AGS 3 or AGS 4 PROJ group is correct.
16+
Returns True if the AGS 3 or AGS 4 PROJ group is correct.
1717
"""
1818
if len(ags_proj) != 1:
1919
raise ValueError("The PROJ group must contain exactly one row.")

src/bedrock_ge/gi/db_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def merge_dbs(
2828
brgi_dbs: The Bedrock GI databases containing the data to be merged.
2929
3030
Returns:
31-
BedrockGIDatabase: Merged Bedrock GI database.
31+
Merged Bedrock GI database.
3232
"""
3333
dbs = list(brgi_dbs)
3434

src/bedrock_ge/gi/geospatial.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def create_brgi_geodb(
3232
5. Returns a BedrockGIGeospatialDatabase object.
3333
3434
Args:
35-
brgi_db (BedrockGIDatabase): The Bedrock GI database to be converted.
35+
brgi_db: The Bedrock GI database to be converted.
3636
3737
Returns:
38-
BedrockGIGeospatialDatabase: The resulting Bedrock GI geospatial database.
38+
The resulting Bedrock GI geospatial database.
3939
"""
4040
location_geodf = create_location_geodf(brgi_db)
4141
lon_lat_height_geodf = create_lon_lat_height_geodf(brgi_db)
@@ -72,13 +72,12 @@ def create_location_geodf(brgi_db: BedrockGIDatabase) -> gpd.GeoDataFrame:
7272
project data.
7373
7474
Args:
75-
brgi_db (BedrockGIDatabase): The Bedrock GI database containing location
75+
brgi_db: The Bedrock GI database containing location
7676
data and project CRS information.
7777
7878
Returns:
79-
gpd.GeoDataFrame: A GeoDataFrame with LineString geometries representing
80-
vertical boreholes, using the compound CRS derived from the project's
81-
horizontal and vertical CRS.
79+
A GeoDataFrame with LineString geometries representing vertical boreholes,
80+
using the compound CRS derived from the project's horizontal and vertical CRS.
8281
"""
8382
# TODO: Implement logic to handle multiple CRS'es in the input GI data:
8483
# 1. Create WKT geometry for each location in original CRS
@@ -130,13 +129,11 @@ def create_lon_lat_height_geodf(brgi_db: BedrockGIDatabase) -> gpd.GeoDataFrame:
130129
EGM2008 ground level height, along with the corresponding point geometries in EPSG:9518.
131130
132131
Args:
133-
brgi_db (BedrockGIDatabase): The source Bedrock Ground Investigation database
134-
containing location and project information.
132+
brgi_db: The source Bedrock Ground Investigation database containing location and project information.
135133
136134
Returns:
137-
gpd.GeoDataFrame: A GeoDataFrame with the transformed longitude, latitude,
138-
and EGM2008 ground level height, along with the corresponding point
139-
geometries in EPSG:9518.
135+
A GeoDataFrame with the transformed longitude, latitude, and EGM2008 ground level height,
136+
along with the corresponding point geometries in EPSG:9518.
140137
"""
141138
wgs84_egm2008_crs = CRS("EPSG:9518")
142139
crs_lookup = brgi_db.Project.set_index("project_uid")
@@ -198,8 +195,7 @@ def interpolate_gi_geometry(
198195
location_geodf: The location GeoDataFrame containing the location LineStrings to be used for interpolation.
199196
200197
Returns:
201-
gpd.GeoDataFrame: A GeoDataFrame containing the interpolated geospatial geometry
202-
for the In-Situ test DataFrame.
198+
A GeoDataFrame containing the interpolated geospatial geometry for the In-Situ test DataFrame.
203199
"""
204200
# TODO: implement a warning when interpolating GI geospatial geometry when
205201
# TODO: a single GI location has waaay too many rows in a certain In-Situ test.
@@ -271,7 +267,7 @@ def interpolate_3d(linestring: LineString, distance: float) -> Point:
271267
distance: Distance along the line in 3D space
272268
273269
Returns:
274-
Point: The interpolated 3D point
270+
The interpolated 3D point
275271
"""
276272
if distance <= 0:
277273
return Point(linestring.coords[0])
@@ -312,7 +308,7 @@ def substring_3d(
312308
end_dist: End distance along the line in 3D space
313309
314310
Returns:
315-
LineString: The extracted 3D LineString segment
311+
The extracted 3D LineString segment
316312
"""
317313
# Ensure start_dist <= end_dist
318314
if start_dist > end_dist:

src/bedrock_ge/gi/io_utils.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ def detect_encoding(source: str | Path | IO[str] | IO[bytes] | bytes) -> str:
1919
"""Detect the character encoding of various input types.
2020
2121
Args:
22-
source (str | Path | IO[str] | IO[bytes] | bytes): The source to detect encoding from.
22+
source: The source to detect encoding from.
2323
- str or Path: File path.
2424
- IO[str]: Already decoded text stream (returns `DEFAULT_ENCODING`)
2525
- IO[bytes]: Binary stream to detect encoding from
2626
- bytes: Binary data to detect encoding from
2727
2828
Returns:
29-
str: The detected encoding name (e.g., 'utf-8', 'iso-8859-1', 'ascii', etc.)
29+
The detected encoding name (e.g., 'utf-8', 'iso-8859-1', 'ascii', etc.)
3030
3131
Raises:
3232
TypeError: If the source type is unsupported
@@ -122,15 +122,15 @@ def open_text_data_source(
122122
"""Opens or wraps a given source for reading AGS (text-based) data.
123123
124124
Args:
125-
source (str | Path | IO[str] | IO[bytes] | bytes): The source to read from.
125+
source: The source to read from.
126126
- str or Path: File path or direct string content.
127127
- IO[str]: A file-like text stream.
128128
- IO[bytes]: Byte stream
129129
- bytes: Binary content or stream (will be decoded).
130130
encoding (str | None): Encoding to use for decoding bytes. Default is None.
131131
132132
Returns:
133-
ContextManager[TextIOBase]: A context manager yielding a text stream.
133+
A context manager yielding a text stream.
134134
135135
Raises:
136136
TypeError: If the source type is unsupported or binary streams are not decoded.
@@ -177,15 +177,14 @@ def coerce_string(string: str) -> None | bool | float | str:
177177
"""Converts a string to an appropriate Python data type.
178178
179179
Args:
180-
string (str): The input string to be converted.
180+
string: The input string to be converted.
181181
182182
Returns:
183-
None: If the string is 'none', 'null', or empty.
184-
bool: If the string is 'true' or 'false' (case insensitive).
185-
int: If the string can be converted to a float and has no decimal part.
186-
float: If the string can be converted to a float with a decimal part.
187-
str: If the string cannot be converted to any of the above types.
188-
183+
None if the string is 'none', 'null', or empty.
184+
bool if the string is 'true' or 'false' (case insensitive).
185+
int if the string can be converted to a float and has no decimal part.
186+
float if the string can be converted to a float with a decimal part.
187+
str if the string cannot be converted to any of the above types.
189188
"""
190189
if string.lower() in {"none", "null", ""}:
191190
return None
@@ -210,12 +209,11 @@ def brgi_db_to_dfs(
210209
"""Converts a Bedrock GI (geospatial) database to a dictionary of DataFrames.
211210
212211
Args:
213-
brgi_db (BedrockGIDatabase | BedrockGIGeospatialDatabase): The Bedrock GI (geospatial) database.
212+
brgi_db: The Bedrock GI (geospatial) database.
214213
215214
Returns:
216-
dict[str, pd.DataFrame | gpd.GeoDataFrame]: A dictionary where the keys are
217-
the Bedrock GI table names and the values are the DataFrames that contain
218-
the data for each table.
215+
A dictionary where the keys are the Bedrock GI table names and the values are
216+
the DataFrames that contain the data for each table.
219217
"""
220218
dict_of_dfs = {
221219
"Project": brgi_db.Project,
@@ -254,8 +252,7 @@ def convert_object_col_content_to_string(
254252
in_place: Whether to modify the DataFrame in-place (default) or return a new DataFrame.
255253
256254
Returns:
257-
pd.DataFrame: The modified DataFrame with object dtypes converted to string dtypes.
258-
255+
The modified DataFrame with object dtypes converted to string dtypes.
259256
"""
260257
if not in_place:
261258
df = df.copy()

src/bedrock_ge/gi/mapper.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def map_to_brgi_db(brgi_db_mapping: BedrockGIMapping) -> BedrockGIDatabase:
2424
table, validates them against their respective schemas, and constructs the final
2525
BedrockGIDatabase object.
2626
27-
Examples:
27+
Example:
2828
```python
2929
from pyproj import CRS
3030
from bedrock_ge.gi.mapping_models import BedrockGIMapping
@@ -69,12 +69,10 @@ def map_to_brgi_db(brgi_db_mapping: BedrockGIMapping) -> BedrockGIDatabase:
6969
```
7070
7171
Args:
72-
brgi_db_mapping (BedrockGIDatabaseMapping): The mapping object containing GI
73-
data and metadata for mapping to Bedrock's schema.
72+
brgi_db_mapping: The mapping object containing GI data and metadata for mapping to Bedrock's schema.
7473
7574
Returns:
76-
BedrockGIDatabase: The transformed Bedrock GI database containing validated
77-
DataFrames for each table type.
75+
The transformed Bedrock GI database containing validated DataFrames for each table type.
7876
"""
7977
# Create a base64 hash from the project data, such that a project Unique ID
8078
# can be created from the project_id and the hash of the project data.

src/bedrock_ge/gi/validate.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ def check_brgi_geodb(
2121
- Sample
2222
- All Lab test tables
2323
24-
Args:
25-
brgi_geodb (BedrockGIGeospatialDatabase): Bedrock GI geospatial database object.
26-
27-
Returns:
28-
is_valid (bool): True if all tables are valid and relationships are properly maintained.
29-
3024
Example:
3125
```python
3226
brgi_geodb = BedrockGIGeospatialDatabase(
@@ -39,6 +33,12 @@ def check_brgi_geodb(
3933
)
4034
check_brgi_geodb(brgi_db)
4135
```
36+
37+
Args:
38+
brgi_geodb: Bedrock GI geospatial database object.
39+
40+
Returns:
41+
True if all tables are valid and relationships are properly maintained.
4242
"""
4343
# TODO: implement this
4444
return True
@@ -57,12 +57,6 @@ def check_brgi_db(
5757
- Sample (without geospatial geometry)
5858
- All Lab test tables (never has geospatial geometry)
5959
60-
Args:
61-
brgi_db (BedrockGIDatabase): A Bedrock GI database object.
62-
63-
Returns:
64-
bool: True if all tables are valid and relationships are properly maintained.
65-
6660
Example:
6761
```python
6862
brgi_db = BedrockGIDatabase(
@@ -74,6 +68,12 @@ def check_brgi_db(
7468
)
7569
check_brgi_db(brgi_db)
7670
```
71+
72+
Args:
73+
brgi_db: A Bedrock GI database object.
74+
75+
Returns:
76+
True if all tables are valid and relationships are properly maintained.
7777
"""
7878
# TODO: implement this
7979
return True
@@ -89,21 +89,21 @@ def check_foreign_key(
8989
This function ensures that all foreign key values in a child table exist in the corresponding
9090
parent table, maintaining data integrity in the GIS database.
9191
92+
Example:
93+
```python
94+
check_foreign_key("project_uid", projects_df, locations_df)
95+
```
96+
9297
Args:
93-
foreign_key (str): The name of the column that serves as the foreign key.
94-
parent_table (pd.DataFrame| gpd.GeoDataFrame): The parent table containing the primary keys.
95-
table_with_foreign_key (pd.DataFrame| gpd.GeoDataFrame): The child table containing the foreign keys.
98+
foreign_key: The name of the column that serves as the foreign key.
99+
parent_table: The parent table containing the primary keys.
100+
table_with_foreign_key: The child table containing the foreign keys.
96101
97102
Returns:
98-
bool: True if all foreign keys exist in the parent table.
103+
True if all foreign keys exist in the parent table.
99104
100105
Raises:
101106
ValueError: If any foreign key values in the child table do not exist in the parent table.
102-
103-
Example:
104-
```python
105-
check_foreign_key("project_uid", projects_df, locations_df)
106-
```
107107
"""
108108
# Get the foreign keys that are missing in the parent group
109109
missing_foreign_keys = table_with_foreign_key[

src/bedrock_ge/gi/write.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def write_brgi_db_to_file(
2020
determined by the `driver` argument. Possible values are "GPKG" and "EXCEL".
2121
2222
Args:
23-
brgi_db (BedrockGIDatabase | BedrockGIGeospatialDatabase): The Bedrock GI (geospatial) database.
24-
path (str | Path): The path of the output file.
25-
driver (str): The type of the output file. Possible values are "GPKG" and "EXCEL".
23+
brgi_db: The Bedrock GI (geospatial) database.
24+
path: The path of the output file.
25+
driver: The type of the output file. Possible values are "GPKG" and "EXCEL".
2626
2727
Returns:
2828
None
@@ -47,10 +47,9 @@ def write_gi_db_to_gpkg(
4747
separate table named by the keys of the dictionary.
4848
4949
Args:
50-
dict_of_dfs (dict[str, pd.DataFrame | gpd.GeoDataFrame]): A dictionary where
51-
keys are brgi table names and values are pandas DataFrames or GeoDataFrames
52-
with brgi data.
53-
gpkg_path (str | Path): The name of the output GeoPackage file.
50+
dict_of_dfs: A dictionary where keys are brgi table names and values are pandas
51+
DataFrames or GeoDataFrames with brgi data.
52+
gpkg_path: The name of the output GeoPackage file.
5453
5554
Returns:
5655
None
@@ -77,10 +76,8 @@ def write_gi_db_to_excel(
7776
AGS, Bedrock, or another format.
7877
7978
Args:
80-
dict_of_dfs (dict[str, pd.DataFrame | gpd.GeoDataFrame]): A dictionary where
81-
keys are GI table names and values are DataFrames with GI data.
82-
excel_path (str | Path): Path to the output Excel file. Can be provided as a
83-
string or Path object.
79+
dict_of_dfs: A dictionary where keys are GI table names and values are DataFrames with GI data.
80+
excel_path: Path to the output Excel file. Can be provided as a string or Path object.
8481
8582
Returns:
8683
None
@@ -103,10 +100,10 @@ def sanitize_table_name(sheet_name):
103100
replacing invalid characters and spaces with underscores.
104101
105102
Args:
106-
sheet_name (str): The original sheet name.
103+
sheet_name: The original sheet name.
107104
108105
Returns:
109-
sanitized_name (str): A sanitized sheet name with invalid characters and spaces replaced.
106+
A sanitized sheet name with invalid characters and spaces replaced.
110107
"""
111108
invalid_chars = [":", "/", "\\", "?", "*", "[", "]"]
112109
sanitized_name = sheet_name.strip()

0 commit comments

Comments
 (0)