Skip to content

Commit

Permalink
Generalise type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed May 27, 2024
1 parent c643939 commit b925e44
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/atoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Atoms(system::AbstractSystem{D})
system_data = Dict{Symbol,Any}()
for (k, v) in pairs(system)
atoms_base_keys = (:charge, :multiplicity, :boundary_conditions, :bounding_box)
if k in atoms_base_keys || v isa ExtxyzType
if k in atoms_base_keys || v isa ExtxyzType || v isa AbstractArray{<: ExtxyzType}
# These are either Unitful quantities, which are uniformly supported
# across all of AtomsBase or the value has a type that Extxyz can write
# losslessly, so we can just write them no matter the value
Expand Down Expand Up @@ -221,7 +221,12 @@ function write_dict(atoms::Atoms)
elseif v isa ExtxyzType
info[string(k)] = v
elseif v isa AbstractArray{<:ExtxyzType}
info[string(k)] = convert(Array, v)
if size(v, 1) != 3
@warn("Writing Array data with a first leading dimension " *
"different from 3 not supported.") # Else leads to segfaults
else
info[string(k)] = convert(Array, v)
end
else
@warn "Writing quantities of type $(typeof(v)) is not supported in write_dict."
end
Expand Down

0 comments on commit b925e44

Please sign in to comment.