Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge develop into master for v0.5.1 release #331

Merged
merged 10 commits into from
Feb 4, 2022
4 changes: 0 additions & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
[run]
branch = True
omit =
**/test_*.py
**/__init__.py

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: Bug report
labels: bug
assignees: ahurli, BainanXia, danielolsen, jon-hagg, rouille
assignees: BainanXia, danielolsen, jon-hagg, rouille

---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Feature request
about: Suggest an idea for this project
title: Feature request
labels: feature request
assignees: ahurli, BainanXia, danielolsen, jon-hagg, rouille
assignees: BainanXia, danielolsen, jon-hagg, rouille

---

Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,18 @@ jobs:

name: Generate coverage report
steps:
- name: Checkout PostREISE
uses: actions/checkout@v2
with:
path: PostREISE

- name: Checkout PowerSimData
uses: actions/checkout@v2
with:
repository: Breakthrough-Energy/PowerSimData
path: PowerSimData
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- run: python -m pip install --upgrade pip tox
working-directory: PostREISE

- run: tox -e pytest -- --cov-report=xml
working-directory: PostREISE

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: codecov-postreise
fail_ci_if_error: true
directory: PostREISE
14 changes: 1 addition & 13 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout PostREISE
uses: actions/checkout@v2
with:
path: PostREISE

- name: Checkout PowerSimData
uses: actions/checkout@v2
with:
repository: Breakthrough-Energy/PowerSimData
path: PowerSimData
- uses: actions/checkout@v2

- name: Pipenv lock
id: pipenv_lock
uses: Breakthrough-Energy/actions/update-packages@main
with:
repo-dir: PostREISE

- name: Parse JSON
id: parse_json
Expand Down Expand Up @@ -67,4 +56,3 @@ jobs:

[1]: https://github.com/peter-evans/create-pull-request
branch: update-dependencies
path: PostREISE
16 changes: 2 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8]
python-version: ['3.8', '3.9', '3.10']

steps:
- name: Checkout PostREISE
uses: actions/checkout@v2
with:
path: PostREISE

- name: Checkout PowerSimData
uses: actions/checkout@v2
with:
repository: Breakthrough-Energy/PowerSimData
path: PowerSimData
- uses: actions/checkout@v2

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

- run: python -m pip install --upgrade tox
working-directory: PostREISE

- run: tox -e pytest
working-directory: PostREISE
7 changes: 3 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ verify_ssl = true
bokeh = "==2.0.2"
matplotlib = "~=3.3"
numpy = "~=1.20"
pandas = "~=1.2"
pyproj = "==2.6.1.post1"
seaborn = "==0.10.1"
powersimdata = "~=0.4.3"
pandas = "~=1.4.0"
powersimdata = "~=0.5.0"
pyproj = "~=3.0"

[dev-packages]
black = "*"
Expand Down
1,001 changes: 527 additions & 474 deletions Pipfile.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![logo](https://raw.githubusercontent.com/Breakthrough-Energy/docs/master/source/_static/img/BE_Sciences_RGB_Horizontal_Color.svg)
[![PyPI](https://img.shields.io/pypi/v/postreise?color=purple)](https://pypi.org/project/postreise/)
[![codecov](https://codecov.io/gh/Breakthrough-Energy/PostREISE/branch/develop/graph/badge.svg?token=UFZ9CW4GND)](https://codecov.io/gh/Breakthrough-Energy/PostREISE)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Expand Down Expand Up @@ -28,7 +29,8 @@ A detailed tutorial can be found on our [docs].


## Where to get it
For now, only the source code is available. Clone or Fork the code here on GitHub.
* Clone or Fork the source code on [GitHub](https://github.com/Breakthrough-Energy/PostREISE)
* Get latest release from PyPi: `pip install postreise`


## Dependencies
Expand All @@ -53,7 +55,8 @@ software ecosystem.


## Documentation
The official documentation can be found [here][docs].
[Code documentation][docstrings] in form of Python docstrings along with an overview of
the [package][docs] are available on our [website][website].


## Communication Channels
Expand All @@ -68,5 +71,7 @@ Guide](https://breakthrough-energy.github.io/docs/dev/contribution_guide.html).



[docs]: https://breakthrough-energy.github.io/docs/index.html
[docs]: https://breakthrough-energy.github.io/docs/postreise/index.html
[docstrings]: https://breakthrough-energy.github.io/docs/postreise.html
[website]: https://breakthrough-energy.github.io/docs/
[PowerSimData]: https://github.com/Breakthrough-Energy/PowerSimData
3 changes: 1 addition & 2 deletions postreise/analyze/transmission/congestion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import pandas as pd
from powersimdata.input.helpers import summarize_plant_to_bus
from powersimdata.input.input_data import get_bus_demand
from powersimdata.scenario.analyze import Analyze
from powersimdata.scenario.scenario import Scenario

Expand All @@ -22,7 +21,7 @@ def calculate_congestion_surplus(scenario):
lmp = scenario.state.get_lmp()
pg = scenario.state.get_pg()

bus_demand = get_bus_demand(scenario.info, grid).to_numpy()
bus_demand = scenario.get_bus_demand()
bus_pg = summarize_plant_to_bus(pg, grid, all_buses=True)

congestion_surplus = (lmp.to_numpy() * (bus_demand - bus_pg)).sum(axis=1)
Expand Down
31 changes: 10 additions & 21 deletions postreise/analyze/transmission/tests/test_congestion_surplus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
from powersimdata.input.input_data import InputData
from powersimdata.tests.mock_scenario import MockScenario

from postreise.analyze.transmission import congestion
Expand All @@ -27,21 +26,15 @@ def _check_return(expected_return, surplus):
np.testing.assert_array_equal(surplus.to_numpy(), expected_return.to_numpy(), msg)


def test_calculate_congestion_surplus_single_time(monkeypatch):
def test_calculate_congestion_surplus_single_time():
"""Congested case from Kirschen & Strbac Section 5.3.2.4"""

def mock_get_data(*args, **kwargs):
return demand

# Override default InputData.get_data method to avoid profile csv lookup
monkeypatch.setattr(InputData, "get_data", mock_get_data)

demand = pd.DataFrame({"UTC": ["t1"], 1: [410], 2: [0]})
bus_demand = pd.DataFrame({"UTC": ["t1"], 1: [50], 2: [60], 3: [300], 4: [0]})
lmp = pd.DataFrame({"UTC": ["t1"], 1: [7.5], 2: [11.25], 3: [10], 4: [0]})
pg = pd.DataFrame({"UTC": ["t1"], "A": [50], "B": [285], "C": [0], "D": [75]})
for df in (demand, lmp, pg):
for df in (bus_demand, lmp, pg):
df.set_index("UTC", inplace=True)
mock_scenario = MockScenario(grid_attrs, demand=demand, lmp=lmp, pg=pg)
mock_scenario = MockScenario(grid_attrs, bus_demand=bus_demand, lmp=lmp, pg=pg)

expected_return = pd.Series(
data=[787.5],
Expand All @@ -53,17 +46,13 @@ def mock_get_data(*args, **kwargs):
_check_return(expected_return, surplus)


def test_calculate_congestion_surplus_three_times(monkeypatch):
def test_calculate_congestion_surplus_three_times():
"""First: congested. Second: uncongested. Third: uncongested, fuzzy."""

def mock_get_data(*args, **kwargs):
return demand

# Override default InputData.get_data method to avoid profile csv lookup
monkeypatch.setattr(InputData, "get_data", mock_get_data)

time_indices = ["t1", "t2", "t3"]
demand = pd.DataFrame({"UTC": time_indices, 1: [410] * 3, 2: [0] * 3})
bus_demand = pd.DataFrame(
{"UTC": time_indices, 1: [50] * 3, 2: [60] * 3, 3: [300] * 3, 4: [0] * 3}
)
lmp = pd.DataFrame(
{
"UTC": time_indices,
Expand All @@ -82,9 +71,9 @@ def mock_get_data(*args, **kwargs):
"D": [75, 0, 0],
}
)
for df in (demand, lmp, pg):
for df in (bus_demand, lmp, pg):
df.set_index("UTC", inplace=True)
mock_scenario = MockScenario(grid_attrs, demand=demand, lmp=lmp, pg=pg)
mock_scenario = MockScenario(grid_attrs, bus_demand=bus_demand, lmp=lmp, pg=pg)

expected_return = pd.Series(
data=[787.5, 0, 0],
Expand Down
2 changes: 1 addition & 1 deletion postreise/plot/plot_carbon_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def add_emission(canvas, emission, scale_factor):
hover = HoverTool(
tooltips=[
("Type", "@type"),
(u"Tons CO\u2082", "@tons"),
("Tons CO\u2082", "@tons"),
],
renderers=[circle],
)
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
bokeh==2.0.2
matplotlib~=3.3
numpy~=1.19
pandas~=1.1.2
powersimdata~=0.4.3
pyproj==2.6.1.post1
pandas~=1.4.0
powersimdata~=0.5.0
pyproj~=3.0
black
pytest
coverage
Expand Down
15 changes: 8 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[metadata]
name = postreise
version = 0.5.0
author = Kaspar Mueller
author_email = kaspar@breakthroughenergy.org
version = 0.5.1
author = Breakthrough Energy
author_email = sciences@breakthroughenergy.org
description = Extract, analyze and plot data from scenario
long_description = file: README.md
long_description_content_type = text/markdown
Expand All @@ -12,19 +12,20 @@ project_urls =
classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
zip_safe = False
packages = find:
python_requires = >=3.7
python_requires = >=3.8
install_requires =
powersimdata~=0.4.3
powersimdata~=0.5.0
bokeh
matplotlib
pyproj

[options.package_data]
postreise = data/*.csv
postreise = data/*.csv