Skip to content

Commit 71e50af

Browse files
author
Jordan Benjamin
committed
Phase J9: Final Test Suite Harmonization & v0.3.0 Release Hygiene
- Achieved 100% pass rate (145/145 tests). - Resolved all Aqua ambiguities in shorthands and factory constructors. - Confirmed absolute type stability via JET and @inferred tests. - Standardized all imports to strict 'using Module: Module' pattern. - Restored and widened parallel extension support for generic vectors/tuples.
1 parent e23fc98 commit 71e50af

28 files changed

Lines changed: 717 additions & 594 deletions

ext/StructureFunctionsHDF5Ext.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function SFC.calculate_structure_function_from_file(
4242
x_clean, u_clean = SFH.remove_nans(x_mat, u_mat)
4343

4444
# 5. Delegate
45-
return SFC.calculate_structure_function(x_clean, u_clean, bin_edges, sf_type; kwargs...)
45+
return SFC.calculate_structure_function(sf_type, x_clean, u_clean, bin_edges; kwargs...)
4646
end
4747
end
4848

ext/StructureFunctionsParallelCalculationsExt.jl

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export parallel_calculate_structure_function
1616

1717
function SFC.parallel_calculate_structure_function(
1818
structure_function_type::SFT.AbstractStructureFunctionType,
19-
x_vecs::Tuple{T1, Vararg{T1}},
20-
u_vecs::Tuple{T2, Vararg{T2}},
21-
distance_bins::AbstractVector{<:Tuple{FT3, FT3}};
19+
x_vecs::Tuple,
20+
u_vecs::Tuple,
21+
distance_bins::AbstractVector;
2222
return_sums_and_counts::Bool = false,
2323
kwargs...,
24-
) where {T1, T2, FT3}
24+
)
2525
return SFC.parallel_calculate_structure_function(
2626
structure_function_type,
2727
x_vecs,
@@ -34,12 +34,12 @@ end
3434

3535
function SFC.parallel_calculate_structure_function(
3636
structure_function_type::SFT.AbstractStructureFunctionType,
37-
x_vecs::Tuple{T1, Vararg{T1}},
38-
u_vecs::Tuple{T2, Vararg{T2}},
39-
distance_bins::AbstractVector{<:Tuple{FT3, FT3}},
37+
x_vecs::Tuple,
38+
u_vecs::Tuple,
39+
distance_bins::AbstractVector,
4040
::Val{RSAC};
4141
kwargs...,
42-
) where {T1, T2, FT3, RSAC}
42+
) where {RSAC}
4343
return _parallel_calculate_structure_function_core(
4444
structure_function_type,
4545
x_vecs,
@@ -52,66 +52,53 @@ end
5252

5353
function _parallel_calculate_structure_function_core(
5454
structure_function_type::SFT.AbstractStructureFunctionType,
55-
x_vecs::Tuple{T1, Vararg{T1}},
56-
u_vecs::Tuple{T2, Vararg{T2}},
57-
distance_bins::AbstractVector{<:Tuple{FT3, FT3}},
55+
x_vecs::Tuple,
56+
u_vecs::Tuple,
57+
distance_bins::AbstractVector,
5858
::Val{RSAC};
5959
distance_metric::DI.PreMetric = DI.Euclidean(),
6060
verbose = true,
6161
show_progress = true,
62-
) where {T1, T2, FT3, RSAC}
63-
N = length(x_vecs)
64-
N3 = length(distance_bins)
65-
66-
67-
# Create a stable Vector for bins edges
68-
distance_bins_vec = Vector{FT3}(undef, N3 + 1)
69-
for k in 1:N3
70-
distance_bins_vec[k] = distance_bins[k][1]
71-
end
72-
distance_bins_vec[end] = distance_bins[end][2]
73-
62+
) where {RSAC}
7463
if verbose
75-
@info("calculating structure function")
64+
@info("calculating structure function (distributed reduction)")
7665
end
7766

78-
output, counts =
79-
PM.@showprogress enabled = show_progress Distributed.@distributed ((x, y) -> ((x[1] .+ y[1]), (x[2] .+ y[2]))) for i in
80-
eachindex(
81-
x_vecs[1],
82-
)
67+
# Use the result-object wrapper for clean distributed reduction using package types
68+
sums_and_counts =
69+
PM.@showprogress enabled = show_progress Distributed.@distributed (+) for i in eachindex(x_vecs[1])
8370
SFC.calculate_structure_function_i(
8471
structure_function_type,
8572
i,
8673
x_vecs,
8774
u_vecs,
88-
distance_bins_vec;
75+
distance_bins;
8976
distance_metric = distance_metric,
9077
)
9178
end
9279

9380
if RSAC
94-
return SF.StructureFunctionSumsAndCounts(structure_function_type, distance_bins, output, counts)
81+
return sums_and_counts
9582
else
96-
counts_safe = copy(counts)
83+
counts_safe = copy(sums_and_counts.counts)
9784
counts_safe[counts_safe .== 0] .= NaN # replace 0s with NaNs to avoid divide by 0 giving Inf
98-
output_div = output ./ counts_safe
85+
output_div = sums_and_counts.sums ./ counts_safe
9986
return SF.StructureFunction(structure_function_type, distance_bins, output_div)
10087
end
10188
end
10289

10390

10491
function SFC.parallel_calculate_structure_function(
10592
structure_function_type::SFT.AbstractStructureFunctionType,
106-
x_vecs::Tuple{T1, Vararg{T1}},
107-
u_vecs::Tuple{T2, Vararg{T2}},
93+
x_vecs::Tuple,
94+
u_vecs::Tuple,
10895
distance_bins::Int;
10996
distance_metric::DI.PreMetric = DI.Euclidean(),
11097
bin_spacing = :logarithmic,
11198
verbose = true,
11299
show_progress = true,
113-
return_sums_and_counts = false,
114-
) where {T1, T2}
100+
return_sums_and_counts::Bool = false,
101+
)
115102
N = length(x_vecs)
116103
"""
117104
Here we assume that the distance bins are evenly spaced

0 commit comments

Comments
 (0)