6b7e6b44f1
gh-pages / build (push) Waiting to run
Python Publish (pypi) / Upload release to PyPI (push) Waiting to run
Spellcheck / spellcheck (push) Waiting to run
Python Build and Type Check / python-ci (ubuntu-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
|
|
"""LiteLLM Test Utilities."""
|
|
|
|
|
|
def bin_time_intervals(
|
|
time_values: list[float], time_interval: int
|
|
) -> list[list[float]]:
|
|
"""Bin values."""
|
|
bins: list[list[float]] = []
|
|
|
|
bin_number = 0
|
|
for time_value in time_values:
|
|
upper_bound = (bin_number * time_interval) + time_interval
|
|
while time_value >= upper_bound:
|
|
bin_number += 1
|
|
upper_bound = (bin_number * time_interval) + time_interval
|
|
while len(bins) <= bin_number:
|
|
bins.append([])
|
|
bins[bin_number].append(time_value)
|
|
|
|
return bins
|
|
|
|
|
|
def assert_max_num_values_per_period(
|
|
periods: list[list[float]], max_values_per_period: int
|
|
):
|
|
"""Assert the number of values per period."""
|
|
for period in periods:
|
|
assert len(period) <= max_values_per_period
|
|
|
|
|
|
def assert_stagger(time_values: list[float], stagger: float):
|
|
"""Assert stagger."""
|
|
for i in range(1, len(time_values)):
|
|
assert time_values[i] - time_values[i - 1] >= stagger
|