MCPcopy
hub / github.com/ray-project/ray / from_values

Method from_values

python/ray/serve/schema.py:1602–1619  ·  view source on GitHub ↗

Compute statistics from a list of values.

(cls, values: List[float])

Source from the content-addressed store, hash-verified

1600
1601 @classmethod
1602 def from_values(cls, values: List[float]) -> "DurationStats":
1603 """Compute statistics from a list of values."""
1604 if not values:
1605 return cls()
1606
1607 n = len(values)
1608 mean = sum(values) / n
1609 min_val = min(values)
1610 max_val = max(values)
1611
1612 # Compute standard deviation
1613 if n > 1:
1614 variance = sum((x - mean) ** 2 for x in values) / n
1615 std = math.sqrt(variance)
1616 else:
1617 std = 0.0
1618
1619 return cls(mean=mean, std=std, min=min_val, max=max_val)
1620
1621
1622@PublicAPI(stability="alpha")

Callers 4

collect_metricsMethod · 0.80
test_empty_valuesMethod · 0.80
test_single_valueMethod · 0.80
test_multiple_valuesMethod · 0.80

Calls 2

clsClass · 0.85
sumFunction · 0.50

Tested by 3

test_empty_valuesMethod · 0.64
test_single_valueMethod · 0.64
test_multiple_valuesMethod · 0.64