normalize_weights

Function normalize_weights 

Source
pub fn normalize_weights(weights: &[(u16, u16)]) -> Vec<NormalizedWeight>
Expand description

Normalize weights to sum to u16::MAX

§Arguments

  • weights - Vector of (uid, weight) pairs

§Returns

Vector of NormalizedWeight where weights sum to approximately u16::MAX

§Example

use bittensor_rs::utils::{normalize_weights, NormalizedWeight};

let weights = vec![(0, 100), (1, 100)];
let normalized = normalize_weights(&weights);
assert_eq!(normalized.len(), 2);