Skip to content

Commit

Permalink
preview line length changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsheni committed Jan 2, 2023
1 parent 6e884f3 commit bb215e4
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ repos:
rev: v0.10.1
hooks:
- id: validate-pyproject
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.202
hooks:
- id: ruff
- repo: https://github.com/python/black
rev: 22.12.0
hooks:
- id: black
additional_dependencies: [".[jupyter]"]
types_or: [python, jupyter]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.202
hooks:
- id: ruff
9 changes: 6 additions & 3 deletions gridstatus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ def get_fuel_mix(self, date, end=None, verbose=False):
"""Get fuel mix in 5 minute intervals for a provided day
Arguments:
date (datetime or str): "latest", "today", or an object that can be parsed as a datetime for the day to return data.
date (datetime or str): "latest", "today", or an object that can be parsed
as a datetime for the day to return data.
start (datetime or str): start of date range to return. alias for `date` parameter. Only specify one of `date` or `start`.
start (datetime or str): start of date range to return. alias for `date` parameter.
Only specify one of `date` or `start`.
end (datetime or str): "today" or an object that can be parsed as a datetime for the day to return data. Only used if requesting a range of dates.
end (datetime or str): "today" or an object that can be parsed as a datetime for the
day to return data. Only used if requesting a range of dates.
verbose (bool): print verbose output. Defaults to False.
Expand Down
22 changes: 15 additions & 7 deletions gridstatus/caiso.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def get_fuel_mix(self, date, end=None, verbose=False):
return self._get_historical_fuel_mix(date, verbose=verbose)

def _get_historical_fuel_mix(self, date, verbose=False):

url = _HISTORY_BASE + "/%s/fuelsource.csv"
df = _get_historical(url, date, verbose=verbose)

Expand Down Expand Up @@ -431,14 +430,24 @@ def get_interconnection_queue(self, verbose=False):

queue = queue.rename(
columns={
"Interconnection Request\nReceive Date": "Interconnection Request Receive Date",
"Interconnection Request\nReceive Date": (
"Interconnection Request Receive Date"
),
"Actual\nOn-line Date": "Actual On-line Date",
"Current\nOn-line Date": "Current On-line Date",
"Interconnection Agreement \nStatus": "Interconnection Agreement Status",
"Interconnection Agreement \nStatus": (
"Interconnection Agreement Status"
),
"Study\nProcess": "Study Process",
"Proposed\nOn-line Date\n(as filed with IR)": "Proposed On-line Date (as filed with IR)",
"System Impact Study or \nPhase I Cluster Study": "System Impact Study or Phase I Cluster Study",
"Facilities Study (FAS) or \nPhase II Cluster Study": "Facilities Study (FAS) or Phase II Cluster Study",
"Proposed\nOn-line Date\n(as filed with IR)": (
"Proposed On-line Date (as filed with IR)"
),
"System Impact Study or \nPhase I Cluster Study": (
"System Impact Study or Phase I Cluster Study"
),
"Facilities Study (FAS) or \nPhase II Cluster Study": (
"Facilities Study (FAS) or Phase II Cluster Study"
),
"Optional Study\n(OS)": "Optional Study (OS)",
},
)
Expand Down Expand Up @@ -758,7 +767,6 @@ def _make_timestamp(time_str, today, timezone="US/Pacific"):


def _get_historical(url, date, verbose=False):

date_str = date.strftime("%Y%m%d")
date_obj = date
url = url % date_str
Expand Down
1 change: 0 additions & 1 deletion gridstatus/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def wrapped_f(*args, **kwargs):
total = len(dates) - dates.count(None) * 2 - 1

with tqdm.tqdm(disable=total <= 1, total=total) as pbar:

for end_date in dates[1:]:
# if we come across None, it means we should reset
if end_date is None:
Expand Down
1 change: 0 additions & 1 deletion gridstatus/miso.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def get_load(self, date, verbose=False):
raise NotSupported

def get_load_forecast(self, date, verbose=False):

if date != "today":
raise NotSupported()

Expand Down
3 changes: 0 additions & 3 deletions gridstatus/nyiso.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class NYISO(ISOBase):

@support_date_range(frequency="MS")
def get_status(self, date, end=None, verbose=False):

if date == "latest":
latest = self._latest_from_today(self.get_status)
return GridStatus(
Expand Down Expand Up @@ -589,7 +588,6 @@ def _download_nyiso_archive(
filename=None,
verbose=False,
):

if filename is None:
filename = dataset_name

Expand All @@ -607,7 +605,6 @@ def _download_nyiso_archive(
if end is None and date > pd.Timestamp.now(
tz=self.default_timezone,
).normalize() - pd.DateOffset(days=7):

if verbose:
print(f"Requesting {csv_url}")

Expand Down
16 changes: 12 additions & 4 deletions gridstatus/pjm.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ def get_lmp(
market_type = "da"
else:
raise ValueError(
"market must be one of REAL_TIME_5_MIN, REAL_TIME_HOURLY, DAY_AHEAD_HOURLY",
(
"market must be one of REAL_TIME_5_MIN, REAL_TIME_HOURLY,"
" DAY_AHEAD_HOURLY"
),
)

if location_type:
Expand All @@ -279,7 +282,10 @@ def get_lmp(

if market == Markets.REAL_TIME_5_MIN:
warnings.warn(
"When using Real Time 5 Minute market, location_type filter will happen after all data is downloaded",
(
"When using Real Time 5 Minute market, location_type filter"
" will happen after all data is downloaded"
),
)
else:
params["type"] = f"*{location_type}*"
Expand All @@ -298,7 +304,10 @@ def get_lmp(

elif locations is not None:
warnings.warn(
"Querying before archive date, so filtering by location will happen after all data is downloaded",
(
"Querying before archive date, so filtering by location will happen"
" after all data is downloaded"
),
)

data = self._get_pjm_json(
Expand Down Expand Up @@ -524,7 +533,6 @@ def _get_key(self):


if __name__ == "__main__":

import gridstatus

for i in gridstatus.all_isos:
Expand Down
20 changes: 14 additions & 6 deletions gridstatus/spp.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def get_status(self, date=None, verbose=False):

if (
status_text
== "SPP is currently in Normal Operations with no effective advisories or alerts."
== "SPP is currently in Normal Operations with no effective advisories or"
" alerts."
):
status = "Normal"
notes = [status_text]
Expand All @@ -116,7 +117,6 @@ def get_status(self, date=None, verbose=False):
)

def get_fuel_mix(self, date, verbose=False):

if date != "latest":
raise NotSupported

Expand Down Expand Up @@ -159,7 +159,8 @@ def get_load(self, date, verbose=False):
def get_load_forecast(self, date, forecast_type="MID_TERM", verbose=False):
"""
type (str): MID_TERM is hourly for next 7 days or SHORT_TERM is every five minutes for a few hours
type (str): MID_TERM is hourly for next 7 days or
SHORT_TERM is every five minutes for a few hours
"""
df = self._get_load_and_forecast(verbose=verbose)

Expand Down Expand Up @@ -276,7 +277,8 @@ def get_interconnection_queue(self, verbose=False):
"Substation or Line": "Interconnection Location",
}

# todo: there are a few columns being parsed as "unamed" that aren't being included but should
# todo: there are a few columns being parsed
# as "unamed" that aren't being included but should
extra_columns = [
"In-Service Date",
"Commercial Operation Date",
Expand Down Expand Up @@ -552,7 +554,10 @@ def _get_location_list(self, location_type, verbose=False):
return df["SETTLEMENT_LOCATION"].unique().tolist()

def _fs_get_rtbm_lmp_by_location_paths(self, date, verbose=False):
"""Lists files for Real-Time Balancing Market (RTBM), Locational Marginal Price (LMP) by Settlement Location (SL)"""
"""
Lists files for Real-Time Balancing Market (RTBM),
Locational Marginal Price (LMP) by Settlement Location (SL)
"""
if date == "latest":
paths = ["/RTBM-LMP-SL-latestInterval.csv"]
elif utils.is_today(date, self.default_timezone):
Expand Down Expand Up @@ -582,7 +587,10 @@ def _fetch_and_concat_csvs(self, paths: list, fs_name: str, verbose: bool = Fals
return pd.concat(all_dfs)

def _fs_get_dam_lmp_by_location_paths(self, date, verbose=False):
"""Lists files for Day-ahead Market (DAM), Locational Marginal Price (LMP) by Settlement Location (SL)"""
"""
Lists files for Day-ahead Market (DAM),
Locational Marginal Price (LMP) by Settlement Location (SL)
"""
paths = []
if date == "latest":
raise ValueError(
Expand Down
1 change: 0 additions & 1 deletion gridstatus/tests/test_ercot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def test_ercot_get_load_3_days_ago():


def test_ercot_get_fuel_mix():

# today
iso = gridstatus.Ercot()
cols = [
Expand Down
4 changes: 2 additions & 2 deletions gridstatus/tests/test_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def test_dam_heat_map():

iso = gridstatus.CAISO()

df = iso.get_lmp(
Expand All @@ -21,7 +20,8 @@ def test_dam_heat_map():
assert isinstance(fig, plotly.graph_objs._figure.Figure)

# check if works with hour too
# not the best test since we dont know if the viz is actually using it instead of time
# not the best test since we dont know if
# the viz is actually using it instead of time
df["Hour"] = df["Time"].dt.hour
fig = gridstatus.viz.dam_heat_map(df)
assert isinstance(fig, plotly.graph_objs._figure.Figure)
4 changes: 2 additions & 2 deletions gridstatus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def make_availability_df():
for method in methods:
availability[i.__name__][method] = {}
for date in ["latest", "today", "historical"]:

test = date
if date == "historical":
test = pd.Timestamp.now(
Expand Down Expand Up @@ -240,7 +239,8 @@ def load_folder(path, time_zone=None, verbose=True):
Arguments:
path {str} -- path to folder
time_zone {str} -- time zone to localize to timestamps. By default returns as UTC
time_zone {str} -- time zone to localize to timestamps.
By default returns as UTC
Returns:
pd.DataFrame -- dataframe of all files
Expand Down
3 changes: 2 additions & 1 deletion gridstatus/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def dam_heat_map(df):
Args:
df (pd.DataFrame): A DataFrame with columns "Time", "Location", and "LMP".
If Hour is specified, it will be used as the x-axis. Otherwise, the hour ending will be used instead of Time
If Hour is specified, it will be used as the x-axis.
Otherwise, the hour ending will be used instead of Time
Returns:
Expand Down

0 comments on commit bb215e4

Please sign in to comment.