Skip to content

Commit 206b66b

Browse files
authored
Merge pull request #29 from bedrock-engineer/small-docstring-fixes
Small docstring fixes
2 parents 7b9e81b + 9509c64 commit 206b66b

File tree

6 files changed

+32
-25
lines changed

6 files changed

+32
-25
lines changed

src/bedrock_ge/gi/ags/read.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def ags_to_dfs(ags_data: str) -> Dict[str, pd.DataFrame]:
1818
1919
Returns:
2020
Dict[str, pd.DataFrame]]: A dictionary where keys represent AGS group
21-
names with corresponding DataFrames for the corresponding group data.
21+
names with corresponding DataFrames for the corresponding group data.
2222
"""
2323
# Process each line to find the AGS version and delegate parsing
2424
for line in ags_data.splitlines():
@@ -57,8 +57,9 @@ def ags3_to_dfs(ags3_data: str) -> Dict[str, pd.DataFrame]:
5757
ags3_data (str): The AGS 3 data as a string.
5858
5959
Returns:
60-
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 3 data,
61-
and the corresponding value is a pandas DataFrame containing the data for that group.
60+
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key
61+
represents a group name from AGS 3 data, and the corresponding value is a
62+
pandas DataFrame containing the data for that group.
6263
"""
6364
# Initialize dictionary and variables used in the AGS 3 read loop
6465
ags3_dfs = {}
@@ -156,8 +157,9 @@ def ags4_to_dfs(ags4_data: str) -> Dict[str, pd.DataFrame]:
156157
ags4_data (str): The AGS 4 data as a string.
157158
158159
Returns:
159-
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 4 data,
160-
and the corresponding value is a pandas DataFrame containing the data for that group.
160+
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key
161+
represents a group name from AGS 4 data, and the corresponding value is a
162+
pandas DataFrame containing the data for that group.
161163
"""
162164
# AGS4.AGS4_to_dataframe accepts the file, not the data string
163165
ags4_file = io.StringIO(ags4_data)

src/bedrock_ge/gi/ags/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def ags3_db_to_no_gis_brgi_db(
4343
4444
Returns:
4545
Dict[str, pd.DataFrame]: A dictionary containing Bedrock GI database tables,
46-
where keys are table names and values are transformed pandas DataFrames.
46+
where keys are table names and values are transformed pandas DataFrames.
4747
4848
Note:
4949
The function creates a copy of the input database to avoid modifying the original data.

src/bedrock_ge/gi/concatenate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def concatenate_databases(
2020
db2 (Dict[str, pd.DataFrame]): A dictionary of pandas DataFrames, i.e. a database.
2121
2222
Returns:
23-
dict: A dictionary of concatenated pandas DataFrames.
23+
concatenated_dict (Dict[str, pd.DataFrame]): A dictionary of concatenated pandas DataFrames.
2424
"""
2525
# Create a new dict to store the concatenated dataframes
2626
concatenated_dict = {key: df.dropna(axis=1, how="all") for key, df in db1.items()}

src/bedrock_ge/gi/gis_geometry.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ def calculate_gis_geometry(
2828
2929
Returns:
3030
Dict[str, gpd.GeoDataFrame]: Dictionary containing the Bedrock GI database tables
31-
with added GIS geometry. All tables are converted to GeoDataFrames with
32-
appropriate CRS and geometry columns.
31+
with added GIS geometry. All tables are converted to GeoDataFrames with
32+
appropriate CRS and geometry columns.
3333
3434
Raises:
3535
ValueError: If the projects in the database use different Coordinate Reference Systems (CRS).
3636
3737
Note:
3838
The function performs the following operations:
39+
3940
1. Verifies all projects use the same CRS
4041
2. Calculates GIS geometry for the 'Location' table
4142
3. Creates a 'LonLatHeight' table for 2D visualization
@@ -155,7 +156,7 @@ def calculate_location_gis_geometry(
155156

156157
def calculate_wgs84_coordinates(
157158
from_crs: CRS, easting: float, northing: float, elevation: Union[float, None] = None
158-
) -> Tuple:
159+
) -> Tuple[float, float, (float | None)]:
159160
"""Transforms coordinates from an arbitrary Coordinate Reference System (CRS) to the WGS84 CRS, which is the standard for geodetic coordinates.
160161
161162
Args:
@@ -166,9 +167,10 @@ def calculate_wgs84_coordinates(
166167
transform. Defaults to None.
167168
168169
Returns:
169-
tuple: A tuple containing the longitude, latitude and WGS84 height of the
170-
transformed point, in that order. The height is None if no elevation was
171-
given, or if the provided CRS doesn't have a proper datum defined.
170+
Tuple[float, float, (float | None)]: A tuple containing the longitude, latitude
171+
and WGS84 height of the transformed point, in that order.
172+
The height is None if no elevation was given, or if the provided CRS doesn't
173+
have a proper datum defined.
172174
"""
173175
transformer = Transformer.from_crs(from_crs, 4326, always_xy=True)
174176
if elevation:
@@ -177,7 +179,7 @@ def calculate_wgs84_coordinates(
177179
lon, lat = transformer.transform(easting, northing)
178180
wgs84_height = None
179181

180-
return lon, lat, wgs84_height
182+
return (lon, lat, wgs84_height)
181183

182184

183185
def create_lon_lat_height_table(
@@ -197,7 +199,7 @@ def create_lon_lat_height_table(
197199
crs (CRS): The Coordinate Reference System of the GI locations.
198200
199201
Returns:
200-
GeoDataFrame: The 'LonLatHeight' GeoDataFrame.
202+
gpd.GeoDataFrame: The 'LonLatHeight' GeoDataFrame.
201203
"""
202204
lon_lat_height = gpd.GeoDataFrame(
203205
brgi_location[
@@ -231,9 +233,9 @@ def calculate_in_situ_gis_geometry(
231233
232234
Returns:
233235
gpd.GeoDataFrame: The GIS geometry for the given in-situ data, with additional columns:
234-
- elevation_at_top: The elevation at the top of the in-situ data.
235-
- elevation_at_base: The elevation at the base of the in-situ data.
236-
- geometry: The GIS geometry of the in-situ data.
236+
- elevation_at_top: The elevation at the top of the in-situ data.
237+
- elevation_at_base: The elevation at the base of the in-situ data.
238+
- geometry: The GIS geometry of the in-situ data.
237239
"""
238240
location_child = brgi_in_situ.copy()
239241

src/bedrock_ge/gi/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def check_brgi_database(brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]
3333
values are the corresponding data tables (DataFrame or GeoDataFrame).
3434
3535
Returns:
36-
bool: True if all tables are valid and relationships are properly maintained.
36+
is_valid (bool): True if all tables are valid and relationships are properly maintained.
3737
3838
Example:
3939
```python

src/bedrock_ge/gi/write.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def write_gi_db_to_gpkg(
1616
separate table named by the keys of the dictionary.
1717
1818
Args:
19-
brgi_db (dict): A dictionary where keys are brgi table names and values are DataFrames
19+
brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary where
20+
keys are brgi table names and values are pandas DataFrames or GeoDataFrames
2021
with brgi data.
2122
gpkg_path (str): The name of the output GeoPackage file.
2223
@@ -39,7 +40,7 @@ def write_gi_db_to_gpkg(
3940

4041

4142
def write_gi_db_to_excel(
42-
gi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
43+
gi_dfs: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
4344
excel_path: Union[str, Path],
4445
) -> None:
4546
"""Writes a database with Ground Investigation data to an Excel file.
@@ -49,15 +50,17 @@ def write_gi_db_to_excel(
4950
AGS, Bedrock, or another format.
5051
5152
Args:
52-
gi_dfs (dict): A dictionary where keys are GI table names and values are DataFrames with GI data.
53-
excel_path (str): The name of the output Excel file.
53+
gi_dfs (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary where
54+
keys are GI table names and values are DataFrames with GI data.
55+
excel_path (Union[str, Path]): Path to the output Excel file. Can be provided as a
56+
string or Path object.
5457
5558
Returns:
5659
None
5760
"""
5861
# Create an Excel writer object
5962
with pd.ExcelWriter(excel_path, engine="openpyxl") as writer:
60-
for sheet_name, df in gi_db.items():
63+
for sheet_name, df in gi_dfs.items():
6164
sanitized_sheet_name = sanitize_table_name(sheet_name)
6265
if isinstance(df, pd.DataFrame) or isinstance(df, gpd.GeoDataFrame):
6366
df.to_excel(writer, sheet_name=sanitized_sheet_name, index=False)
@@ -76,7 +79,7 @@ def sanitize_table_name(sheet_name):
7679
sheet_name (str): The original sheet name.
7780
7881
Returns:
79-
sanitized_name: A sanitized sheet name with invalid characters and spaces replaced.
82+
sanitized_name (str): A sanitized sheet name with invalid characters and spaces replaced.
8083
"""
8184
# Trim to a maximum length of 31 characters
8285
trimmed_name = sheet_name.strip()[:31]

0 commit comments

Comments
 (0)