Skip to content

Commit fb59822

Browse files
authored
Merge pull request #22 from rmi-electricity/dev
Updates for 0.3
2 parents 90afb8d + b1e7f84 commit fb59822

File tree

17 files changed

+571
-76
lines changed

17 files changed

+571
-76
lines changed

.github/workflows/documentation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: docs
22
on: [push, pull_request, workflow_dispatch]
3+
permissions:
4+
contents: write
35
jobs:
46
docs:
57
runs-on: ubuntu-latest

.github/workflows/tox-pytest.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,19 @@ jobs:
3737
- name: Run PyTest with Tox
3838
run: |
3939
conda run -n dispatch tox
40+
41+
- name: Coveralls
42+
uses: coverallsapp/github-action@master
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
path-to-lcov: ./coverage.info
46+
47+
finish:
48+
needs: ci-test
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Coveralls Finished
52+
uses: coverallsapp/github-action@master
53+
with:
54+
github-token: ${{ secrets.github_token }}
55+
parallel-finished: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ htmlcov/
5050
.cache
5151
nosetests.xml
5252
coverage.xml
53+
coverage.info
5354
*.cover
5455
*.py,cover
5556
.hypothesis/
@@ -149,3 +150,7 @@ Thumbs.db
149150

150151
# Dispatch
151152
*.zip
153+
*.ipynb
154+
!tests/data/*.zip
155+
156+
/src/dispatch/_version.py

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ repos:
124124
rev: v1.0.0
125125
hooks:
126126
- id: doc8
127-
args: ["--config", "tox.ini"]
127+
args: ["--config", "pyproject.toml"]
128128

129129
# Lint any RST files and embedded code blocks for syntax / formatting errors
130130
- repo: https://github.com/myint/rstcheck
131131
rev: v6.1.0
132132
hooks:
133133
- id: rstcheck
134-
additional_dependencies: [sphinx]
135-
args: ["--config", "tox.ini"]
134+
additional_dependencies: ["rstcheck[toml, sphinx]"]
135+
args: ["--config", "pyproject.toml"]
136136

137137
########################################################################################
138138
# Custom local hooks

README.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Dispatch: A simple and efficient electricity dispatch model
66
:target: https://github.com/rmi-electricity/dispatch/actions?query=workflow%3Atox-pytest
77
:alt: Tox-PyTest Status
88

9+
.. image:: https://github.com/rmi-electricity/dispatch/workflows/docs/badge.svg
10+
:target: https://rmi-electricity.github.io/dispatch/
11+
:alt: GitHub Pages Status
12+
13+
.. image:: https://coveralls.io/repos/github/rmi-electricity/dispatch/badge.svg?branch=dev
14+
:target: https://coveralls.io/github/rmi-electricity/dispatch?branch=dev
15+
916
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
1017
:target: https://github.com/psf/black>
1118
:alt: Any color you want, so long as it's black.
@@ -36,9 +43,22 @@ For more information about how the model works and how to use it, please see the
3643

3744
Installation
3845
=======================================================================================
46+
3947
Dispatch can be installed and used in it's own environment or installed into another
40-
environment using pip. To create an environment for Dispatch, navigate to the repo
41-
folder in terminal and run:
48+
environment using pip. To install it using pip:
49+
50+
.. code-block:: bash
51+
52+
$ pip install git+https://github.com/rmi-electricity/dispatch.git
53+
54+
Or from the dev branch:
55+
56+
.. code-block:: bash
57+
58+
$ pip install git+https://github.com/rmi-electricity/dispatch.git@dev
59+
60+
61+
To create an environment for Dispatch, navigate to the repo folder in terminal and run:
4262

4363
.. code-block:: bash
4464

docs/conf.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
from datetime import datetime
1313
from pathlib import Path
1414

15-
import pkg_resources
15+
# import pkg_resources
1616
from sphinx.application import Sphinx
1717

18+
from dispatch import __version__ as version
19+
1820
DOCS_DIR = Path(__file__).parent.resolve()
1921

2022
# -- Path setup --------------------------------------------------------------
@@ -24,7 +26,7 @@
2426
# importable path.
2527

2628
# The full version, including alpha/beta/rc tags
27-
release = pkg_resources.get_distribution("rmi.dispatch").version
29+
release = ".".join(version.split(".")[:2])
2830

2931
# -- Project information -----------------------------------------------------
3032

@@ -98,13 +100,28 @@
98100
# further. For a list of options available for each theme, see the
99101
# documentation.
100102
html_theme_options = {
103+
"footer_icons": [
104+
{
105+
"name": "GitHub",
106+
"url": "https://github.com/rmi-electricity/dispatch",
107+
"html": """
108+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
109+
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
110+
</svg>
111+
""",
112+
"class": "",
113+
},
114+
],
101115
"navigation_with_keys": True,
102116
# "logo": {
103117
# "image_light": "Small_PNG-RMI_logo_PrimaryUse.PNG",
104118
# "image_dark": "Small_PNG-RMI_logo_PrimaryUse_White_Horizontal.PNG",
105119
# },
106120
"light_logo": "Small_PNG-RMI_logo_PrimaryUse.PNG",
107121
"dark_logo": "Small_PNG-RMI_logo_PrimaryUse_White_Horizontal.PNG",
122+
"source_repository": "https://github.com/rmi-electricity/dispatch/",
123+
"source_branch": "main",
124+
"source_directory": "docs/",
108125
}
109126

110127
# Add any paths that contain custom static files (such as style sheets) here,

docs/release_notes.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Release Notes
55
.. _release-v0-3-0:
66

77
---------------------------------------------------------------------------------------
8-
0.3.0 (2022-XX-XX)
8+
0.3.0 (2022-10-08)
99
---------------------------------------------------------------------------------------
1010

1111
What's New?
@@ -32,15 +32,26 @@ What's New?
3232
* Added validation steps for each type of specs that raise an error when an
3333
operating_date is after the dispatch period which would otherwise result in
3434
dispatch errors.
35+
* New helpers (:func:`.dfs_to_zip` and :func:`.dfs_from_zip`) that simplify saving
36+
and reading in groups of :class:`pandas.DataFrame`.
37+
* Added plotting functions :meth:`.DispatchModel.plot_period` and
38+
:meth:`.DispatchModel.plot_year`.
3539

3640
Known Issues
3741
^^^^^^^^^^^^
3842
* :meth:`.DispatchModel.re_summary` and :meth:`.DispatchModel.storage_summary` have
39-
operations cost data.
40-
* :meth:`.DispatchModel.re_summary` and :meth:`.DispatchModel.storage_summary` have
41-
no tests.
43+
null operations cost data.
4244
* There is still no nice way to include nuclear and hydro resources.
45+
* :meth:`.DispatchModel.plot_year` doesn't seem to really work. At all.
46+
4347

48+
Bug Fixes
49+
^^^^^^^^^
50+
* A validation check throws an error when ramp rates are zero which otherwise would
51+
prevent plant output from ever changing on a fresh dispatch.
52+
* Fixed a :exc:`TypeError` issue in :func:`.apply_op_ret_date` when some dates were
53+
inexplicably converted to :class:`int` rather than :class:`numpy.datetime64` by
54+
:meth:`pandas.DataFrame.to_numpy`.
4455

4556
.. _release-v0-2-0:
4657

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ requires = ["setuptools<64", "setuptools_scm"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.setuptools_scm]
6+
write_to = "src/dispatch/_version.py"
67

78
[tool.black]
89
line-length = 88
@@ -30,3 +31,26 @@ module = [
3031
"numba.*"
3132
]
3233
ignore_missing_imports = true
34+
35+
[tool.pytest.ini_options]
36+
testpaths = ["."]
37+
addopts = ["--verbose"]
38+
log_format = "%(asctime)s [%(levelname)8s] %(name)s:%(lineno)s %(message)s"
39+
log_date_format=" %Y-%m-%d %H:%M:%S"
40+
log_cli = true
41+
log_cli_level = "INFO"
42+
doctest_optionflags = ["NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL", "ELLIPSIS"]
43+
filterwarnings = [
44+
"ignore:distutils Version classes are deprecated:DeprecationWarning",
45+
"ignore:Creating a LegacyVersion:DeprecationWarning:pkg_resources[.*]",
46+
]
47+
48+
[tool.doc8]
49+
max-line-length = 88
50+
ignore-path = "docs/_build"
51+
52+
[tool.rstcheck]
53+
report_level = "WARNING"
54+
ignore_roles = ["pr", "issue", "user", "include"]
55+
ignore_messages = '(Hyperlink target .* is not referenced\.$|Duplicate implicit target name:|An `AttributeError` error occured.*)'
56+
ignore_directives = ["bibliography", "todo", "include"]

setup.cfg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dev =
3737
tox>=3.20,<3.27
3838
doc =
3939
doc8>=0.9,<1.1
40-
sphinx>=4,!=5.1.0,<5.2.3
40+
sphinx>=4,!=5.1.0,<5.2.4
4141
sphinx-autoapi>=1.8,<2.1
4242
sphinx-autodoc-typehints
4343
sphinxcontrib-mermaid
@@ -47,7 +47,7 @@ tests =
4747
; Checks code for security issues
4848
bandit>=1.6,<1.8
4949
; Lets us track what code is being tested
50-
coverage>=5.3,<6.5
50+
coverage>=5.3,<6.6
5151
; Ensures clean documentation formatting
5252
doc8>=0.9,<1.1
5353
; A framework for linting & static analysis
@@ -63,7 +63,7 @@ tests =
6363
; Checks that code isn't overly complicated
6464
mccabe>=0.6,<0.8
6565
; Static type checking
66-
mypy>=0.942,<0.982
66+
mypy>=0.942,<0.983
6767
; Require PEP8 compliant variable names
6868
pep8-naming>=0.12,<0.14
6969
; Allow us to run pre-commit hooks in testing
@@ -74,9 +74,9 @@ tests =
7474
; Allow automatic testing of scripts
7575
pytest-console-scripts>=1.1,<1.4
7676
; Pytest plugin for working with coverage
77-
pytest-cov>=2.10,<3.1
77+
pytest-cov>=2.10,<4.1
7878
; ReStructuredText linter
79-
rstcheck[sphinx]>=5.0,<6.2
79+
rstcheck[sphinx,toml]>=5.0,<6.2
8080
; Python test environment manager
8181
tox>=3.20,<3.27
8282
; pandas-stubs

src/dispatch/__init__.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
"""A template repository for a Python package created by Catalyst Cooperative."""
22
import logging
3-
from importlib.metadata import PackageNotFoundError, version
3+
4+
__author__ = "RMI"
5+
__contact__ = "[email protected]"
6+
__maintainer__ = "Alex Engel"
7+
__license__ = "BSD 3-Clause License"
8+
__maintainer_email__ = "[email protected]"
9+
__docformat__ = "restructuredtext en"
10+
__description__ = "A simple and efficient dispatch model."
11+
12+
try:
13+
from dispatch._version import version as __version__
14+
except ImportError:
15+
__version__ = "unknown"
16+
17+
# try:
18+
# __version__ = version("rmi.dispatch")
19+
# except PackageNotFoundError:
20+
# # package is not installed
21+
# pass
422

523
from dispatch.engine import dispatch_engine, dispatch_engine_compiled
6-
from dispatch.helpers import apply_op_ret_date, copy_profile
24+
from dispatch.helpers import apply_op_ret_date, copy_profile, dfs_from_zip, dfs_to_zip
725
from dispatch.model import DispatchModel
826

927
__all__ = [
@@ -12,22 +30,11 @@
1230
"dispatch_engine_compiled",
1331
"copy_profile",
1432
"apply_op_ret_date",
33+
"dfs_to_zip",
34+
"dfs_from_zip",
35+
"__version__",
1536
]
1637

17-
__author__ = "RMI"
18-
__contact__ = "[email protected]"
19-
__maintainer__ = "Alex Engel"
20-
__license__ = "BSD 3-Clause License"
21-
__maintainer_email__ = "[email protected]"
22-
__docformat__ = "restructuredtext en"
23-
__description__ = "A simple and efficient dispatch model."
24-
25-
try:
26-
__version__ = version("rmi.dispatch")
27-
except PackageNotFoundError:
28-
# package is not installed
29-
pass
30-
3138
__projecturl__ = "https://github.com/rmi-electricity/dispatch"
3239
__downloadurl__ = "https://github.com/rmi-electricity/dispatch"
3340

0 commit comments

Comments
 (0)