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

Structure #90

Merged
merged 72 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3662e69
changed to poetry
rwijtvliet Sep 5, 2023
7a235a1
fixed pint problem (groups in unitdef.txt) and pint-pandas dependency…
rwijtvliet Sep 5, 2023
6d1117d
ci pipeline
rwijtvliet Sep 5, 2023
5bce0c3
ci pipeline
rwijtvliet Sep 5, 2023
44fffbc
Merge branch 'develop' into poetry
rwijtvliet Sep 5, 2023
af97c21
ci with poetry
rwijtvliet Sep 5, 2023
81df6f4
solve dependency problems between pandas and pint-pandas
rwijtvliet Sep 8, 2023
0a941bb
workaround pint-pandas bug
rwijtvliet Sep 8, 2023
67ad1b4
typo
rwijtvliet Sep 15, 2023
01b6666
seaborn pinned version to 0.8
rwijtvliet Nov 3, 2023
41f1ec4
fixed to_excel function, updated version of pint
Nov 10, 2023
8ee0658
fixed arithmatic on pflines without overlap
rwijtvliet Nov 13, 2023
f9b63cc
Merge remote-tracking branch 'refs/remotes/origin/poetry' into poetry
rwijtvliet Nov 13, 2023
150f3c1
small changes
Nov 13, 2023
3b12095
Merge remote-tracking branch 'refs/remotes/origin/poetry' into poetry
Nov 13, 2023
90bf90f
more consistent functions to get random pfline
rwijtvliet Nov 13, 2023
65dd175
deleted comment
Nov 13, 2023
b932758
Merge remote-tracking branch 'refs/remotes/origin/poetry' into poetry
Nov 13, 2023
d120b03
change the python version for push request to 3.11
Nov 15, 2023
657b6bf
test
rwijtvliet Nov 15, 2023
6871b2c
Removed unused dependency
Nov 15, 2023
85ec27c
updated toml
Nov 15, 2023
a7322b6
added exception if no clipboard available
rwijtvliet Nov 15, 2023
49d4e95
Merge remote-tracking branch 'refs/remotes/origin/poetry' into poetry
rwijtvliet Nov 15, 2023
1cac21e
updated toml
Nov 15, 2023
81aa5a4
Merge remote-tracking branch 'refs/remotes/origin/poetry' into poetry
Nov 15, 2023
047807b
fixed pfline_excelclipboad.py
Nov 17, 2023
8b46ec6
changed lock file for pre-commit
Nov 17, 2023
af19246
install poetry libraries in pre-commit step
Nov 17, 2023
7c106c8
use black on all files in pre-commit
Nov 17, 2023
f325b75
updated flake8 version in pre-commit.yaml
Nov 17, 2023
4cb6bc8
exclude .venv folder from flake8
Nov 17, 2023
cbef5e7
changed setup.cfg to ignore flake8 error messages
Nov 17, 2023
5ce6839
initial commit
Nov 21, 2023
545879b
first try at plotting children
rwijtvliet Nov 21, 2023
106e13c
Merge branch 'develop' into plot_children
Nov 21, 2023
420b530
bar plot with children
Dec 1, 2023
9f6e0d1
Merge branch 'develop' into plot_children
Dec 4, 2023
4e68c33
created plot_children(),fixed bug with darken
Dec 12, 2023
6416b13
area plots for children stacked on top of each other. for daily it pl…
Dec 20, 2023
b3c2d49
Merge branch 'develop' into plot_children
Dec 28, 2023
8f958c5
changed the logic of all plot_timeseries_as functions, now based on f…
Jan 2, 2024
96ca68a
created a function to test plotting pfline
Jan 3, 2024
53affbc
created slice attr, wrote tests for it
Jan 11, 2024
c1c9f5b
more flexible intersec function with ignore freq, tz, start_of_day + …
Jan 22, 2024
ffa4dad
small changes to intersect
Jan 23, 2024
5a7d3f2
intersect_flex function is finished, more testing with frames needed
Feb 5, 2024
a99e4fc
finished intersect_flex, more testing with frames needed
Feb 5, 2024
8957d9f
added children bool to plot pfstate
Mar 5, 2024
faab40e
added hash function for colors for children
Mar 8, 2024
1cad372
deleted unnecessary test
Mar 11, 2024
818019a
changed hash function, and width of hline
Mar 20, 2024
a94b6dc
deleted unnecessary test
Mar 22, 2024
35d4d20
Merge branch 'develop' into plot_children
Apr 10, 2024
3a1975a
plot with children
rwijtvliet Apr 17, 2024
285b79e
Merge branch 'develop' into plot_children
Apr 22, 2024
0335779
Merge branch 'develop' into plot_children
Apr 22, 2024
0b274ac
changed plot_pfstate to work with new logic
Apr 22, 2024
22a81fb
tests for plot function
Apr 24, 2024
e5ed4f6
Merge branch 'develop' into structure
Apr 30, 2024
730bf7e
error with refactoring :3
May 10, 2024
3e6cccc
refactoring
rwijtvliet May 12, 2024
e26ed4d
deleted unnecessary files
May 13, 2024
8ac55fd
more powerful peak/offpeak functions
rwijtvliet May 15, 2024
27d541c
removed longer_or_shorter from frequency tools
rwijtvliet May 21, 2024
5a0fb5a
tests for peakfn and peakconvert
rwijtvliet May 22, 2024
04a123b
removed nonexisting import
rwijtvliet May 22, 2024
98b12ef
fixed test
rwijtvliet May 22, 2024
152016e
removed all Union and replaced with |
rwijtvliet May 22, 2024
aa972de
minor things
rwijtvliet May 23, 2024
5f2974b
fixed po-method
rwijtvliet May 24, 2024
c91f12b
fixed typo
rwijtvliet May 24, 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
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
=========
portfolyo
=========

Expand Down Expand Up @@ -28,6 +29,8 @@ portfolyo
Portfolyo is a Python package to analyse and manipulate timeseries related to power
and gas offtake portfolios.


------------
Installation
------------

Expand All @@ -45,13 +48,16 @@ NB: this package is under active development and the API will change without pri
portfolyo = "x.y.z"


-------------
Documentation
-------------

Documentation is hosted on readthedocs:

https://portfolyo.readthedocs.io/


----------
Repository
----------

Expand All @@ -60,6 +66,7 @@ The git repository is hosted on github:
http://www.github.com/rwijtvliet/portfolyo


----------
Developing
----------

Expand All @@ -74,6 +81,16 @@ the commit hooks.

Feature branches are merged into the ``develop`` branch via pull request.


Internal dependencies
---------------------

Inside the package, modules depend on each other in the following chain. A module may depend on another module if it is further to the left:

tools >> pfline >> pfstate >> tools2


----------
Publishing
----------

Expand Down
19 changes: 9 additions & 10 deletions portfolyo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
"""Package to analyse and manipulate timeseries related to power and gas offtake portfolios."""

from . import _version, dev, testing, tools
from . import _version, dev, tools
from .core import extendpandas # extend functionalty of pandas
from .core import suppresswarnings
from .tools2.plot import plot_pfstates
from .core.pfline import Kind, PfLine, Structure, create
from .core.pfstate import PfState
from .tools import testing
from .tools2.changeyear import map_to_year
from .tools2.concat import general as concat
from .tools2.intersect import indexable as intersection
from .tools2.plot import plot_pfstates
from .prices.hedge import hedge
from .prices.utils import is_peak_hour
from .tools.changefreq import averagable as asfreq_avg
from .tools.changefreq import summable as asfreq_sum
from .tools.changeyear import characterize_index, map_frame_to_year
from .tools.freq import FREQUENCIES
from .tools.hedge import hedge
from .tools.peakfn import PeakFunction
from .tools.peakfn import factory as create_peakfn
from .tools.product import germanpower_peakfn, is_peak_hour
from .tools.standardize import frame as standardize
from .tools.tzone import force_agnostic, force_aware
from .tools.unit import Q_, Unit, ureg
from .tools.wavg import general as wavg
from .tools2.concat import general as concat
from .tools2.intersect import indexable as intersection

# from .core.shared.concat import general as concat


VOLUME = Kind.VOLUME
PRICE = Kind.PRICE
Expand All @@ -33,4 +32,4 @@
suppresswarnings.apply()

__version__ = _version.get_versions()["version"]
__all__ = ["tools", "dev", "testing", "PfLine", "PfState"]
__all__ = ["tools", "dev", "PfLine", "PfState"]
16 changes: 7 additions & 9 deletions portfolyo/core/pfline/arithmatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any

import numpy as np
import pandas as pd

from ... import testing, tools
from ... import tools
from . import classes, create, interop
from .enums import Kind, Structure

Expand All @@ -23,7 +23,7 @@ def assert_objects_indexcompatibility(fn):

def wrapper(o1, o2, *args, **kwargs):
try:
testing.assert_indices_compatible(o1.index, o2.index)
tools.testing.assert_indices_compatible(o1.index, o2.index)
except AssertionError as e:
raise NotImplementedError from e
return fn(o1, o2, *args, **kwargs)
Expand Down Expand Up @@ -185,7 +185,7 @@ def __rmul__(self: PfLine, other: Any) -> PfLine:
@Prep.standardize_other # other converted to None, a PfLine, or dimless Series
@Prep.raiseerror_if_otherNone # other is now a PfLine or dimless Series...
@Prep.assert_objects_indexcompatibility # ... with a compatible index
def __truediv__(self: PfLine, other: Any) -> Union[PfLine, pd.Series]:
def __truediv__(self: PfLine, other: Any) -> PfLine | pd.Series:
if isinstance(other, pd.Series):
return Multiply.pfline_and_series(self, 1 / other)
else:
Expand All @@ -195,7 +195,7 @@ def __truediv__(self: PfLine, other: Any) -> Union[PfLine, pd.Series]:
@Prep.raiseerror_if_otherNone # other is now a PfLine or dimless Series
@Prep.raiseerror_if_otherdimlessseries # other is now a PfLine...
@Prep.assert_objects_indexcompatibility # ... with a compatible index
def __rtruediv__(self: PfLine, other: Any) -> Union[PfLine, pd.Series]:
def __rtruediv__(self: PfLine, other: Any) -> PfLine | pd.Series:
return Divide.two_pflines(other, self) # NB order!

@Prep.standardize_other # other converted to None, a PfLine, or dimless Series
Expand Down Expand Up @@ -285,12 +285,10 @@ def nestedpfline_and_series(pfl: NestedPfLine, s: pd.Series) -> NestedPfLine:

class Divide:
@Prep.ensure_pflines_flat # pfl1 and pfl2 are now both flat
def two_pflines(pfl1: PfLine, pfl2: PfLine) -> Union[pd.Series, PfLine]:
def two_pflines(pfl1: PfLine, pfl2: PfLine) -> pd.Series | PfLine:
return Divide.two_flatpflines(pfl1, pfl2)

def two_flatpflines(
pfl1: FlatPfLine, pfl2: FlatPfLine
) -> Union[pd.Series, FlatPfLine]:
def two_flatpflines(pfl1: FlatPfLine, pfl2: FlatPfLine) -> pd.Series | FlatPfLine:
if pfl1.kind is pfl2.kind:
if pfl1.kind is Kind.COMPLETE:
raise NotImplementedError(
Expand Down
10 changes: 4 additions & 6 deletions portfolyo/core/pfline/children.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Any, Mapping, Union
from typing import TYPE_CHECKING, Any, Mapping

from ... import testing, tools
from ... import tools
from . import create

if TYPE_CHECKING:
from .classes import NestedPfLine, PfLine


class ChildFunctionality(Mapping):
def set_child(
self: NestedPfLine, name: str, child: Union[PfLine, Any]
) -> NestedPfLine:
def set_child(self: NestedPfLine, name: str, child: PfLine | Any) -> NestedPfLine:
"""Set/add/update child; returns new pfline instance without changing current instance."""
if name in ["w", "q", "p", "r"]:
raise ValueError("Name cannot be one of 'w', 'q', 'p', 'r'.")
Expand All @@ -28,7 +26,7 @@ def set_child(
f"Incompatible kinds; the portfolio line has {self.kind} but the child has {child.kind}."
)
try:
testing.assert_indices_compatible(self.index, child.index)
tools.testing.assert_indices_compatible(self.index, child.index)
except AssertionError as e:
raise ValueError(
"Index of new child is not compatible with the existing data."
Expand Down
Loading
Loading