aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-02-19 17:11:58 +0100
committerThomas White <taw@physics.org>2024-02-19 17:11:58 +0100
commit0da7d9d1208f273aeb557adaed3f3e0f6dcdfe5a (patch)
tree8ed415aa3ab434554d82c8c1d380a55e373422df
parent93181e995bcae77e69d0b7eb3e32abfdd4d0d738 (diff)
Julia: Add Base.get!(::Reflist, indices)
-rw-r--r--julia/CrystFEL/src/reflists.jl15
-rw-r--r--julia/process_hkl.jl5
2 files changed, 16 insertions, 4 deletions
diff --git a/julia/CrystFEL/src/reflists.jl b/julia/CrystFEL/src/reflists.jl
index 89967d6f..901162e8 100644
--- a/julia/CrystFEL/src/reflists.jl
+++ b/julia/CrystFEL/src/reflists.jl
@@ -108,6 +108,21 @@ function Base.getindex(reflist::RefList{T}, indices) where T
end
+function Base.get!(reflist::RefList{T}, indices) where T
+
+ refl = @ccall libcrystfel.find_refl(reflist.internalptr::Ptr{InternalRefList},
+ indices[1]::Cint,
+ indices[2]::Cint,
+ indices[3]::Cint)::Ptr{InternalReflection}
+
+ if refl == C_NULL
+ return push!(reflist, indices)
+ else
+ return T(refl)
+ end
+end
+
+
function Base.push!(reflist::RefList{T}, indices) where T
refl = @ccall libcrystfel.add_refl(reflist.internalptr::Ptr{InternalRefList},
diff --git a/julia/process_hkl.jl b/julia/process_hkl.jl
index ab2a6a20..ac6ec662 100644
--- a/julia/process_hkl.jl
+++ b/julia/process_hkl.jl
@@ -9,10 +9,7 @@ for (cr,reflections) in allcrystals(st)
for refl in reflections
indices = asymmetricindices(sym, refl.indices)
- model_version = merged[indices]
- if model_version === nothing
- model_version = push!(merged, indices)
- end
+ model_version = get!(merged, indices)
w = 1.0
mean = model_version.intensity