Skip to content

Commit 3faf0ec

Browse files
Merge branch 'main' into release-plz-2026-06-17T03-04-27Z
2 parents 700b6cc + fdcb537 commit 3faf0ec

129 files changed

Lines changed: 4023 additions & 3356 deletions

File tree

Some content is hidden

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

build/scripts/miri.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# SPDX-License-Identifier: MIT
3+
# Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4+
#
5+
6+
set -o errexit
7+
set -o nounset
8+
set -o pipefail
9+
10+
CRATES=(
11+
"deep_causality"
12+
"deep_causality_algorithms"
13+
"deep_causality_ast"
14+
"deep_causality_calculus"
15+
"deep_causality_cfd"
16+
"deep_causality_core"
17+
"deep_causality_data_structures"
18+
"deep_causality_discovery"
19+
"deep_causality_ethos"
20+
"deep_causality_fft"
21+
"deep_causality_haft"
22+
"deep_causality_macros"
23+
"deep_causality_metric"
24+
"deep_causality_multivector"
25+
"deep_causality_num"
26+
"deep_causality_par"
27+
"deep_causality_rand"
28+
"deep_causality_physics"
29+
"deep_causality_sparse"
30+
"deep_causality_tensor"
31+
"deep_causality_topology"
32+
"deep_causality_uncertain"
33+
"ultragraph"
34+
)
35+
36+
for CRATE_NAME in "${CRATES[@]}"; do
37+
echo "Running MIRI for crate: $CRATE_NAME"
38+
if ! cargo miri test -p "$CRATE_NAME" --lib --tests
39+
then
40+
echo "Failed to run MIRI for $CRATE_NAME"
41+
fi
42+
done
43+
44+
echo "MIRI complete."

deep_causality_algorithms/tests/causal_discovery/brcd/family_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn mixture_with_all_anomalous_collapses_to_the_present_expert() {
7777
}
7878

7979
#[test]
80+
#[cfg_attr(miri, ignore)]
8081
fn mixture_is_finite_and_deterministic() {
8182
let node = vec![0.0, 1.0, 2.0, 8.0, 9.0, 10.0];
8283
let parents = vec![

deep_causality_algorithms/tests/causal_discovery/brcd/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*/
55
#[cfg(test)]
66
mod augment_tests;
7+
// Disabled under Miri
78
#[cfg(test)]
9+
#[cfg(not(miri))]
810
mod boss_bootstrap_tests;
911
#[cfg(test)]
1012
mod boss_config_tests;
@@ -33,12 +35,15 @@ mod gate_tests;
3335
#[cfg(test)]
3436
mod gaussian_tests;
3537
#[cfg(test)]
38+
#[cfg(not(miri))]
3639
mod mapconfig_tests;
3740
#[cfg(test)]
41+
#[cfg(not(miri))]
3842
mod mec_tests;
3943
#[cfg(test)]
4044
mod meek_tests;
4145
#[cfg(test)]
46+
#[cfg(not(miri))]
4247
mod update_tests;
4348
#[cfg(test)]
4449
mod validity_tests;

deep_causality_algorithms/tests/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
44
*/
55
mod causal_discovery;
6+
// MIRI takes forever on DAG sampling
7+
#[cfg(not(miri))]
68
mod dag_sampling;
79
mod feature_selection;

deep_causality_cfd/tests/solvers/dec/boundary_zone_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn march(solver: &DecNsSolver<'_, 2, f64>, seed: &SolenoidalField<f64>, steps: u
5454
}
5555

5656
#[test]
57+
#[cfg_attr(miri, ignore)]
5758
fn body_force_zone_marches_bit_identically_to_the_legacy_solver() {
5859
let (m, h) = channel(9, [true, false]);
5960
let dt = 0.5 * h * h / (4.0 * NU);

deep_causality_cfd/tests/solvers/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
44
*/
55

6+
#[cfg(test)]
7+
#[cfg(not(miri))]
68
mod dec;
79
mod dec_config;

deep_causality_cfd/tests/types/flow/coupling_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ fn a_stage_error_short_circuits_the_coupling() {
209209
}
210210

211211
#[test]
212+
#[cfg_attr(miri, ignore)]
212213
fn coupled_viscosity_feedback_changes_the_flow_dynamics() {
213214
// A 3D Taylor–Green vortex decay marched twice: once single-physics, once with a hot-wall
214215
// thermal relaxation feeding ν(T) back through the ambient. The coupled run dissipates

deep_causality_cfd/tests/types/flow/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,26 @@ where
2424
pub mod coupling_tests;
2525
#[cfg(test)]
2626
pub mod frequency_tests;
27+
// IO operations are unsupported under MIRI.
2728
#[cfg(test)]
29+
#[cfg(not(miri))]
2830
pub mod io_tests;
2931
#[cfg(test)]
32+
#[cfg(not(miri))]
3033
pub mod march_case_tests;
3134
#[cfg(test)]
35+
#[cfg(not(miri))]
3236
pub mod march_run_tests;
3337
#[cfg(test)]
3438
pub mod mms_tests;
3539
#[cfg(test)]
40+
#[cfg(not(miri))]
3641
pub mod operator_study_tests;
3742
#[cfg(test)]
3843
pub mod report_tests;
44+
// IO operations are unsupported under MIRI.
3945
#[cfg(test)]
46+
#[cfg(not(miri))]
4047
pub mod uncertain_march_run_tests;
4148
#[cfg(test)]
4249
pub mod verify_tests;

deep_causality_physics/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub(crate) mod error;
1313
pub(crate) mod kernels;
1414
pub mod quantities;
1515
pub mod theories;
16+
#[cfg(feature = "alloc")]
17+
pub mod utils_tests;
1618

1719
pub use crate::constants::*;
1820

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4+
*/
5+
6+
//! Shared test fixtures for the physics test suite.
7+
//!
8+
//! These helpers build discrete manifolds and cochains used by the
9+
//! `SolenoidalField` tests. They live in the source tree (rather than inside
10+
//! the `tests/` folder) because the Bazel `rust_test_suite` compiles each
11+
//! `*_tests.rs` file as a standalone crate, so test files cannot share helpers
12+
//! across one another — only the crate under test is visible to all of them.
13+
14+
use alloc::{vec, vec::Vec};
15+
use deep_causality_num::{FromPrimitive, RealField};
16+
use deep_causality_tensor::CausalTensor;
17+
use deep_causality_topology::{ChainComplex, CubicalReggeGeometry, LatticeComplex, Manifold};
18+
19+
/// A 2D square-torus lattice manifold of side `n` with unit cubical metric.
20+
pub fn unit_manifold<R>(n: usize) -> Manifold<LatticeComplex<2, R>, R>
21+
where
22+
R: RealField
23+
+ deep_causality_par::MaybeParallel
24+
+ FromPrimitive
25+
+ Default
26+
+ PartialEq
27+
+ core::fmt::Debug
28+
+ core::fmt::Display,
29+
{
30+
let lattice: LatticeComplex<2, R> = LatticeComplex::square_torus(n);
31+
let total: usize = (0..=2).map(|k| lattice.num_cells(k)).sum();
32+
let data = CausalTensor::new(vec![R::zero(); total], vec![total]).unwrap();
33+
let metric: CubicalReggeGeometry<2, R> = CubicalReggeGeometry::unit();
34+
Manifold::from_cubical_with_metric(lattice, data, metric, 0)
35+
}
36+
37+
/// A deterministic pseudo-random cochain of length `len` in `[-1, 1]`.
38+
pub fn random_cochain<R: RealField + FromPrimitive>(len: usize, seed: u64) -> Vec<R> {
39+
let mut state = seed
40+
.wrapping_mul(6364136223846793005)
41+
.wrapping_add(1442695040888963407);
42+
(0..len)
43+
.map(|_| {
44+
state = state
45+
.wrapping_mul(6364136223846793005)
46+
.wrapping_add(1442695040888963407);
47+
let unit = (state >> 11) as f64 / (1u64 << 53) as f64;
48+
R::from_f64(2.0 * unit - 1.0).expect("[-1,1] lifts")
49+
})
50+
.collect()
51+
}
52+
53+
/// Discrete divergence of an edge cochain: place at grade 1, apply δ.
54+
pub fn divergence<R>(manifold: &Manifold<LatticeComplex<2, R>, R>, one_form: &[R]) -> Vec<R>
55+
where
56+
R: RealField
57+
+ deep_causality_par::MaybeParallel
58+
+ FromPrimitive
59+
+ Default
60+
+ PartialEq
61+
+ core::fmt::Debug
62+
+ core::fmt::Display,
63+
{
64+
let lattice = LatticeComplex::<2, R>::square_torus(
65+
// shape is square by fixture construction
66+
manifold.complex().shape()[0],
67+
);
68+
let total: usize = (0..=2).map(|g| lattice.num_cells(g)).sum();
69+
let n0 = lattice.num_cells(0);
70+
let mut data = vec![R::zero(); total];
71+
data[n0..n0 + one_form.len()].copy_from_slice(one_form);
72+
let tensor = CausalTensor::new(data, vec![total]).unwrap();
73+
let metric: CubicalReggeGeometry<2, R> = CubicalReggeGeometry::unit();
74+
let m = Manifold::from_cubical_with_metric(lattice, tensor, metric, 0);
75+
m.codifferential(1).as_slice().to_vec()
76+
}
77+
78+
/// Supremum (max-abs) norm of a slice.
79+
pub fn sup_norm<R: RealField>(v: &[R]) -> R {
80+
v.iter()
81+
.map(|x| x.abs())
82+
.fold(R::zero(), |m, x| if x > m { x } else { m })
83+
}
84+
85+
#[cfg(test)]
86+
mod tests {
87+
use super::*;
88+
89+
#[test]
90+
fn test_sup_norm() {
91+
assert_eq!(sup_norm(&[-3.0_f64, 1.0, 2.0]), 3.0);
92+
assert_eq!(sup_norm::<f64>(&[]), 0.0);
93+
}
94+
95+
#[test]
96+
fn test_random_cochain_is_bounded_and_deterministic() {
97+
let a = random_cochain::<f64>(16, 7);
98+
let b = random_cochain::<f64>(16, 7);
99+
assert_eq!(a, b);
100+
assert!(a.iter().all(|&x| (-1.0..=1.0).contains(&x)));
101+
}
102+
103+
#[test]
104+
fn test_unit_manifold_and_divergence_dimensions() {
105+
let manifold = unit_manifold::<f64>(4);
106+
let n1 = manifold.complex().num_cells(1);
107+
let div = divergence(&manifold, &random_cochain::<f64>(n1, 1));
108+
assert_eq!(div.len(), manifold.complex().num_cells(0));
109+
}
110+
}

0 commit comments

Comments
 (0)