Skip to content

Commit

Permalink
Clean, fix wasm32 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Sep 19, 2024
1 parent 32048dc commit c4fd6d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
22 changes: 3 additions & 19 deletions src/nested/map/astrometry/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//!
use std::ops::{Add, Sub};

use num_traits::FloatConst;

use crate::Customf64;

pub trait HasLocalRotMatrix {
Expand Down Expand Up @@ -335,7 +333,8 @@ impl M3x3 {
/// obtained by:
/// * a first rotation of `angle_z_rad` radians around the `z-axis`, leading to `x'y'z'`
/// * a second rotation of `angle_yp_rad` radians around the `y'-axis`, leading to `x''y''z''`
/// * a thrid rotation of `angle_zpp_rad` radians around the `z''-axis`, leading to `XYZ`
/// * a thrid rotation of `angle_zpp_rad` radians around the `z''-axis`, leading to `XYZ`
#[allow(dead_code)]
fn from_zyz_euler_intrinsic(angle_z_rad: f64, angle_yp_rad: f64, angle_zpp_rad: f64) -> Self {
// z1-y′-z2″ (intrinsic rotations) or z2-y-z1 (extrinsic rotations)
let (s1, c1) = angle_z_rad.sin_cos();
Expand Down Expand Up @@ -501,22 +500,7 @@ impl M3x3 {
#[cfg(test)]
mod tests {

use super::{M3x3, XYZt};
// use crate::qty::{coo::Coo, HasLocalRotMatrix};

fn relative_diff(theo: f64, meas: f64) -> f64 {
(meas - theo).abs() / theo
}

fn assert_eq_f64(theo: f64, meas: f64) {
assert!(
relative_diff(theo, meas) < 1.0e-13,
"{:e} != {:e}: rdiff: {:e}",
theo,
meas,
relative_diff(theo, meas)
)
}
use super::M3x3;

#[test]
fn test_from_zyz_euler_intrinsic() {
Expand Down
7 changes: 4 additions & 3 deletions src/nested/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ pub mod skymap;
#[cfg(test)]
mod tests {
use super::{
img::{to_png_file, ColorMapFunctionType, PosConversion},
skymap::*,
img::{ColorMapFunctionType, PosConversion},
skymap::SkyMap,
};
use mapproj::pseudocyl::mol::Mol;

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn test_skymap() {
let mut path = "test/resources/skymap/skymap.fits";
let path = "test/resources/skymap/skymap.fits";
let skymap = SkyMap::from_fits_file(path).unwrap();
skymap
.to_png_file::<Mol, _>(
Expand Down
7 changes: 6 additions & 1 deletion src/nested/map/skymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ use mapproj::CanonicalProjection;
// Make a trait SkyMap: Iterable<Item=(u64, V)> { depth(), get(hash) }
// => Make a map from a FITS file without loading data in memory (bot implicit and explicit)

#[cfg(not(target_arch = "wasm32"))]
use super::img::show_with_default_app;
use super::{
fits::{error::FitsError, read::from_fits_skymap, write::write_implicit_skymap_fits},
img::{show_with_default_app, to_png, ColorMapFunctionType, PosConversion},
img::{to_png, ColorMapFunctionType, PosConversion},
};

// Implicit map
Expand All @@ -33,12 +35,14 @@ pub enum SkyMapArray {
}

impl SkyMap {
#[cfg(not(target_arch = "wasm32"))]
pub fn from_fits_file<P: AsRef<Path>>(path: P) -> Result<Self, FitsError> {
File::open(path)
.map_err(FitsError::Io)
.map(BufReader::new)
.and_then(SkyMap::from_fits)
}

pub fn from_fits<R: Read + Seek>(reader: BufReader<R>) -> Result<Self, FitsError> {
from_fits_skymap(reader)
}
Expand All @@ -54,6 +58,7 @@ impl SkyMap {
}
}

#[cfg(not(target_arch = "wasm32"))]
pub fn to_png_file<P: CanonicalProjection, W: AsRef<Path>>(
&self,
img_size: (u16, u16),
Expand Down

0 comments on commit c4fd6d3

Please sign in to comment.