Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Migrate from Black to ruff
bc2e00b5eaee49cca7829dd615dedbf9d202fa11
df59900337de9c74cdbc7aba8511e3840afb0737
26 changes: 8 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 26.1.0
hooks:
- id: black
name: black
stages: [pre-commit]
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 7.0.0
rev: 9.0.2
hooks:
- id: isort
additional_dependencies: [toml]
Expand All @@ -22,11 +14,14 @@ repos:
additional_dependencies: [toml]
types: [pyi]

- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.10
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff-check
types_or: [python, pyi, jupyter]
args: [--fix]
- id: ruff-format
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
Expand All @@ -40,8 +35,3 @@ repos:
- id: mixed-line-ending
- id: pretty-format-json
args: [--autofix]

- repo: https://github.com/pycqa/flake8
rev: '7.3.0'
hooks:
- id: flake8
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file. If you make a notable change to the project, please add a line describing the change to the "unreleased" section. The maintainers will make an effort to keep the [Github Releases](https://github.com/NREL/OpenOA/releases) page up to date with this changelog. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

- Replace `black` and `flake8` with `ruff` for faster and more robust linting/automated formatting.

## v3.2 - 2026-01-29

- Features and updates:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![PyPI downloads](https://img.shields.io/pypi/dm/openoa)](https://pypi.org/project/WOMBAT/)

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
Expand Down
4 changes: 2 additions & 2 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ will need to accept the Contributor License Agreement(CLA).
## Coding Style

This code uses a ``pre-commit`` workflow where code styling and linting is taken care of when a user
commits their code. Specifically, this code utilizes ``black`` for automatic formatting (line length, quotation usage, hanging
lines, etc.), ``isort`` for automatic import sorting, and ``flake8`` for linting.
commits their code. Specifically, this code utilizes ``ruff`` for automatic formatting (line length,
quotation usage, hanging lines, etc.) and linting and ``isort`` for automatic import sorting.

To activate the ``pre-commit`` workflow, the user must install the develop version as outlined in the
[Readme](https://github.com/NREL/OpenOA/tree/develop#Development), and run the following line:
Expand Down
44 changes: 24 additions & 20 deletions examples/00_intro_to_plant_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@
" df=scada_df_tz,\n",
" time_col=\"Date_time\",\n",
" local_tz=\"Europe/Paris\",\n",
" tz_aware=True # Indicate that we can use encoded data to convert between timezones\n",
" tz_aware=True, # Indicate that we can use encoded data to convert between timezones\n",
")\n",
"scada_df_tz.head()"
]
Expand Down Expand Up @@ -1043,7 +1043,7 @@
" df=scada_df_no_tz,\n",
" time_col=\"Date_time\",\n",
" local_tz=\"Europe/Paris\",\n",
" tz_aware=False # Indicates that we're going to need to make inferences about encoding the timezones\n",
" tz_aware=False, # Indicates that we're going to need to make inferences about encoding the timezones\n",
")\n",
"scada_df_no_tz.head()"
]
Expand Down Expand Up @@ -1249,8 +1249,19 @@
],
"source": [
"no_tz = qa.describe(scada_df_no_tz)\n",
"no_tz = no_tz.loc[~no_tz.index.isin([\"Date_time\"])] # Ignore the Date_time column that is not shared between the dataframes\n",
"col_order = [\"count\", \"mean\", \"std\", \"min\", \"25%\", \"50%\", \"75%\", \"max\"] # Ensure description columns are in the same order\n",
"no_tz = no_tz.loc[\n",
" ~no_tz.index.isin([\"Date_time\"])\n",
"] # Ignore the Date_time column that is not shared between the dataframes\n",
"col_order = [\n",
" \"count\",\n",
" \"mean\",\n",
" \"std\",\n",
" \"min\",\n",
" \"25%\",\n",
" \"50%\",\n",
" \"75%\",\n",
" \"max\",\n",
"] # Ensure description columns are in the same order\n",
"qa.describe(scada_df_tz)[col_order] == no_tz[col_order]"
]
},
Expand Down Expand Up @@ -1621,9 +1632,7 @@
],
"source": [
"dup_orig_no_tz, dup_local_no_tz, dup_utc_no_tz = qa.duplicate_time_identification(\n",
" df=scada_df_no_tz,\n",
" time_col=\"Date_time\",\n",
" id_col=\"Wind_turbine_name\"\n",
" df=scada_df_no_tz, time_col=\"Date_time\", id_col=\"Wind_turbine_name\"\n",
")\n",
"dup_orig_no_tz.size, dup_local_no_tz.size, dup_utc_no_tz.size"
]
Expand Down Expand Up @@ -1729,9 +1738,7 @@
],
"source": [
"gap_orig_no_tz, gap_local_no_tz, gap_utc_no_tz = qa.gap_time_identification(\n",
" df=scada_df_no_tz,\n",
" time_col=\"Date_time\",\n",
" freq=\"10min\"\n",
" df=scada_df_no_tz, time_col=\"Date_time\", freq=\"10min\"\n",
")\n",
"gap_orig_no_tz.size, gap_local_no_tz.size, gap_utc_no_tz.size"
]
Expand Down Expand Up @@ -1840,7 +1847,7 @@
" time_col=\"Date_time\",\n",
" power_col=\"P_avg\",\n",
" freq=\"10min\",\n",
" hour_window=3 # default value\n",
" hour_window=3, # default value\n",
")"
]
},
Expand All @@ -1864,9 +1871,7 @@
"outputs": [],
"source": [
"dup_orig_tz, dup_local_tz, dup_utc_tz = qa.duplicate_time_identification(\n",
" df=scada_df_tz,\n",
" time_col=\"Date_time\",\n",
" id_col=\"Wind_turbine_name\"\n",
" df=scada_df_tz, time_col=\"Date_time\", id_col=\"Wind_turbine_name\"\n",
")"
]
},
Expand Down Expand Up @@ -1980,9 +1985,7 @@
],
"source": [
"gap_orig_tz, gap_local_tz, gap_utc_tz = qa.gap_time_identification(\n",
" df=scada_df_tz,\n",
" time_col=\"Date_time\",\n",
" freq=\"10min\"\n",
" df=scada_df_tz, time_col=\"Date_time\", freq=\"10min\"\n",
")\n",
"gap_orig_tz.size, gap_local_tz.size, gap_utc_tz.size"
]
Expand Down Expand Up @@ -2054,7 +2057,7 @@
" time_col=\"Date_time\",\n",
" power_col=\"P_avg\",\n",
" freq=\"10min\",\n",
" hour_window=3 # default value\n",
" hour_window=3, # default value\n",
")"
]
},
Expand Down Expand Up @@ -2265,6 +2268,7 @@
],
"source": [
"from openoa.plant import PlantMetaData\n",
"\n",
"print(PlantMetaData.__doc__)"
]
},
Expand Down Expand Up @@ -2349,7 +2353,7 @@
"print(f\"The new analysis types now has all and MonteCarloAEP: {engie.analysis_type}\")\n",
"try:\n",
" engie.validate()\n",
"except ValueError as e: # Catch the error message so that the whole notebook can run\n",
"except ValueError as e: # Catch the error message so that the whole notebook can run\n",
" print(e)"
]
},
Expand Down Expand Up @@ -2398,7 +2402,7 @@
" asset=f\"{data_path}/asset.csv\",\n",
" reanalysis={\n",
" \"era5\": f\"{data_path}/reanalysis_era5.csv\",\n",
" \"merra2\": f\"{data_path}/reanalysis_merra2.csv\"\n",
" \"merra2\": f\"{data_path}/reanalysis_merra2.csv\",\n",
" },\n",
")"
]
Expand Down
21 changes: 12 additions & 9 deletions examples/01_utils_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
"\n",
"from bokeh.plotting import show\n",
"from bokeh.io import output_notebook\n",
"\n",
"output_notebook()\n",
"\n",
"from openoa.utils import filters, power_curve, plot\n",
Expand Down Expand Up @@ -697,7 +698,7 @@
" xlim=(-1, 20), # optional input for refining plots\n",
" ylim=(-100, 2100), # optional input for refining plots\n",
" legend=True, # optional flag for adding a legend\n",
" scatter_kwargs=dict(alpha=0.8, s=10) # optional input for refining plots\n",
" scatter_kwargs=dict(alpha=0.8, s=10), # optional input for refining plots\n",
")"
]
},
Expand Down Expand Up @@ -757,7 +758,7 @@
}
],
"source": [
"out_of_window = filters.window_range_flag(windspeed, 5., 40, power_kw, 20., 2100.)\n",
"out_of_window = filters.window_range_flag(windspeed, 5.0, 40, power_kw, 20.0, 2100.0)\n",
"plot.plot_power_curve(\n",
" windspeed,\n",
" power_kw,\n",
Expand All @@ -766,7 +767,7 @@
" xlim=(-1, 20), # optional input for refining plots\n",
" ylim=(-100, 2100), # optional input for refining plots\n",
" legend=True, # optional flag for adding a legend\n",
" scatter_kwargs=dict(alpha=0.4, s=10) # optional input for refining plots\n",
" scatter_kwargs=dict(alpha=0.4, s=10), # optional input for refining plots\n",
")"
]
},
Expand Down Expand Up @@ -816,7 +817,9 @@
],
"source": [
"max_bin = 0.90 * power_kw_filt1.max()\n",
"bin_outliers = filters.bin_filter(power_kw_filt1, windspeed_filt1, 100, 1.5, \"median\", 20., max_bin, \"scalar\", \"all\")\n",
"bin_outliers = filters.bin_filter(\n",
" power_kw_filt1, windspeed_filt1, 100, 1.5, \"median\", 20.0, max_bin, \"scalar\", \"all\"\n",
")\n",
"plot.plot_power_curve(\n",
" windspeed_filt1,\n",
" power_kw_filt1,\n",
Expand All @@ -825,7 +828,7 @@
" xlim=(-1, 20), # optional input for refining plots\n",
" ylim=(-100, 2100), # optional input for refining plots\n",
" legend=True, # optional flag for adding a legend\n",
" scatter_kwargs=dict(alpha=0.5, s=10) # optional input for refining plots\n",
" scatter_kwargs=dict(alpha=0.5, s=10), # optional input for refining plots\n",
")"
]
},
Expand Down Expand Up @@ -881,7 +884,7 @@
" xlim=(-1, 20), # optional input for refining plots\n",
" ylim=(-100, 2100), # optional input for refining plots\n",
" legend=True, # optional flag for adding a legend\n",
" scatter_kwargs=dict(alpha=0.4, s=10) # optional input for refining plots\n",
" scatter_kwargs=dict(alpha=0.4, s=10), # optional input for refining plots\n",
")"
]
},
Expand Down Expand Up @@ -972,9 +975,9 @@
")\n",
"\n",
"x = np.linspace(0, 20, 100)\n",
"ax.plot(x, iec_curve(x), color=\"red\", label = \"IEC\", linewidth = 3)\n",
"ax.plot(x, spline_curve(x), color=\"C1\", label = \"Spline\", linewidth = 3)\n",
"ax.plot(x, l5p_curve(x), color=\"C2\", label = \"L5P\", linewidth = 3)\n",
"ax.plot(x, iec_curve(x), color=\"red\", label=\"IEC\", linewidth=3)\n",
"ax.plot(x, spline_curve(x), color=\"C1\", label=\"Spline\", linewidth=3)\n",
"ax.plot(x, l5p_curve(x), color=\"C2\", label=\"L5P\", linewidth=3)\n",
"\n",
"ax.legend()\n",
"\n",
Expand Down
Loading
Loading