Skip to content

Commit

Permalink
Fix more f-strings
Browse files Browse the repository at this point in the history
These are manually crafted, not feasible by use of ruff
  • Loading branch information
berland committed Dec 17, 2024
1 parent eb73509 commit 1d7f55e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main(argv):

for i in range(0, len(times)):
val = sum.get("FOPR")[i]
save_return_value(val, "oil_prod_rate_%03d" % i)
save_return_value(val, f"oil_prod_rate_{i:03d}")

with open("OIL_PROD_RATE_OK", "w", encoding="utf-8") as f:
f.write("Everything went fine here!")
Expand Down
14 changes: 7 additions & 7 deletions tests/everest/test_templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def test_render_invalid(copy_template_test_data_to_tmp):
render = everest.jobs.templating.render

prod_wells = {"PROD%d" % idx: 0.3 * idx for idx in range(4)}
prod_wells = {f"PROD{idx:d}": 0.3 * idx for idx in range(4)}
prod_in = "well_drill_prod.json"
with open(prod_in, "w", encoding="utf-8") as fout:
json.dump(prod_wells, fout)
Expand All @@ -45,8 +45,8 @@ def test_render_invalid(copy_template_test_data_to_tmp):
def test_render(copy_template_test_data_to_tmp):
render = everest.jobs.templating.render

wells = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)}
wells.update({"INJ%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)})
wells = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)}
wells.update({f"INJ{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)})
wells_in = "well_drill.json"
with open(wells_in, "w", encoding="utf-8") as fout:
json.dump(wells, fout)
Expand Down Expand Up @@ -75,12 +75,12 @@ def test_render(copy_template_test_data_to_tmp):
def test_render_multiple_input(copy_template_test_data_to_tmp):
render = everest.jobs.templating.render

wells_north = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)}
wells_north = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)}
wells_north_in = "well_drill_north.json"
with open(wells_north_in, "w", encoding="utf-8") as fout:
json.dump(wells_north, fout)

wells_south = {"PROD%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)}
wells_south = {f"PROD{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)}
wells_south_in = "well_drill_south.json"
with open(wells_south_in, "w", encoding="utf-8") as fout:
json.dump(wells_south, fout)
Expand All @@ -98,12 +98,12 @@ def test_render_executable(copy_template_test_data_to_tmp):
assert os.access(everest.jobs.render, os.X_OK)

# Dump input
wells_north = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)}
wells_north = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)}
wells_north_in = "well_drill_north.json"
with open(wells_north_in, "w", encoding="utf-8") as fout:
json.dump(wells_north, fout)

wells_south = {"PROD%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)}
wells_south = {f"PROD{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)}
wells_south_in = "well_drill_south.json"
with open(wells_south_in, "w", encoding="utf-8") as fout:
json.dump(wells_south, fout)
Expand Down

0 comments on commit 1d7f55e

Please sign in to comment.