chore: clippy & fmt

This commit is contained in:
Emilia Allison 2023-06-15 22:23:12 -04:00
parent 28c1716f17
commit 6aee3ded2c
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
5 changed files with 46 additions and 46 deletions

View File

@ -64,7 +64,7 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
.transfers
.iter()
.filter(|t| t.dest_id == props.destination_plate.get_uuid());
let mut tooltip_map: HashMap<(u8,u8), Vec<&Transfer>> = HashMap::new();
let mut tooltip_map: HashMap<(u8, u8), Vec<&Transfer>> = HashMap::new();
for t in ts {
let dws = t.transfer_region.get_destination_wells();
for dw in dws {
@ -120,10 +120,8 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
.map(|t| PALETTE.get_uuid(t.get_uuid()))
}
cell_height={props.cell_height}
title={if let Some(transfers) = transfer_map.get(&(i,j)) {
Some(format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
.collect::<Vec<_>>().join(", ")))
} else { None }}
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
.collect::<Vec<_>>().join(", ")))}
/>
}
}).collect::<Html>();
@ -136,7 +134,7 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
.collect::<Html>();
html! {
<div class={classes!{"dest_plate",
<div class={classes!{"dest_plate",
"W".to_owned()+&props.source_plate.plate.plate_format.to_string()}}>
<table
onmouseup={move |e| {
@ -179,10 +177,7 @@ fn DestPlateCell(props: &DestPlateCellProps) -> Html {
Some(true) => Some("in_transfer"),
_ => None,
};
let color = match props.color {
Some(num) => num,
None => [255.0, 255.0, 255.0],
};
let color = props.color.unwrap_or([255.0, 255.0, 255.0]);
let mouse = Callback::clone(&props.mouse);
let mouse2 = Callback::clone(&props.mouse);
let (i, j) = (props.i, props.j);

View File

@ -1,6 +1,6 @@
#![allow(non_snake_case)]
use wasm_bindgen::JsCast;
use wasm_bindgen::prelude::Closure;
use wasm_bindgen::JsCast;
use yew::prelude::*;
use crate::data::plate_instances::PlateInstance;
@ -16,26 +16,36 @@ pub struct PlateContainerProps {
#[function_component]
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
let cell_height = {
let height = web_sys::window().unwrap().inner_height().unwrap().as_f64().unwrap();
let width = web_sys::window().unwrap().inner_width().unwrap().as_f64().unwrap();
if let (Some(src_d), Some(dest_d)) = (&props.source_dims, &props.destination_dims) {
let h =
(0.78*height)/(src_d.plate.size().0 + dest_d.plate.size().0) as f64;
let w =
(0.90*width)/(src_d.plate.size().1 + dest_d.plate.size().1) as f64;
f64::min(w,h)
} else {
1f64
}
};
let cell_height = {
let height = web_sys::window()
.unwrap()
.inner_height()
.unwrap()
.as_f64()
.unwrap();
let width = web_sys::window()
.unwrap()
.inner_width()
.unwrap()
.as_f64()
.unwrap();
if let (Some(src_d), Some(dest_d)) = (&props.source_dims, &props.destination_dims) {
let h = (0.78 * height) / (src_d.plate.size().0 + dest_d.plate.size().0) as f64;
let w = (0.90 * width) / (src_d.plate.size().1 + dest_d.plate.size().1) as f64;
f64::min(w, h)
} else {
1f64
}
};
let resize_trigger = use_force_update();
let onresize = Closure::<dyn FnMut(_)>::new(move |_: Event| {
resize_trigger.force_update();
});
web_sys::window().unwrap().set_onresize(Some(onresize.as_ref().unchecked_ref()));
onresize.forget(); // Magic!
let resize_trigger = use_force_update();
let onresize = Closure::<dyn FnMut(_)>::new(move |_: Event| {
resize_trigger.force_update();
});
web_sys::window()
.unwrap()
.set_onresize(Some(onresize.as_ref().unchecked_ref()));
onresize.forget(); // Magic!
html! {
<div class="plate_container">

View File

@ -44,7 +44,7 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
.transfers
.iter()
.filter(|t| t.source_id == props.source_plate.get_uuid());
let mut tooltip_map: HashMap<(u8,u8), Vec<&Transfer>> = HashMap::new();
let mut tooltip_map: HashMap<(u8, u8), Vec<&Transfer>> = HashMap::new();
for t in ts {
let sws = t.transfer_region.get_source_wells();
for sw in sws {
@ -103,8 +103,8 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
let headers = (1..=props.source_plate.plate.size().1)
.map(|j| {
html! {<th>
{format!("{:0>2}", j)}
</th>}
{format!("{:0>2}", j)}
</th>}
})
.collect::<Html>();
html! {<tr><th />{ headers }</tr>}
@ -124,10 +124,8 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
.map(|t| PALETTE.get_uuid(t.get_uuid()))
}
cell_height={props.cell_height}
title={if let Some(transfers) = transfer_map.get(&(i,j)) {
Some(format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
.collect::<Vec<_>>().join(", ")))
} else { None }}
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
.collect::<Vec<_>>().join(", ")))}
/>
}
})
@ -184,10 +182,7 @@ fn SourcePlateCell(props: &SourcePlateCellProps) -> Html {
Some(true) => Some("in_transfer"),
_ => None,
};
let color = match props.color {
Some(num) => num,
None => [255.0, 255.0, 255.0],
};
let color = props.color.unwrap_or([255.0, 255.0, 255.0]);
let mouse = Callback::clone(&props.mouse);
let mouse2 = Callback::clone(&props.mouse);
let (i, j) = (props.i, props.j);
@ -279,7 +274,7 @@ mod tests {
let c2 = (10, 10);
let pt1 = (0, 0);
let pt2 = (15, 15);
assert_eq!(false, in_rect(Some(c1), Some(c2), pt1));
assert_eq!(false, in_rect(Some(c1), Some(c2), pt2));
assert!(!in_rect(Some(c1), Some(c2), pt1));
assert!(!in_rect(Some(c1), Some(c2), pt2));
}
}

View File

@ -26,9 +26,9 @@ impl ColorPalette {
]
}
pub fn get_u8(&self, t: u8) -> [f64; 3] {
pub fn _get_u8(&self, t: u8) -> [f64; 3] {
assert!(t > 0, "t must be greater than zero!");
self.get((2f64.powi(-1*t.ilog2() as i32)) as f64 * (t as f64 + 0.5f64)-1.0f64)
self.get((2f64.powi(-(t.ilog2() as i32))) * (t as f64 + 0.5f64) - 1.0f64)
}
pub fn get_uuid(&self, t: uuid::Uuid) -> [f64; 3] {

View File

@ -454,7 +454,7 @@ mod tests {
Some("BJ".to_string())
);
for i in 1..=255 {
assert_eq!(letters_to_num(&num_to_letters(i as u8).unwrap()), Some(i));
assert_eq!(letters_to_num(&num_to_letters(i).unwrap()), Some(i));
}
}