Skip to content

Commit

Permalink
pre-commit issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgitonga committed Dec 6, 2023
1 parent 62294f6 commit b9d17e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
author = "Wildlife Dynamics"

source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
".rst": "restructuredtext",
".md": "markdown",
}


Expand Down
22 changes: 11 additions & 11 deletions ecoscope/analysis/seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ def seasonal_windows(ndvi_vals, cuts, season_labels):
).set_index("unique_season")


def add_seasonal_index(df, index_name, start_date, end_date, aoi_geom_filter=None, seasons=2, season_labels=["dry", "wet"]):

def add_seasonal_index(
df, index_name, start_date, end_date, aoi_geom_filter=None, seasons=2, season_labels=["dry", "wet"]
):

aoi_ = None
try:
aoi_ = aoi_geom_filter.dissolve().iloc[0]['geometry']
aoi_ = aoi_geom_filter.dissolve().iloc[0]["geometry"]
except:
aoi_ = aoi_geom_filter

if len(season_labels) != seasons:
raise Exception(f"Parameter value 'seasons' ({seasons}) must match the number of 'season_labels' elements ({season_labels})")
raise Exception(
f"Parameter value 'seasons' ({seasons}) must match the number of 'season_labels' elements ({season_labels})"
)
# extract the standardized NDVI ndvi_vals within the AOI
ndvi_vals = std_ndvi_vals(
aoi_,
start=since_filter.isoformat(),
end=until_filter.isoformat()
)
ndvi_vals = std_ndvi_vals(aoi_, start=since_filter.isoformat(), end=until_filter.isoformat())

# calculate the seasonal transition point
cuts = val_cuts(ndvi_vals, seasons)
Expand All @@ -135,7 +135,7 @@ def add_seasonal_index(df, index_name, start_date, end_date, aoi_geom_filter=Non
# Categorize the fixtime values according to the season
bins = pandas.IntervalIndex(data=windows.apply(lambda x: pandas.Interval(x["start"], x["end"]), axis=1))
labels = windows.season
df[index_name] = pandas.cut(df[time_col], bins=bins).map(dict(zip(bins,labels)))
df[index_name] = pandas.cut(df[time_col], bins=bins).map(dict(zip(bins, labels)))

# set the index
return df.set_index(index_name, append=True)
return df.set_index(index_name, append=True)
2 changes: 1 addition & 1 deletion ecoscope/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ def add_temporal_index(df, index_name, time_col, directive):
df[index_name] = df[time_col].dt.strftime(directive)
return df.set_index(index_name, append=True)
else:
return df
return df

0 comments on commit b9d17e0

Please sign in to comment.