Skip to content

Don't divide by zero #53

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

Merged
merged 1 commit into from
May 28, 2022
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
8 changes: 8 additions & 0 deletions partitionmanager/table_append_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
more, and returns a final list of weighted partition-position-increase-per-
day, with one entry per column.
"""
log = logging.getLogger("get_weighted_position_increase_per_day_for_partitions")

if not partitions:
raise ValueError("Partition list must not be empty")

Expand All @@ -279,6 +281,12 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
]
weights = _generate_weights(len(pos_rates))

if not pos_rates or not weights:
log.error(
"No rates of change were valid for the partition list: %s", partitions
)
raise ValueError("No valid rates of change")

# Initialize a list with a zero for each position
weighted_sums = [0] * partitions[0].num_columns

Expand Down