From cd1da148f0bb50df31488e8dfbcfda169efd523e Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 12:28:51 -0700 Subject: [PATCH 1/9] replace '\t' with ' ' [4 spaces] --- ard/api/interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ard/api/interface.py b/ard/api/interface.py index 73ec9032..0de613a9 100644 --- a/ard/api/interface.py +++ b/ard/api/interface.py @@ -165,10 +165,10 @@ def set_up_system_recursive( # Add subsystems directly from the input dictionary if hasattr(parent_group, "name") and (parent_group.name != ""): print( - f"{''.join(['\t' for _ in range(_depth)])}Adding {system_name} to {parent_group.name}." + f"{''.join([' ' for _ in range(_depth)])}Adding {system_name} to {parent_group.name}." ) else: - print(f"{''.join(['\t' for _ in range(_depth)])}Adding {system_name}.") + print(f"{''.join([' ' for _ in range(_depth)])}Adding {system_name}.") if "systems" in input_dict: # Recursively add nested subsystems] if _depth > 0: group = parent_group.add_subsystem( From 6f319aeee72dc0c8a7abb13218c038777c0f8cc0 Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:18:06 -0700 Subject: [PATCH 2/9] remove all instances of '\' in f-strings for compatibility with python 3.10-3.11 --- ard/api/interface.py | 3 ++- ard/collection/optiwindnet_wrap.py | 11 +++++++---- ard/utils/logging.py | 3 ++- ard/utils/test_utils.py | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ard/api/interface.py b/ard/api/interface.py index 0de613a9..d68cb08b 100644 --- a/ard/api/interface.py +++ b/ard/api/interface.py @@ -188,7 +188,8 @@ def set_up_system_recursive( _depth=_depth + 1, ) if "approx_totals" in input_dict: - print(f"\tActivating approximate totals on {system_name}") + prefix = "\t" + print(prefix.join(f"Activating approximate totals on {system_name}")) group.approx_totals(**input_dict["approx_totals"]) else: diff --git a/ard/collection/optiwindnet_wrap.py b/ard/collection/optiwindnet_wrap.py index fad464a1..42fb0001 100644 --- a/ard/collection/optiwindnet_wrap.py +++ b/ard/collection/optiwindnet_wrap.py @@ -42,9 +42,10 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: ] ) if np.any(repeat_accumulate > 0): # only if there are any repeats + prefix = "\n" warn_string = ( - f"\nDetected {np.sum(repeat_accumulate > 0)} coincident " - f"turbines and/or substations in optiwindnet setup." + prefix.join(f"Detected {np.sum(repeat_accumulate > 0)} coincident " + f"turbines and/or substations in optiwindnet setup.") ) # start a warning string for the UserWarning # TODO: make Ard warnings? @@ -57,11 +58,13 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: for idx, dxy in enumerate(adjustments[:T, :]): if np.sum(dxy != 0) == 0: continue - warn_string += f"\n\tadjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" + prefix = "\n\t" + warn_string += prefix.join(f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}") for idx, dxy in enumerate((adjustments[-R:, :])[::-1, :]): if np.sum(dxy != 0) == 0: continue - warn_string += f"\n\tadjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" + prefix = "\n\t" + warn_string += prefix.join(f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}") # output the final warning warn(warn_string) diff --git a/ard/utils/logging.py b/ard/utils/logging.py index 9d6a0da0..636c7049 100644 --- a/ard/utils/logging.py +++ b/ard/utils/logging.py @@ -198,7 +198,8 @@ def wrapper(*args, **kwargs): output = sys.stdout.getvalue() sys.stdout = old_stdout - tabset = "".join(["\t" for t in range(tabs)]) + prefix = "\t" + tabset = "".join([prefix for t in range(tabs)]) if output: for line in output.splitlines(): print(f"{tabset}{line}") diff --git a/ard/utils/test_utils.py b/ard/utils/test_utils.py index 058d9280..8d4ecd48 100644 --- a/ard/utils/test_utils.py +++ b/ard/utils/test_utils.py @@ -48,11 +48,12 @@ def pyrite_validator( if not validation_matches: print(f"for variable {k}:", file=sys.stderr) + prefix = "\t" print( - f"\t{sum_isclose} values match of {vd_size} total validation values", + prefix.join(f"{sum_isclose} values match of {vd_size} total validation values"), file=sys.stderr, ) - print(f"\tto a tolerance of {rtol_val:e}", file=sys.stderr) + print(prefix.join(f"to a tolerance of {rtol_val:e}"), file=sys.stderr) print(f"pyrite data for {k}: {v}", file=sys.stderr) print( f"computed data for {k}: {data_for_validation[k]}", file=sys.stderr From 01b523827c73e61266170dc0594632c9b985d0a7 Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:25:19 -0700 Subject: [PATCH 3/9] run black --- ard/collection/optiwindnet_wrap.py | 14 +++++++++----- ard/utils/test_utils.py | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ard/collection/optiwindnet_wrap.py b/ard/collection/optiwindnet_wrap.py index 42fb0001..e448541d 100644 --- a/ard/collection/optiwindnet_wrap.py +++ b/ard/collection/optiwindnet_wrap.py @@ -43,9 +43,9 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: ) if np.any(repeat_accumulate > 0): # only if there are any repeats prefix = "\n" - warn_string = ( - prefix.join(f"Detected {np.sum(repeat_accumulate > 0)} coincident " - f"turbines and/or substations in optiwindnet setup.") + warn_string = prefix.join( + f"Detected {np.sum(repeat_accumulate > 0)} coincident " + f"turbines and/or substations in optiwindnet setup." ) # start a warning string for the UserWarning # TODO: make Ard warnings? @@ -59,12 +59,16 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: if np.sum(dxy != 0) == 0: continue prefix = "\n\t" - warn_string += prefix.join(f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}") + warn_string += prefix.join( + f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" + ) for idx, dxy in enumerate((adjustments[-R:, :])[::-1, :]): if np.sum(dxy != 0) == 0: continue prefix = "\n\t" - warn_string += prefix.join(f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}") + warn_string += prefix.join( + f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" + ) # output the final warning warn(warn_string) diff --git a/ard/utils/test_utils.py b/ard/utils/test_utils.py index 8d4ecd48..b16ada44 100644 --- a/ard/utils/test_utils.py +++ b/ard/utils/test_utils.py @@ -50,7 +50,9 @@ def pyrite_validator( print(f"for variable {k}:", file=sys.stderr) prefix = "\t" print( - prefix.join(f"{sum_isclose} values match of {vd_size} total validation values"), + prefix.join( + f"{sum_isclose} values match of {vd_size} total validation values" + ), file=sys.stderr, ) print(prefix.join(f"to a tolerance of {rtol_val:e}"), file=sys.stderr) From 316da0e4fd1dabde3abf1e20639f2b587af7ac8a Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:36:42 -0700 Subject: [PATCH 4/9] correct warning syntax --- ard/collection/optiwindnet_wrap.py | 13 +++++-------- test/conftest.py | 6 ++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ard/collection/optiwindnet_wrap.py b/ard/collection/optiwindnet_wrap.py index e448541d..dacffbbd 100644 --- a/ard/collection/optiwindnet_wrap.py +++ b/ard/collection/optiwindnet_wrap.py @@ -42,8 +42,7 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: ] ) if np.any(repeat_accumulate > 0): # only if there are any repeats - prefix = "\n" - warn_string = prefix.join( + warn_string = ( f"Detected {np.sum(repeat_accumulate > 0)} coincident " f"turbines and/or substations in optiwindnet setup." ) # start a warning string for the UserWarning @@ -58,16 +57,14 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: for idx, dxy in enumerate(adjustments[:T, :]): if np.sum(dxy != 0) == 0: continue - prefix = "\n\t" - warn_string += prefix.join( - f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" + warn_string += ( + "\n\t" + f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" ) for idx, dxy in enumerate((adjustments[-R:, :])[::-1, :]): if np.sum(dxy != 0) == 0: continue - prefix = "\n\t" - warn_string += prefix.join( - f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" + warn_string += ( + "\n\t" + f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" ) # output the final warning warn(warn_string) diff --git a/test/conftest.py b/test/conftest.py index 9114d9a2..80f5bd4f 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,4 @@ +import os from pathlib import Path @@ -6,9 +7,10 @@ def pytest_sessionfinish(session, exitstatus): # for each tempdir for pytest_out_dir in Path().glob("pytest*_out"): - for root, dirs, files in pytest_out_dir.walk( - top_down=False + for root, dirs, files in os.walk( + pytest_out_dir, topdown=False ): # walk the directory + root = Path(root) for name in files: (root / name).unlink() # remove subdirectory files, and for name in dirs: From f72469465694491c6b9647c93c1eb120688a7f4f Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:40:37 -0700 Subject: [PATCH 5/9] run black --- ard/api/interface.py | 2 +- ard/collection/optiwindnet_wrap.py | 6 ++++-- ard/utils/test_utils.py | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ard/api/interface.py b/ard/api/interface.py index d68cb08b..1f4814c5 100644 --- a/ard/api/interface.py +++ b/ard/api/interface.py @@ -189,7 +189,7 @@ def set_up_system_recursive( ) if "approx_totals" in input_dict: prefix = "\t" - print(prefix.join(f"Activating approximate totals on {system_name}")) + print(prefix + f"Activating approximate totals on {system_name}") group.approx_totals(**input_dict["approx_totals"]) else: diff --git a/ard/collection/optiwindnet_wrap.py b/ard/collection/optiwindnet_wrap.py index dacffbbd..18d525ac 100644 --- a/ard/collection/optiwindnet_wrap.py +++ b/ard/collection/optiwindnet_wrap.py @@ -58,13 +58,15 @@ def _own_L_from_inputs(inputs: dict, discrete_inputs: dict) -> nx.Graph: if np.sum(dxy != 0) == 0: continue warn_string += ( - "\n\t" + f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" + "\n\t" + + f"adjusting turbine #{idx} from {VertexCTR[idx, :]} to {VertexCTR[idx, :] + dxy}" ) for idx, dxy in enumerate((adjustments[-R:, :])[::-1, :]): if np.sum(dxy != 0) == 0: continue warn_string += ( - "\n\t" + f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" + "\n\t" + + f"adjusting substation #{idx} from {VertexCTR[-(idx+1), :]} to {VertexCTR[-(idx+1), :] + dxy}" ) # output the final warning warn(warn_string) diff --git a/ard/utils/test_utils.py b/ard/utils/test_utils.py index b16ada44..57178066 100644 --- a/ard/utils/test_utils.py +++ b/ard/utils/test_utils.py @@ -50,12 +50,11 @@ def pyrite_validator( print(f"for variable {k}:", file=sys.stderr) prefix = "\t" print( - prefix.join( - f"{sum_isclose} values match of {vd_size} total validation values" - ), + prefix + + f"{sum_isclose} values match of {vd_size} total validation values", file=sys.stderr, ) - print(prefix.join(f"to a tolerance of {rtol_val:e}"), file=sys.stderr) + print(prefix + f"to a tolerance of {rtol_val:e}", file=sys.stderr) print(f"pyrite data for {k}: {v}", file=sys.stderr) print( f"computed data for {k}: {data_for_validation[k]}", file=sys.stderr From 8e3749ebc1b45f533c709c26fcba8a1ce07d78a4 Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:53:37 -0700 Subject: [PATCH 6/9] test only ubuntu and windows and both python 3.11 and 3.13 --- .../workflows/python-tests-consolidated.yaml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-tests-consolidated.yaml b/.github/workflows/python-tests-consolidated.yaml index fb420d8c..10665560 100644 --- a/.github/workflows/python-tests-consolidated.yaml +++ b/.github/workflows/python-tests-consolidated.yaml @@ -14,8 +14,8 @@ jobs: name: Setup and install Ard strategy: matrix: - python-version: [3.12] # ["3.10", "3.11", "3.12", "3.13"] - os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest] # macos-latest include: - os: ubuntu-latest path: ~/.cache/pip @@ -51,8 +51,8 @@ jobs: needs: setup-install strategy: matrix: - python-version: [3.12] # ["3.10", "3.11", "3.12", "3.13"] - os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest] # macos-latest include: - os: ubuntu-latest path: ~/.cache/pip @@ -91,8 +91,8 @@ jobs: needs: test-unit strategy: matrix: - python-version: [3.12] # ["3.10", "3.11", "3.12", "3.13"] - os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest] # macos-latest include: - os: ubuntu-latest path: ~/.cache/pip @@ -154,8 +154,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.12] # ["3.10", "3.11", "3.12", "3.13"] - os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest] # macos-latest include: - os: ubuntu-latest path: ~/.cache/pip @@ -235,8 +235,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.12] # ["3.10", "3.11", "3.12", "3.13"] - os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest] # macos-latest include: - os: ubuntu-latest path: ~/.cache/pip From 103f47bde4aec53e1112bfb159f3597dd2e1937f Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:55:20 -0700 Subject: [PATCH 7/9] Update ard/api/interface.py Simplify tabbing Co-authored-by: Rob Hammond <13874373+RHammond2@users.noreply.github.com> --- ard/api/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ard/api/interface.py b/ard/api/interface.py index 1f4814c5..a4d66bb1 100644 --- a/ard/api/interface.py +++ b/ard/api/interface.py @@ -165,7 +165,7 @@ def set_up_system_recursive( # Add subsystems directly from the input dictionary if hasattr(parent_group, "name") and (parent_group.name != ""): print( - f"{''.join([' ' for _ in range(_depth)])}Adding {system_name} to {parent_group.name}." + f"{''.join(' ' * 4 * _depth)}Adding {system_name} to {parent_group.name}." ) else: print(f"{''.join([' ' for _ in range(_depth)])}Adding {system_name}.") From 766097c8a59554254a495ad6d9fb2884a73e0665 Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 13:57:08 -0700 Subject: [PATCH 8/9] Update ard/api/interface.py Simplify tabbing Co-authored-by: Rob Hammond <13874373+RHammond2@users.noreply.github.com> --- ard/api/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ard/api/interface.py b/ard/api/interface.py index a4d66bb1..22ac5792 100644 --- a/ard/api/interface.py +++ b/ard/api/interface.py @@ -168,7 +168,7 @@ def set_up_system_recursive( f"{''.join(' ' * 4 * _depth)}Adding {system_name} to {parent_group.name}." ) else: - print(f"{''.join([' ' for _ in range(_depth)])}Adding {system_name}.") + print(f"{''.join(' ' * 4 * _depth)}Adding {system_name}.") if "systems" in input_dict: # Recursively add nested subsystems] if _depth > 0: group = parent_group.add_subsystem( From edaf85abe2b37936125bec476629940810698ccd Mon Sep 17 00:00:00 2001 From: Jared Thomas Date: Mon, 9 Feb 2026 14:40:51 -0700 Subject: [PATCH 9/9] re-include macos testing --- .github/workflows/python-tests-consolidated.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-tests-consolidated.yaml b/.github/workflows/python-tests-consolidated.yaml index 10665560..1b164db1 100644 --- a/.github/workflows/python-tests-consolidated.yaml +++ b/.github/workflows/python-tests-consolidated.yaml @@ -15,7 +15,7 @@ jobs: strategy: matrix: python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] # macos-latest + os: [macos-latest, ubuntu-latest, windows-latest] include: - os: ubuntu-latest path: ~/.cache/pip @@ -52,7 +52,7 @@ jobs: strategy: matrix: python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] # macos-latest + os: [macos-latest, ubuntu-latest, windows-latest] include: - os: ubuntu-latest path: ~/.cache/pip @@ -92,7 +92,7 @@ jobs: strategy: matrix: python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] # macos-latest + os: [macos-latest, ubuntu-latest, windows-latest] include: - os: ubuntu-latest path: ~/.cache/pip @@ -155,7 +155,7 @@ jobs: fail-fast: false matrix: python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] # macos-latest + os: [macos-latest, ubuntu-latest, windows-latest] include: - os: ubuntu-latest path: ~/.cache/pip @@ -236,7 +236,7 @@ jobs: fail-fast: false matrix: python-version: [3.11, 3.13] # ["3.10", "3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] # macos-latest + os: [macos-latest, ubuntu-latest, windows-latest] include: - os: ubuntu-latest path: ~/.cache/pip