From 0909cf4403405aac1df9c7af4383d01415541fe7 Mon Sep 17 00:00:00 2001 From: fxpineau Date: Fri, 4 Oct 2024 15:19:18 +0200 Subject: [PATCH] Remove spurious import and clean a few things --- src/nested/map/img.rs | 11 ++++++----- src/nested/map/mom/impls/zvec.rs | 16 +++++++--------- src/nested/map/mom/mod.rs | 3 +-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/nested/map/img.rs b/src/nested/map/img.rs index 25b7697..cefbc5b 100644 --- a/src/nested/map/img.rs +++ b/src/nested/map/img.rs @@ -615,7 +615,7 @@ where if let Some(lonlat) = img2cel.img2lonlat(&ImgXY::new(x as f64, y as f64)) { let (lon, lat) = imgpos2mappos(lonlat.lon(), lonlat.lat()); let idx = hpx.hash(lon, lat); - let color = if let Some((z_, val)) = mom + let color = if let Some((_, val)) = mom .get_cell_containing_unsafe(M::ZUniqHType::to_zuniq(depth, M::ZUniqHType::from_u64(idx))) { color_map.eval_continuous(color_map_func.value(val.to_f64())) @@ -848,7 +848,7 @@ where /// * `path`: the path of th PNG file to be written. /// * `view`: set to true to visualize the saved image. #[cfg(not(target_arch = "wasm32"))] -pub fn to_mom_png_file<'a, M, P>( +pub fn to_mom_png_file<'a, M, P, A>( mom: &'a M, img_size: (u16, u16), proj: Option

, @@ -857,17 +857,18 @@ pub fn to_mom_png_file<'a, M, P>( pos_convert: Option, color_map: Option, color_map_func_type: Option, - path: &Path, + path: A, view: bool, ) -> Result<(), Box> where P: CanonicalProjection, M: Mom<'a>, M::ValueType: Val, + A: AsRef, { // Brackets are important to be sure the file is closed before trying to open it. { - let file = File::create(path)?; + let file = File::create(path.as_ref())?; let mut writer = BufWriter::new(file); to_mom_png( mom, @@ -882,7 +883,7 @@ where )?; } if view { - show_with_default_app(path.to_string_lossy().as_ref())?; + show_with_default_app(path.as_ref().to_string_lossy().as_ref())?; } Ok(()) } diff --git a/src/nested/map/mom/impls/zvec.rs b/src/nested/map/mom/impls/zvec.rs index f40fefd..00f56b7 100644 --- a/src/nested/map/mom/impls/zvec.rs +++ b/src/nested/map/mom/impls/zvec.rs @@ -1,4 +1,3 @@ -use std::os::linux::raw::stat; use std::{iter::Map, slice::Iter}; use super::super::{ @@ -194,17 +193,16 @@ where #[cfg(test)] mod tests { - use std::{f64::consts::PI, path::Path}; + use std::f64::consts::PI; use mapproj::pseudocyl::mol::Mol; - use num::integer::Roots; use crate::{ n_hash, nested::map::{ img::{to_mom_png_file, ColorMapFunctionType, PosConversion}, - mom::{impls::zvec::MomVecImpl, Mom, ZUniqHashT}, - skymap::{SkyMap, SkyMapEnum}, + mom::{impls::zvec::MomVecImpl, ZUniqHashT}, + skymap::SkyMapEnum, }, }; @@ -246,7 +244,7 @@ mod tests { .collect::>(), }; - to_mom_png_file::<'_, _, Mol>( + to_mom_png_file::<'_, _, Mol, _>( &mom, (1600, 800), None, @@ -255,7 +253,7 @@ mod tests { Some(PosConversion::EqMap2GalImg), None, Some(ColorMapFunctionType::LinearLog), //Some(ColorMapFunctionType::LinearSqrt) - Path::new("test/resources/skymap/mom.png"), + "test/resources/skymap/mom.png", false, ) .unwrap(); @@ -325,7 +323,7 @@ mod tests { .collect::>(), }; - to_mom_png_file::<'_, _, Mol>( + to_mom_png_file::<'_, _, Mol, _>( &mom, (1600, 800), None, @@ -334,7 +332,7 @@ mod tests { Some(PosConversion::EqMap2GalImg), None, Some(ColorMapFunctionType::LinearLog), //Some(ColorMapFunctionType::LinearSqrt) - Path::new("test/resources/skymap/mom.png"), + "test/resources/skymap/mom.png", false, ) .unwrap(); diff --git a/src/nested/map/mom/mod.rs b/src/nested/map/mom/mod.rs index c57e7f3..9f5f7fb 100644 --- a/src/nested/map/mom/mod.rs +++ b/src/nested/map/mom/mod.rs @@ -75,8 +75,7 @@ pub trait ZUniqHashT: fn depth_from_zuniq(zuniq: Self) -> u8 { let n_trailing_zero = zuniq.trailing_zeros() as u8; let delta_depth = Self::div_by_dim(n_trailing_zero); - let depth = Self::MAX_DEPTH - delta_depth; - depth + Self::MAX_DEPTH - delta_depth } /// Transforms a `depth` and `hash value` tuple into a `zuniq`.