Skip to content

Commit 35ab02e

Browse files
authored
Refactor lambda functions with ruff for improved readability in GDP and HURDAT2 adapters; update version to 0.47.0 (#589)
1 parent 014daf1 commit 35ab02e

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

clouddrift/adapters/gdp/gdpsource.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,14 @@ def _process_chunk(
494494
preremove_df_chunk,
495495
filters=[
496496
# Filter out year values that are in the future or predating the GDP program
497-
lambda df: (df["posObsYear"] > datetime.datetime.now().year)
498-
| (df["posObsYear"] < 0),
499-
lambda df: (df["senObsYear"] > datetime.datetime.now().year)
500-
| (df["senObsYear"] < 0),
497+
lambda df: (
498+
(df["posObsYear"] > datetime.datetime.now().year)
499+
| (df["posObsYear"] < 0)
500+
),
501+
lambda df: (
502+
(df["senObsYear"] > datetime.datetime.now().year)
503+
| (df["senObsYear"] < 0)
504+
),
501505
# Filter out month values that contain non-numeric characters
502506
lambda df: df["senObsMonth"].astype(np.str_).str.contains(r"[\D]"),
503507
lambda df: df["posObsMonth"].astype(np.str_).str.contains(r"[\D]"),

clouddrift/adapters/hurdat2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,16 @@ def _extract_track_data(datafile_path: str, convert: bool) -> list[TrackData]:
417417
track_data = list[TrackData]()
418418

419419
is_html_line = lambda line: re.match(r"[html|head|pre]+", line)
420-
is_header_line = (
421-
lambda cols, data_line_count: len(cols) == 4 and data_line_count == 0
420+
is_header_line = lambda cols, data_line_count: (
421+
len(cols) == 4 and data_line_count == 0
422422
)
423423
is_data_line = lambda cols, data_line_count: len(cols) == 21 and data_line_count > 0
424424
if convert:
425-
nm_to_m = (
426-
lambda x: float(x) * _METERS_IN_NAUTICAL_MILES
425+
nm_to_m = lambda x: (
426+
float(x) * _METERS_IN_NAUTICAL_MILES
427427
) # nautical-miles to meters
428-
k_to_mps = (
429-
lambda x: float(x) * _METERS_IN_NAUTICAL_MILES / 3600
428+
k_to_mps = lambda x: (
429+
float(x) * _METERS_IN_NAUTICAL_MILES / 3600
430430
) # knots to meters per second
431431
mb_to_pa = lambda x: float(x) * _PASCAL_PER_MILLIBAR # millibar to pascal
432432
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "clouddrift"
7-
version = "0.46.0"
7+
version = "0.47.0"
88

99
authors = [
1010
{ name="Shane Elipot", email="[email protected]" },

tests/ragged_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ def test_subset_by_rows(self):
705705
self.assertTrue(all(ds_sub["rowsize"] == [5, 4]))
706706

707707
def test_subset_callable(self):
708-
func = (
709-
lambda arr: ((arr - arr[0]) % 2) == 0
708+
func = lambda arr: (
709+
((arr - arr[0]) % 2) == 0
710710
) # test keeping obs every two time intervals
711711
ds_sub = subset(self.ds, {"time": func})
712712
self.assertTrue(all(ds_sub["id"] == [1, 3, 2]))

0 commit comments

Comments
 (0)