Connection
Base URL, credentials and a reachable server.
Use histogram.py to verify which bin owns an observation exactly equal to an internal or final edge.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
import bisect, math
def histogram(edges, values):
if type(edges) is not list or type(values) is not list or not 2 <= len(edges) <= 257 or len(values) > 4096:
raise ValueError("bins.shape")
if any(type(x) not in (int, float) or not -10**100 <= x <= 10**100 or not math.isfinite(x) for x in edges+values):
raise ValueError("bins.value")
if any(a >= b for a, b in zip(edges, edges[1:])):
raise ValueError("bins.edges")
counts, under, over = [0]*(len(edges)-1), 0, 0
for value in values:
if value < edges[0]:
under += 1
elif value > edges[-1]:
over += 1
else:
counts[min(bisect.bisect_right(edges, value)-1, len(counts)-1)] += 1
return counts, under, over