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

Enumeration comparisons changed from usage of is to == #559

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
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
21 changes: 10 additions & 11 deletions src/climate_indices/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,15 @@ def spi(
# by the specified number of time steps
values = compute.sum_to_scale(values, scale)

# reshape precipitation values to (years, 12) for monthly,
# or to (years, 366) for daily
if periodicity is compute.Periodicity.monthly:
values = utils.reshape_to_2d(values, 12)
elif periodicity is compute.Periodicity.daily:
# reshape precipitation values to (years, 12) for monthly, or to (years, 366) for daily
if periodicity == compute.Periodicity.monthly:
values = utils.reshape_to_2d(values, 12)
elif periodicity == compute.Periodicity.daily:
values = utils.reshape_to_2d(values, 366)
else:
raise ValueError(f"Invalid periodicity argument: {periodicity}")
raise ValueError(f"Invalid periodicity argument: '{periodicity}'")

if distribution is Distribution.gamma:
if distribution == Distribution.gamma:
# get (optional) fitting parameters if provided
if fitting_params is not None:
alphas = fitting_params["alpha"]
Expand All @@ -166,7 +165,7 @@ def spi(
alphas,
betas,
)
elif distribution is Distribution.pearson:
elif distribution == Distribution.pearson:
# get (optional) fitting parameters if provided
if fitting_params is not None:
probabilities_of_zero = fitting_params["prob_zero"]
Expand Down Expand Up @@ -194,7 +193,7 @@ def spi(
)

else:
message = f"Unsupported distribution argument: {distribution}"
message = f"Unsupported distribution argument: '{distribution}'"
_logger.error(message)
raise ValueError(message)

Expand Down Expand Up @@ -398,9 +397,9 @@ def percentage_of_normal(

# if doing monthly then we'll use 12 periods, corresponding to calendar
# months, if daily assume years w/366 days
if periodicity is compute.Periodicity.monthly:
if periodicity == compute.Periodicity.monthly:
periodicity = 12
elif periodicity is compute.Periodicity.daily:
elif periodicity == compute.Periodicity.daily:
periodicity = 366
else:
message = f"Invalid periodicity argument: '{periodicity}'"
Expand Down
Loading