Compare commits

...

2 Commits

Author SHA1 Message Date
Emilia Allison 72d81439c1
fix: custom get_destination_wells
Gitea Scan/plate-tool/pipeline/head This commit looks good Details
The code here was like, stupid tbh.
2024-02-13 21:54:23 -05:00
Emilia Allison 94cb530de8
Remove log line 2024-02-13 21:10:31 -05:00
2 changed files with 23 additions and 22 deletions

View File

@ -109,22 +109,24 @@ impl TransferRegion {
} }
pub fn get_destination_wells(&self) -> Vec<(u8, u8)> { pub fn get_destination_wells(&self) -> Vec<(u8, u8)> {
match &self.source_region {
Region::Custom(c) => c.dest.clone(),
_ => {
let map = self.calculate_map(); let map = self.calculate_map();
let source_wells = self.get_source_wells(); let source_wells = self.get_source_wells();
let mut wells = Vec::<(u8, u8)>::new(); let mut wells = Vec::<(u8, u8)>::new();
// log::debug!("GDW:");
for well in source_wells { for well in source_wells {
if let Some(mut dest_wells) = map(well) { if let Some(mut dest_wells) = map(well) {
// log::debug!("Map {:?} to {:?}", well, dest_wells);
wells.append(&mut dest_wells); wells.append(&mut dest_wells);
} }
} }
// log::debug!("GDW END.");
wells wells
} }
}
}
#[allow(clippy::type_complexity)] // Resolving gives inherent associated type error #[allow(clippy::type_complexity)] // Resolving gives inherent associated type error
pub fn calculate_map(&self) -> Box<dyn Fn((u8, u8)) -> Option<Vec<(u8, u8)>> + '_> { pub fn calculate_map(&self) -> Box<dyn Fn((u8, u8)) -> Option<Vec<(u8, u8)>> + '_> {
@ -204,14 +206,16 @@ impl TransferRegion {
// How many times can we replicate? // How many times can we replicate?
(1..) (1..)
.position(|n| { .position(|n| {
n * number_used_src_wells.0 * il_dest.0.unsigned_abs() - il_dest.0.unsigned_abs() n * number_used_src_wells.0 * il_dest.0.unsigned_abs()
- il_dest.0.unsigned_abs()
+ 1 + 1
> d_dims.0 > d_dims.0
}) })
.unwrap() as u8, .unwrap() as u8,
(1..) (1..)
.position(|n| { .position(|n| {
n * number_used_src_wells.1 * il_dest.1.unsigned_abs() - il_dest.1.unsigned_abs() n * number_used_src_wells.1 * il_dest.1.unsigned_abs()
- il_dest.1.unsigned_abs()
+ 1 + 1
> d_dims.1 > d_dims.1
}) })
@ -242,14 +246,12 @@ impl TransferRegion {
.filter(|(x, y)| { .filter(|(x, y)| {
// How many times have we replicated? < How many are we allowed // How many times have we replicated? < How many are we allowed
// to replicate? // to replicate?
x.checked_sub(d_ul.0) x.checked_sub(d_ul.0).unwrap().div_euclid(
.unwrap() number_used_src_wells.0 * il_dest.0.unsigned_abs(),
.div_euclid(number_used_src_wells.0 * il_dest.0.unsigned_abs()) ) < count.0
< count.0 && y.checked_sub(d_ul.1).unwrap().div_euclid(
&& y.checked_sub(d_ul.1) number_used_src_wells.1 * il_dest.1.unsigned_abs(),
.unwrap() ) < count.1
.div_euclid(number_used_src_wells.1 * il_dest.1.unsigned_abs())
< count.1
}) })
.collect(), .collect(),
) )

View File

@ -1,7 +1,6 @@
pub fn letters_to_num(letters: &str) -> Option<u8> { pub fn letters_to_num(letters: &str) -> Option<u8> {
let mut num: u8 = 0; let mut num: u8 = 0;
for (i, letter) in letters.to_ascii_uppercase().chars().rev().enumerate() { for (i, letter) in letters.to_ascii_uppercase().chars().rev().enumerate() {
log::debug!("{}, {}", i, letter);
let n = letter as u8; let n = letter as u8;
if !(65..=90).contains(&n) { if !(65..=90).contains(&n) {
return None; return None;