Skip to content

Commit c0638a6

Browse files
authored
Merge pull request #351 from ClimateImpactLab/style_cleanup
Minor style cleanup, using f-strings
2 parents 44cc7f7 + 5cd83b2 commit c0638a6

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
- Python version for running automated tests in CI upgraded from Python 3.10 to 3.12 ([PR #270](https://github.com/ClimateImpactLab/dscim/pull/270), [@brews](https://github.com/brews)).
1212

13+
### Fixed
14+
15+
- Minor code cleanup. Switch old %-string formatting to use f-strings ([PR #351](https://github.com/ClimateImpactLab/dscim/pull/351), [@brews](https://github.com/brews)).
16+
1317
### Removed
1418

1519
- Removed [`preprocessing/climate`](https://github.com/ClimateImpactLab/dscim/tree/25dfb39637d5716662a3ec636028d5066ddb10bb/src/dscim/preprocessing/climate) and [`preprocessing/misc`](https://github.com/ClimateImpactLab/dscim/tree/25dfb39637d5716662a3ec636028d5066ddb10bb/src/dscim/preprocessing/misc) subpackages. ([PR #249](https://github.com/ClimateImpactLab/dscim/pull/249), [@JMGilbert](https://github.com/JMGilbert))

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ statsmodels==0.14.4
99
pytest==8.3.4
1010
pytest-cov==6.0.0
1111
zarr==2.18.3
12-
ruff==0.7.3
12+
ruff==0.8.1
1313
netcdf4==1.7.2
1414
h5netcdf==1.4.1
1515
impactlab-tools==0.6.0

src/dscim/utils/rff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def process_ssp_sample(ssppath):
160160
ssp_df = pd.read_csv(ssppath, skiprows=11)
161161
ssp_df = ssp_df[ssp_df.year >= 2010]
162162
ssp_df["loginc"] = np.log(ssp_df.value)
163-
ssp_df["isoyear"] = ssp_df.apply(lambda row: "%s:%d" % (row.iso, row.year), axis=1)
163+
ssp_df["isoyear"] = ssp_df.apply(lambda row: f"{row.iso}:{row.year:d}", axis=1)
164164
ssp_df["yearscen"] = ssp_df.apply(
165-
lambda row: "%d:%s/%s" % (row.year, row.model, row.scenario), axis=1
165+
lambda row: f"{row.year:d}:{row.model}/{row.scenario}", axis=1
166166
)
167167

168168
return ssp_df
@@ -176,7 +176,7 @@ def process_rff_sample(i, rffpath, ssp_df, outdir, HEADER, **storage_options):
176176
increments for a single RFF-SP
177177
"""
178178

179-
read_feather = os.path.join(rffpath, "run_%d.feather" % i)
179+
read_feather = os.path.join(rffpath, f"run_{i:d}.feather")
180180
rff_raw = pd.read_feather(read_feather)
181181
rff_raw.rename(columns={"Year": "year", "Country": "iso"}, inplace=True)
182182

@@ -199,7 +199,7 @@ def process_rff_sample(i, rffpath, ssp_df, outdir, HEADER, **storage_options):
199199
rff_df = pd.concat((rff_df, all_year_df))
200200

201201
rff_df["loginc"] = np.log(rff_df.value)
202-
rff_df["isoyear"] = rff_df.apply(lambda row: "%s:%d" % (row.iso, row.year), axis=1)
202+
rff_df["isoyear"] = rff_df.apply(lambda row: f"{row.iso}:{row.year:d}", axis=1)
203203

204204
rff_df = pd.merge(rff_df, rff_raw, on=["year", "iso"], how="left")
205205

0 commit comments

Comments
 (0)