Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1c02305
Fix import of pandas testing
Jan 8, 2024
710847b
Only add curve data with unique wind speeds
Jan 8, 2024
ca9e464
Series.append is deprecated, use pd.concat instead
Jan 8, 2024
e963667
Fix error - float can only be applied to single element
Jan 8, 2024
3ce26c7
Make sure data is sorted, sort is now per default False
Jan 8, 2024
3df5e99
Change import of weather data due to deprecation of date_parser
Jan 8, 2024
8792488
Fix full load hours
Jan 10, 2024
4efa95c
Add github workflow for continuous testing
Jan 10, 2024
32fece2
Update tested and supported python versions
Jan 10, 2024
dafb8bc
Bug fix - cannot have uses and run key
Jan 10, 2024
64cb2d3
Make python versions strings so that python3.10 is recognised correctly
Jan 10, 2024
ea7e8a6
Fix missing conda installation
Jan 10, 2024
89c23c4
Fix import of modelchain_example - previous import fails when noteboo…
Jan 12, 2024
07649a9
Use pytest_notebook to test whether notebooks run without errors
Jan 12, 2024
1f48299
Fix tests - tests fail on windows as dtype on one side is np.int32 an…
Jan 12, 2024
a86b50f
Try fixing failing tests on windows - on windows dtype here is np.int…
Jan 12, 2024
bec03ad
Try fixing different index dtype - on windows dtype is int32 and on l…
Jan 12, 2024
b051746
Try fixing import error of example.modelchain_example when notebooks …
Jan 12, 2024
9aec02e
Fix test for windows - on windows dtype on the left is int64 and on t…
Jan 12, 2024
cac3187
Revert "Use pytest_notebook to test whether notebooks run without err…
Jan 12, 2024
4dd5858
Increase timeout to avoid error when tests are run on github
Jan 12, 2024
01be601
Not needed anymore as lower python versions are not supported anymore
Jan 12, 2024
f26de07
Change import back as tests fail now
Jan 12, 2024
5332a8e
Try setting directory to fix error for windows PermissionError: [Errn…
Jan 12, 2024
f275547
Try setting permissions to fix PermissionError
Jan 12, 2024
1d7055f
Comment other tests to run only windows tests
Jan 12, 2024
b668b70
Change permission
Jan 12, 2024
d45d448
Remove setting permissions again as it did not work correctly
Jan 12, 2024
028aa8d
Try workaround - don't import functions from external python file
Jan 12, 2024
4e9fd2c
Remove old imports
Jan 12, 2024
edc6862
Undo commenting linux tests
Jan 12, 2024
5f418bc
Use pytest-notebook again to avoid Permission denied error on windows
Jan 12, 2024
8d488a9
Update documentation
Jan 16, 2024
f5f3d8f
Add changes to whatsnew
Jan 16, 2024
d274ce6
Remove lower limit for pandas as it is not needed anymore
Jan 16, 2024
296e58e
Handle faulty turbine library data
Jan 30, 2024
99c58d5
Merge branch 'dev' into features/fix_and_add_automatic_tests
Jan 31, 2024
8a9a769
Add readthedocs.yml
Feb 1, 2024
649fca0
Add sphinx_rtd_theme to rtd requirements
Feb 1, 2024
285a96a
Remove asterisk
Feb 1, 2024
3a6ed88
Fix failing docstring test for NaN values in "has_cp_curve"
Feb 1, 2024
d57801e
Adapt test so that "oedb" is checked as well ("local" is checked in d…
Feb 1, 2024
b4db824
Move extracting curve data from oedb turbine library to own function …
Feb 9, 2024
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
68 changes: 68 additions & 0 deletions .github/workflows/tests-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Tests with pytest the package and monitors the coverage and sends it to coveralls.io
# Coverage is only send to coveralls.io when no pytest tests fail
name: "Tests & Coverage"

on: [push]

# Cancel jobs on new push
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
name: "${{ matrix.name-suffix }} at py${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- name-suffix: "coverage"
os: ubuntu-latest
python-version: "3.11"
- name-suffix: "basic"
os: ubuntu-latest
python-version: "3.10"
- name-suffix: "basic"
os: ubuntu-latest
python-version: "3.12"
- name-suffix: "basic"
os: windows-latest
python-version: "3.11"

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up Conda
if: runner.os == 'Windows'
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
activate-environment: testenv

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install .[dev]

- name: Run tests
if: ${{ !(runner.os == 'Linux' && matrix.python-version == 3.9 && matrix.name-suffix == 'coverage') }}
run: |
python -m pytest --disable-warnings --color=yes -v

- name: Run tests, coverage and send to coveralls
if: runner.os == 'Linux' && matrix.python-version == 3.9 && matrix.name-suffix == 'coverage'
run: |
coverage run --source=windpowerlib -m pytest --disable-warnings --color=yes -v
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
28 changes: 28 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: doc/requirements.txt

# Set the version of Python
build:
os: ubuntu-22.04
tools:
python: "3.11"
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: python

matrix:
include:
- python: 3.6
- python: 3.7
- python: 3.8
- python: 3.10
- python: 3.11
- python: 3.12

# command to install dependencies
#before_install:
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ Go to the `download page <http://readthedocs.org/projects/windpowerlib/downloads
Installation
============

If you have a working Python 3 (>= 3.6) environment, use pypi to install the latest windpowerlib version:
If you have a working Python 3 environment, use pypi to install the latest windpowerlib version:

::

pip install windpowerlib

The windpowerlib is designed for Python 3 and tested on Python >= 3.5. We highly recommend to use virtual environments.
The windpowerlib is designed for Python 3 and tested on Python >= 3.10. We highly recommend to use virtual environments.
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.

Optional Packages
Expand Down
2 changes: 1 addition & 1 deletion doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you have a working Python 3 environment, use pypi to install the latest windp

pip install windpowerlib

The windpowerlib is designed for Python 3 and tested on Python >= 3.5. We highly recommend to use virtual environments.
The windpowerlib is designed for Python 3 and tested on Python >= 3.10. We highly recommend to use virtual environments.
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.

Optional Packages
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx>=1.4
sphinx_rtd_theme
ipykernel
nbsphinx
pandas
Expand Down
7 changes: 6 additions & 1 deletion doc/whatsnew/v0-2-2.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
v0.2.2 ()
++++++++++++++++++++++++++++++

* Updated the code basis to work for newer versions of python (support for python 3.6 to
python 3.9 is discontinued, supported python versions are now >= python 3.9) and added
github actions to run tests automatically when changes are pushed to github
(`PR 136 <https://github.com/wind-python/windpowerlib/pull/136>`_).

Contributors
############
* Author
* Birgit Schachler
3 changes: 2 additions & 1 deletion example/modelchain_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
" file,\n",
" index_col=0,\n",
" header=[0, 1],\n",
" date_parser=lambda idx: pd.to_datetime(idx, utc=True))\n",
" )\n",
" weather_df.index = pd.to_datetime(weather_df.index, utc=True)\n",
" \n",
" # change time zone\n",
" weather_df.index = weather_df.index.tz_convert(\n",
Expand Down
2 changes: 1 addition & 1 deletion example/modelchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def get_weather_data(filename="weather.csv", **kwargs):
file,
index_col=0,
header=[0, 1],
date_parser=lambda idx: pd.to_datetime(idx, utc=True),
)
weather_df.index = pd.to_datetime(weather_df.index, utc=True)

# change time zone
weather_df.index = weather_df.index.tz_convert("Europe/Berlin")
Expand Down
2 changes: 1 addition & 1 deletion example/simple_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def get_weather_data(filename="weather.csv", **kwargs):
file,
index_col=0,
header=[0, 1],
date_parser=lambda idx: pd.to_datetime(idx, utc=True),
)
weather_df.index = pd.to_datetime(weather_df.index, utc=True)

# change time zone
weather_df.index = weather_df.index.tz_convert("Europe/Berlin")
Expand Down
57 changes: 15 additions & 42 deletions example/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
"""

import os
import subprocess
import tempfile
import nbformat
import sys
from example import modelchain_example as mc_e
from example import turbine_cluster_modelchain_example as tc_mc_e
from numpy.testing import assert_allclose
import pytest
import pytest_notebook


class TestExamples:
Expand Down Expand Up @@ -42,7 +38,7 @@ def test_turbine_cluster_modelchain_example_flh(self):
)
tc_mc_e.calculate_power_output(weather, example_farm, example_cluster)
assert_allclose(
1956.164053,
2004.84125,
(example_farm.power_output.sum() / example_farm.nominal_power),
0.01,
)
Expand All @@ -57,50 +53,27 @@ def test_turbine_cluster_modelchain_example_flh(self):

def _notebook_run(self, path):
"""
Execute a notebook via nbconvert and collect output.
Returns (parsed nb object, execution errors)
Execute a notebook and collect output.
Returns execution errors.
"""
dirname, __ = os.path.split(path)
os.chdir(dirname)
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
args = [
"jupyter",
"nbconvert",
"--to",
"notebook",
"--execute",
"--ExecutePreprocessor.timeout=60",
"--output",
fout.name,
path,
]
subprocess.check_call(args)

fout.seek(0)
nb = nbformat.read(fout, nbformat.current_nbformat)

errors = [
output
for cell in nb.cells
if "outputs" in cell
for output in cell["outputs"]
if output.output_type == "error"
]

return nb, errors
notebook = pytest_notebook.notebook.load_notebook(path=path)
result = pytest_notebook.execution.execute_notebook(
notebook,
with_coverage=False,
timeout=600,
)
return result.exec_error

@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6")
def test_modelchain_example_ipynb(self):
dir_path = os.path.dirname(os.path.realpath(__file__))
nb, errors = self._notebook_run(
errors = self._notebook_run(
os.path.join(dir_path, "modelchain_example.ipynb")
)
assert errors == []
assert errors is None

@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6")
def test_turbine_cluster_modelchain_example_ipynb(self):
dir_path = os.path.dirname(os.path.realpath(__file__))
nb, errors = self._notebook_run(
errors = self._notebook_run(
os.path.join(dir_path, "turbine_cluster_modelchain_example.ipynb")
)
assert errors == []
assert errors is None
Loading