Skip to content

Commit

Permalink
Merge branch 'dev' into fix-and-extend-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nailend committed Aug 16, 2023
2 parents 254695e + 9f53b86 commit 1c665c5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 26 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will run linters with a single version of Python

name: Black

on:
push:
branches:
- main
- dev
- release/*
pull_request:

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Install Python dependencies
run: pip install black flake8 isort

- name: Black
if: success() || failure()
run: black --check .

- name: flake8
if: success() || failure()
run: flake8 data_adapter_oemof tests

- name: isort
if: success() || failure()
run: isort --verbose --check-only --diff data_adapter_oemof tests
19 changes: 9 additions & 10 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# This workflow will install Python dependencies, run tests with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Pytest
Expand All @@ -11,8 +11,7 @@ on:
- release/*

pull_request:
branches:
- dev


# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -60,10 +59,10 @@ jobs:
- name: Test with pytest
run: python -m poetry run python -m pytest -svvv

- name: Lint
run: |
python setup.py check --strict --metadata --restructuredtext
check-manifest .
black --check .
flake8 src tests
isort --verbose --check-only --diff src tests
# - name: Lint
# run: |
# python setup.py check --strict --metadata --restructuredtext
# check-manifest .
# black --check .
# flake8 src tests
# isort --verbose --check-only --diff src tests
4 changes: 1 addition & 3 deletions data_adapter_oemof/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

import oemof.solph
import pandas

from oemof.tabular import facades
from oemof.solph import Bus
from oemof.tabular import facades

from data_adapter_oemof import calculations
from data_adapter_oemof.mappings import Mapper


logger = logging.getLogger()


Expand Down
7 changes: 3 additions & 4 deletions data_adapter_oemof/build_datapackage.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import dataclasses
import os
import warnings

import pandas as pd
import os

from datapackage import Package

from data_adapter import core
from data_adapter.preprocessing import Adapter
from datapackage import Package

from data_adapter_oemof.adapters import FACADE_ADAPTERS
from data_adapter_oemof.mappings import PROCESS_TYPE_MAP, Mapper

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
import os
import sys

sys.path.insert(0, os.path.abspath('..'))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
from oemof.tabular.datapackage import building


building.infer_metadata(
package_name="oemof-tabular-dispatch-example",
foreign_keys={
Expand Down
12 changes: 5 additions & 7 deletions tests/test_build_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from unittest import mock

import oemof.tabular
import pandas
import pandas as pd
import pytest
from data_adapter.databus import download_collection
from data_adapter.preprocessing import Adapter
from data_adapter_oemof.build_datapackage import DataPackage, refactor_timeseries
from oemof.solph import EnergySystem, Model

from utils import PATH_TEST_FILES, PATH_TMP, check_if_csv_dirs_equal
from data_adapter_oemof.build_datapackage import DataPackage, refactor_timeseries

path_default = (
PATH_TEST_FILES
Expand All @@ -23,7 +21,7 @@


def test_refactor_timeseries():
timeseries = pandas.DataFrame(
timeseries = pd.DataFrame(
{
"timeindex_start": ["01:00:00", "01:00:00", "09:00:00"],
"timeindex_stop": ["03:00:00", "03:00:00", "10:00:00"],
Expand All @@ -35,20 +33,20 @@ def test_refactor_timeseries():
)

refactored_ts = refactor_timeseries(timeseries)
expected_df = pandas.DataFrame(
expected_df = pd.DataFrame(
{
"offshore_BB": [7.0, 8, 9, None, None],
"offshore_HH": [10.0, 11, 12, 35, 36],
"onshore_BB": [1.0, 2, 3, None, None],
"onshore_HH": [4.0, 5, 6, 33, 34],
},
index=pandas.DatetimeIndex(
index=pd.DatetimeIndex(
["01:00:00", "02:00:00", "03:00:00", "09:00:00", "10:00:00"]
),
)
expected_df = expected_df.sort_index(axis=1)
refactored_ts = refactored_ts.sort_index(axis=1)
pandas.testing.assert_frame_equal(expected_df, refactored_ts)
pd.testing.assert_frame_equal(expected_df, refactored_ts)


def test_scalar_building():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os
import typing

import pandas as pd
import numpy as np
import pandas as pd
from test_build_datapackage import refactor_timeseries

from data_adapter_oemof.adapters import (
ExtractionTurbineAdapter,
Expand Down

0 comments on commit 1c665c5

Please sign in to comment.