Skip to content

Commit 1f52d09

Browse files
authored
Add Pedantic to crate requirements, many changes (#72)
1 parent e3cd630 commit 1f52d09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1500
-918
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Changed
1818

19+
- Rewrite of NEATM and FRM internal models, remove support for saving files related
20+
to thermal and optical models.
1921
- Throughout the rust code, `Time` is being enforced as inputs for functions instead
2022
of accepting `f64` in a large number of places.
2123

Cargo.toml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,22 @@ rust.trivial_casts = "deny"
7676
rust.elided_lifetimes_in_paths = "deny"
7777
rust.unexpected_cfgs = "deny"
7878

79-
clippy.too_many_arguments = "allow"
80-
clippy.type_complexity = "allow"
8179

8280
clippy.perf = { level = "deny", priority = 1 }
83-
# clippy.pedantic = { level = "warn", priority = 1 }
81+
clippy.pedantic = { level = "deny", priority = 1 }
82+
83+
# Pedantic overrides
84+
clippy.float_cmp = {level = "allow", priority = 2 }
85+
clippy.inline_always = {level = "allow", priority = 2 }
86+
clippy.unreadable-literal = {level = "allow", priority = 2}
87+
clippy.similar_names = {level = "allow", priority = 2}
88+
clippy.too_many_lines = {level = "allow", priority = 2}
89+
clippy.cast_precision_loss = {level = "allow", priority = 2}
90+
clippy.cast_possible_truncation = {level = "allow", priority = 2}
8491

92+
# General list
93+
clippy.too_many_arguments = "allow"
94+
clippy.type_complexity = "allow"
8595
clippy.allow_attributes_without_reason = "warn"
8696
clippy.collection_is_never_read = "warn"
8797
clippy.dbg_macro = "warn"
@@ -102,4 +112,10 @@ clippy.use_self = "warn"
102112
clippy.cargo_common_metadata = "warn"
103113
clippy.negative_feature_names = "warn"
104114
clippy.redundant_feature_names = "warn"
105-
clippy.wildcard_dependencies = "warn"
115+
clippy.wildcard_enum_match_arm = "warn"
116+
clippy.wildcard_dependencies = "warn"
117+
clippy.fallible_impl_from = "warn"
118+
clippy.unneeded_field_pattern = "warn"
119+
clippy.fn_params_excessive_bools = "warn"
120+
121+
clippy.must_use_candidate = "deny"

src/kete/plot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def plot_fits_image(fit, percentiles=(0.1, 99.95), power_stretch=1.0, cmap="gray
4343
`ZScaleInterval`.
4444
power_stretch :
4545
The scaling of the intensity of the plot is a power law, this defines the power
46-
of that power law. By default plots are sqrt scaled. If this is set to 1, then
47-
this becomes a linear scaling.
46+
of that power law. By default plots are linear scaled (`power_stretch=1.0`).
4847
cmap :
4948
Color map to use for the plot.
5049
"""

src/kete/rust/fitting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ pub fn ks_test_py(sample_a: Vec<f64>, sample_b: Vec<f64>) -> f64 {
1414
#[pyo3(name = "fit_chi2")]
1515
pub fn fit_chi2_py(data: Vec<f64>, sigmas: Vec<f64>) -> f64 {
1616
assert_eq!(data.len(), sigmas.len());
17-
fitting::fit_reduced_chi2(&data, &sigmas)
17+
fitting::fit_reduced_chi2(&data, &sigmas).unwrap()
1818
}

src/kete/rust/flux/common.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::f64;
2+
13
use crate::{frame::PyFrames, vector::VectorLike};
24
use itertools::Itertools;
35
use kete_core::constants::{
@@ -232,7 +234,7 @@ pub fn neatm_thermal_py(
232234
diameter: f64,
233235
wavelength: f64,
234236
emissivity: f64,
235-
) -> f64 {
237+
) -> PyResult<f64> {
236238
let sun2obj = sun2obj.into_vector(PyFrames::Ecliptic).into();
237239
let sun2obs = sun2obs.into_vector(PyFrames::Ecliptic).into();
238240

@@ -246,17 +248,13 @@ pub fn neatm_thermal_py(
246248
)
247249
.unwrap();
248250
let params = NeatmParams {
249-
obs_bands: ObserverBands::Generic {
250-
bands: vec![wavelength; 1],
251-
zero_mags: None,
252-
solar_correction: vec![1.0],
253-
},
254-
band_albedos: vec![0.0; 1],
251+
obs_bands: vec![BandInfo::new(wavelength, 1.0, f64::NAN, None)],
252+
band_albedos: vec![0.0],
255253
hg_params,
256254
emissivity,
257255
beaming,
258256
};
259-
params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0]
257+
Ok(params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0])
260258
}
261259

262260
/// Calculate the flux from an object using the FRM thermal model in Jansky.
@@ -300,7 +298,7 @@ pub fn frm_thermal_py(
300298
diameter: f64,
301299
wavelength: f64,
302300
emissivity: f64,
303-
) -> f64 {
301+
) -> PyResult<f64> {
304302
let sun2obj = sun2obj.into_vector(PyFrames::Ecliptic).into();
305303
let sun2obs = sun2obs.into_vector(PyFrames::Ecliptic).into();
306304
let hg_params = HGParams::try_new(
@@ -310,20 +308,15 @@ pub fn frm_thermal_py(
310308
Some(C_V),
311309
Some(v_albedo),
312310
Some(diameter),
313-
)
314-
.unwrap();
311+
)?;
315312

316313
let params = FrmParams {
317-
obs_bands: ObserverBands::Generic {
318-
bands: vec![wavelength; 1],
319-
zero_mags: None,
320-
solar_correction: vec![1.0],
321-
},
322-
band_albedos: vec![0.0; 1],
314+
obs_bands: vec![BandInfo::new(wavelength, 1.0, f64::NAN, None)],
315+
band_albedos: vec![0.0],
323316
hg_params,
324317
emissivity,
325318
};
326-
params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0]
319+
Ok(params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0])
327320
}
328321

329322
/// Given the M1/K1 and M2/K2 values, compute the apparent Comet visible magnitudes.
@@ -421,7 +414,7 @@ pub fn w4_color_correction_py(temp: f64) -> f64 {
421414
/// The normal vectors of the fib lattice
422415
#[pyfunction]
423416
#[pyo3(name = "fib_lattice_vecs")]
424-
pub fn fib_lattice_vecs_py(n_facets: usize) -> Vec<[f64; 3]> {
417+
pub fn fib_lattice_vecs_py(n_facets: u32) -> Vec<[f64; 3]> {
425418
let facets = ConvexShape::new_fibonacci_lattice(n_facets).facets;
426419
facets
427420
.iter()

0 commit comments

Comments
 (0)