Skip to content

Commit

Permalink
Remove spurious import and clean a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Oct 4, 2024
1 parent 83edacd commit 0909cf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
11 changes: 6 additions & 5 deletions src/nested/map/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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<P>,
Expand All @@ -857,17 +857,18 @@ pub fn to_mom_png_file<'a, M, P>(
pos_convert: Option<PosConversion>,
color_map: Option<Gradient>,
color_map_func_type: Option<ColorMapFunctionType>,
path: &Path,
path: A,
view: bool,
) -> Result<(), Box<dyn Error>>
where
P: CanonicalProjection,
M: Mom<'a>,
M::ValueType: Val,
A: AsRef<Path>,
{
// 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,
Expand All @@ -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(())
}
Expand Down
16 changes: 7 additions & 9 deletions src/nested/map/mom/impls/zvec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::os::linux::raw::stat;
use std::{iter::Map, slice::Iter};

use super::super::{
Expand Down Expand Up @@ -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,
},
};

Expand Down Expand Up @@ -246,7 +244,7 @@ mod tests {
.collect::<Vec<(u64, f64)>>(),
};

to_mom_png_file::<'_, _, Mol>(
to_mom_png_file::<'_, _, Mol, _>(
&mom,
(1600, 800),
None,
Expand All @@ -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();
Expand Down Expand Up @@ -325,7 +323,7 @@ mod tests {
.collect::<Vec<(u64, f64)>>(),
};

to_mom_png_file::<'_, _, Mol>(
to_mom_png_file::<'_, _, Mol, _>(
&mom,
(1600, 800),
None,
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/nested/map/mom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 0909cf4

Please sign in to comment.