Skip to content

Commit d15d405

Browse files
committed
Fixed Linting and formatting
Signed-off-by: Marvin Hansen <[email protected]>
1 parent eb312f7 commit d15d405

File tree

14 files changed

+50
-49
lines changed

14 files changed

+50
-49
lines changed

deep_causality_uncertain/benches/uncertain_benchmarks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use criterion::{criterion_group, criterion_main, Criterion};
2-
use deep_causality_uncertain::{Uncertain, with_global_cache, SampledValue};
1+
use criterion::{Criterion, criterion_group, criterion_main};
2+
use deep_causality_uncertain::{SampledValue, Uncertain, with_global_cache};
33

44
// --- Sampling Performance Benchmarks ---
55

@@ -174,4 +174,4 @@ criterion_group!(
174174
bench_sampling_with_cache_hits,
175175
bench_sampling_with_cache_misses,
176176
);
177-
criterion_main!(benches);
177+
criterion_main!(benches);

deep_causality_uncertain/examples/sensor/sensor_processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn sensor_fusion_with_errors(
366366
// Detect sensor disagreement
367367
let temp_values: Vec<f64> = temp_sensors
368368
.iter()
369-
.map(|(_, temp)| temp.expected_value(100).unwrap().clone())
369+
.map(|(_, temp)| temp.expected_value(100).unwrap())
370370
.collect();
371371

372372
if temp_values.len() > 1 {

deep_causality_uncertain/src/types/cache/global_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ impl GlobalSampleCache {
9898
//
9999
/// Global static instance of the cache, initialized once.
100100
#[cfg(not(test))]
101-
static GLOBAL_SAMPLE_CACHE: OnceLock<GlobalSampleCache> = OnceLock::new();
101+
static GLOBAL_SAMPLE_CACHE: OnceLock<GlobalSampleCache> = const { OnceLock::new() };
102102

103103
#[cfg(test)]
104104
thread_local! {
105-
static GLOBAL_SAMPLE_CACHE: OnceLock<GlobalSampleCache> = OnceLock::new();
105+
static GLOBAL_SAMPLE_CACHE: OnceLock<GlobalSampleCache> = const { OnceLock::new() };
106106
}
107107

108108
/// Executes a closure with a reference to the global sample cache.

deep_causality_uncertain/tests/algos/hypothesis/sprt_eval_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ rusty_fork_test! {
6767
assert!(!sprt_eval::evaluate_hypothesis(&ub_low, 1.0, 0.95, 0.01, 10, 0).unwrap());
6868
}
6969

70+
#[allow(clippy::bool_comparison)]
7071
#[test]
7172
fn test_evaluate_hypothesis_epsilon_effect() {
7273
// Test with a distribution that's exactly on the threshold
@@ -103,6 +104,7 @@ rusty_fork_test! {
103104
assert!(result_low_conf, "Should conclude true with low confidence");
104105
}
105106

107+
#[allow(clippy::bool_comparison)]
106108
#[test]
107109
fn test_evaluate_hypothesis_initial_sample_index() {
108110
// Test that initial_sample_index is used correctly

deep_causality_uncertain/tests/types/computation/node/node_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn test_computation_node_leaf_bool_construction_and_clone() {
2828
let cloned_node = node.clone();
2929

3030
match cloned_node {
31-
ComputationNode::LeafBool(DistributionEnum::Point(val)) => assert_eq!(val, true),
31+
ComputationNode::LeafBool(DistributionEnum::Point(val)) => assert!(val),
3232
_ => panic!("Cloned node is not LeafBool(Point)"),
3333
}
3434
}
@@ -148,7 +148,7 @@ fn test_computation_node_function_op_bool_construction_and_clone() {
148148
operand: cloned_operand,
149149
} => {
150150
// Cannot directly compare Arc<dyn Fn>
151-
assert_eq!(cloned_func(3.0), true); // Test the function still works
151+
assert!(cloned_func(3.0)); // Test the function still works
152152
assert!(matches!(*cloned_operand, ComputationNode::LeafF64(_)));
153153
}
154154
_ => panic!("Cloned node is not FunctionOpBool"),

deep_causality_uncertain/tests/types/computation/operator/arithmetic_operator_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ fn test_arithmetic_operator_div() {
4848
assert_eq!(op.apply(6.0, -3.0), -2.0);
4949
assert_eq!(op.apply(-6.0, -3.0), 2.0);
5050
assert_eq!(op.apply(0.0, 5.0), 0.0);
51-
assert_eq!(op.apply(5.0, 0.0).is_infinite(), true); // Division by zero is positive infinity
52-
assert_eq!(op.apply(-5.0, 0.0).is_infinite(), true); // Division by zero is negative infinity
53-
assert_eq!(op.apply(0.0, 0.0).is_nan(), true); // 0/0 is NaN
51+
assert!(op.apply(5.0, 0.0).is_infinite()); // Division by zero is positive infinity
52+
assert!(op.apply(-5.0, 0.0).is_infinite()); // Division by zero is negative infinity
53+
assert!(op.apply(0.0, 0.0).is_nan()); // 0/0 is NaN
5454
}
5555

5656
#[test]
@@ -69,7 +69,7 @@ fn test_arithmetic_operator_debug_clone_copy() {
6969
assert_eq!(format!("{:?}", op), "Add");
7070

7171
// Test Clone
72-
let cloned_op = op.clone();
72+
let cloned_op = op;
7373
assert_eq!(cloned_op, op);
7474

7575
// Test Copy (by assignment)

deep_causality_uncertain/tests/types/computation/operator/comparison_operator_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn test_comparison_operator_debug_clone_copy() {
6060
assert_eq!(format!("{:?}", op), "GreaterThan");
6161

6262
// Test Clone
63-
let cloned_op = op.clone();
63+
let cloned_op = op;
6464
assert_eq!(cloned_op, op);
6565

6666
// Test Copy (by assignment)

deep_causality_uncertain/tests/types/computation/operator/logical_operator_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn test_logical_operator_debug_clone_copy() {
6565
assert_eq!(format!("{:?}", op), "And");
6666

6767
// Test Clone
68-
let cloned_op = op.clone();
68+
let cloned_op = op;
6969
assert_eq!(cloned_op, op);
7070

7171
// Test Copy (by assignment)

deep_causality_uncertain/tests/types/distribution/distribution_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ fn test_distribution_enum_debug_clone_copy() {
3333
);
3434

3535
// Test Clone
36-
let cloned_point_f64 = point_f64.clone();
37-
let cloned_normal = normal.clone();
38-
let cloned_uniform = uniform.clone();
39-
let cloned_bernoulli = bernoulli.clone();
36+
let cloned_point_f64 = point_f64;
37+
let cloned_normal = normal;
38+
let cloned_uniform = uniform;
39+
let cloned_bernoulli = bernoulli;
4040

4141
assert!(matches!(cloned_point_f64, DistributionEnum::Point(1.0)));
4242
assert!(matches!(cloned_normal, DistributionEnum::Normal(_)));
@@ -84,7 +84,7 @@ fn test_distribution_enum_f64_sample_uniform() {
8484
let sample = dist.sample(&mut rng).unwrap();
8585
dbg!(&sample);
8686

87-
assert!(sample >= 0.0 && sample <= 1.0);
87+
assert!((0.0..=1.0).contains(&sample));
8888
}
8989

9090
#[test]
@@ -94,17 +94,17 @@ fn test_distribution_enum_bool_sample_point() {
9494
let sample = dist.sample(&mut rng).unwrap();
9595
dbg!(&sample);
9696

97-
assert_eq!(sample, true);
97+
assert!(sample);
9898
}
9999

100+
#[allow(clippy::bool_comparison)]
100101
#[test]
101102
fn test_distribution_enum_bool_sample_bernoulli() {
102103
let dist: DistributionEnum<bool> = DistributionEnum::Bernoulli(BernoulliParams::new(0.8));
103104
let mut rng = rng();
104105
let sample = dist.sample(&mut rng).unwrap();
105-
// Cannot assert specific value due to randomness, but ensure it's a bool
106106
dbg!(&sample);
107-
107+
// Due to randomness, we can't assert exact equality, but they should both lean towards true
108108
assert!(sample == true || sample == false);
109109
}
110110

deep_causality_uncertain/tests/types/distribution_parameters/bernoulli_params_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn test_bernoulli_params_debug_clone_copy() {
2828
assert_eq!(format!("{:?}", params), "BernoulliParams { p: 0.75 }");
2929

3030
// Test Clone
31-
let cloned_params = params.clone();
31+
let cloned_params = params;
3232
assert_eq!(cloned_params.p, params.p);
3333

3434
// Test Copy (by assignment)

0 commit comments

Comments
 (0)