Skip to content

Commit

Permalink
throw argument error if trying to copy an atom
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Nov 1, 2024
1 parent c97e687 commit 0f4089f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Atom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ segname(atom::Atom) = atom.segname
pdb_element(atom::Atom) = atom.pdb_element
charge(atom::Atom) = atom.charge
custom_field(atom::Atom, field::Symbol) = atom.custom[field]
function Base.copy(atom::Atom)
throw(ArgumentError("""\n
The Atom object contains mutable fields. To create an independent copy
of the object, use the `deepcopy` function.
"""))
end

import Base: getproperty
function getproperty(atom::Atom, field::Symbol)
Expand Down Expand Up @@ -145,6 +152,7 @@ end
@test segname(atom) == "PROT"
@test index_pdb(atom) == 13
@test charge(atom) === nothing
@test_throws ArgumentError copy(atom)
end

@testitem "Atom custom fields" begin
Expand Down

0 comments on commit 0f4089f

Please sign in to comment.