Skip to content

Commit

Permalink
Merge pull request #58 from GreenScheduler/remove_sort_index_from_dat…
Browse files Browse the repository at this point in the history
…aclass

Remove sort_index from dataclass as not needed
  • Loading branch information
ljcolling authored Jul 31, 2023
2 parents 9c0c352 + 785cb40 commit 0b574d4
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions cats/forecast.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
from dataclasses import dataclass, field
from dataclasses import dataclass
from datetime import datetime


@dataclass(order=True)
class CarbonIntensityPointEstimate:
"""Represents a single data point within an intensity
timeseries. Use order=True in order to enable comparison of class
instance based on the sort_index attribute. See
instance based on the first attribute. See
https://peps.python.org/pep-0557
"""
sort_index: float = field(init=False, repr=False)
value: float # the first attribute is used automatically for sorting methods
datetime: datetime
value: float

def __post_init__(self):
self.sort_index = self.value


@dataclass(order=True)
class CarbonIntensityAverageEstimate:
"""Represents a single data point within an *integrated* carbon
intensity timeseries. Use order=True in order to enable comparison
of class instance based on the sort_index attribute. See
of class instance based on the first attribute. See
https://peps.python.org/pep-0557
"""
sort_index: float = field(init=False, repr=False)
value: float
start: datetime # Start of the time-integration window
end: datetime # End of the time-integration window
value: float

def __post_init__(self):
self.sort_index = self.value


class WindowedForecast:
Expand Down

0 comments on commit 0b574d4

Please sign in to comment.