MCPcopy Create free account
hub / github.com/Open-Quant/openquant / plot_clusters

Method plot_clusters

crates/openquant/src/hrp.rs:98–114  ·  view source on GitHub ↗
(&self, assets: &[String])

Source from the content-addressed store, hash-verified

96 }
97
98 pub fn plot_clusters(&self, assets: &[String]) -> Result<HrpDendrogram, HrpError> {
99 if self.clusters.is_empty() || self.ordered_indices.is_empty() {
100 return Err(HrpError::MissingClusters);
101 }
102 let mut icoord = Vec::with_capacity(self.clusters.len());
103 let mut dcoord = Vec::with_capacity(self.clusters.len());
104 let mut color_list = Vec::with_capacity(self.clusters.len());
105 for (i, _) in self.clusters.iter().enumerate() {
106 let x0 = (i * 10) as f64;
107 icoord.push([x0, x0 + 2.5, x0 + 7.5, x0 + 10.0]);
108 dcoord.push([0.0, 1.0, 1.0, 0.0]);
109 color_list.push("C0".to_string());
110 }
111 let leaves = self.ordered_indices.clone();
112 let ivl = leaves.iter().map(|i| assets[*i].clone()).collect();
113 Ok(HrpDendrogram { icoord, dcoord, ivl, leaves, color_list })
114 }
115}
116
117fn freq_step(resample_by: Option<&str>) -> usize {

Callers 1

test_dendrogram_plotFunction · 0.80

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.80

Tested by 1

test_dendrogram_plotFunction · 0.64