diff --git a/.github/workflows/lint-and-test.yaml b/.github/workflows/lint-and-test.yaml index 8855a15..ed31b1f 100644 --- a/.github/workflows/lint-and-test.yaml +++ b/.github/workflows/lint-and-test.yaml @@ -4,13 +4,20 @@ on: push: branches: - main + paths-ignore: + - 'examples/smarteole_example.ipynb' pull_request: branches: - main + paths-ignore: + - 'examples/smarteole_example.ipynb' + workflow_dispatch: + permissions: contents: read + jobs: lint-and-test: runs-on: ${{ matrix.os }} @@ -37,14 +44,14 @@ jobs: run: | python -m venv .venv source .venv/bin/activate - pip install .[dev] + pip install .[all] - name: 'update dependencies' if: steps.cache-venv.outputs.cache-hit == 'true' run: | source .venv/bin/activate - pip install -U .[dev] - - name: "lint check & test" + pip install -U .[all] + - name: 'lint check & test' run: | source .venv/bin/activate poe lint-check - poe test \ No newline at end of file + poe test diff --git a/.github/workflows/smarteole_example.yaml b/.github/workflows/smarteole_example.yaml new file mode 100644 index 0000000..7f889e8 --- /dev/null +++ b/.github/workflows/smarteole_example.yaml @@ -0,0 +1,67 @@ +name: Execute Smarteole Example notebook + +on: + push: + branches: + - main + paths-ignore: + - 'examples/smarteole_example.ipynb' + workflow_dispatch: + + +permissions: + contents: write + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + lint-and-test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ["3.x"] + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.BRANCH_NAME }} + - name: "set up Python ${{ matrix.python-version }}" + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v4 + id: cache-venv + with: + path: ./.venv/ + key: ${{ matrix.python-version }}-venv-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ matrix.python-version }}-venv + - name: 'create environment and install dependencies' + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + python -m venv .venv + source .venv/bin/activate + pip install .[all] + - name: 'update dependencies' + if: steps.cache-venv.outputs.cache-hit == 'true' + run: | + source .venv/bin/activate + pip install -U .[all] + - name: 'lint check & test' + run: | + source .venv/bin/activate + poe lint-check + poe test + - name: 'execute smarteole example notebook and push changes' + run: | + source .venv/bin/activate + poe smarteole-nb + git add -A + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + if git status | grep -q modified; then + git commit -m "Update smarteole example notebook" + git push + fi diff --git a/wind_up/ops_curve_shift.py b/wind_up/ops_curve_shift.py index d04b3e0..5c7dd32 100644 --- a/wind_up/ops_curve_shift.py +++ b/wind_up/ops_curve_shift.py @@ -208,7 +208,7 @@ def _calculate_curve_shift(curve_shift_input: CurveShiftInput) -> float: post_df = curve_shift_input.post_df wtg_name = curve_shift_input.turbine_name - bins = np.arange(0, pre_df[conf.x_col].max() + conf.x_bin_width, conf.x_bin_width) if conf.x_bin_width > 0 else 10 # type: ignore[operator] + bins = np.arange(0, pre_df[conf.x_col].max() + conf.x_bin_width, conf.x_bin_width) if conf.x_bin_width > 0 else 10 # type: ignore[operator,var-annotated] mean_curve = pre_df.groupby(pd.cut(pre_df[conf.x_col], bins=bins, retbins=False), observed=True).agg( x_mean=pd.NamedAgg(column=conf.x_col, aggfunc="mean"),