Skip to content

Commit

Permalink
rename get_ -> getproperty
Browse files Browse the repository at this point in the history
  • Loading branch information
ACEsuit committed May 28, 2024
1 parent a9efea6 commit 939ebcc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/atomsbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export set_position,
set_positions!,
set_bounding_box!

set_position(x::PState, 𝐫::SVector) = set_property(x, :𝐫, 𝐫)
set_position(x::PState, 𝐫::SVector) = setproperty(x, :𝐫, 𝐫)

function set_position!(sys::AosSystem, i::Integer, 𝐫::SVector)
xi = sys.particles[i]
Expand Down
4 changes: 2 additions & 2 deletions src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ vstate_type(S::Type, X::XState) = vstate_type(zero(S), X)

# this seems allocating, unclear why hence a generated implementation below

@generated function set_property(x::TX, s::Symbol, val) where {TX <: XState}
@generated function setproperty(x::TX, s::Symbol, val) where {TX <: XState}
SYMS, TT = _symstt(TX)
code = "$(nameof(TX))("
for i = 1:length(SYMS)
Expand All @@ -218,7 +218,7 @@ vstate_type(S::Type, X::XState) = vstate_type(zero(S), X)
end
end

@generated function set_property(x::TX, ::Val{sym1}, val1) where {TX <: XState, sym1}
@generated function setproperty(x::TX, ::Val{sym1}, val1) where {TX <: XState, sym1}
SYMS, TT = _symstt(TX)
code = "$(nameof(TX))("
for (sym, T) in zip(SYMS, TT.types)
Expand Down
2 changes: 1 addition & 1 deletion test/test_atomsbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ aos = DP.AosSystem(sys)
x = aos[1]
𝐫 = x.𝐫
𝐫1 = 1.01 * 𝐫
x1 = DP.set_property(x, :𝐫, 𝐫1)
x1 = DP.setproperty(x, :𝐫, 𝐫1)
@test x1.𝐫 == 𝐫1
@test x1.π‘š == x.π‘š
@test x1.𝑍 == x.𝑍
Expand Down
6 changes: 3 additions & 3 deletions test/test_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ end
##

x = PState(a = 1.0, b = 2, c = true)
y = DP.set_property(x, :a, 2.3)
z = DP.set_property(x, Val(:a), 2.3)
y = DP.setproperty(x, :a, 2.3)
z = DP.setproperty(x, Val(:a), 2.3)
@test y.a == 2.3 && y.b == x.b && y.c == x.c
@test z.a == 2.3 && z.b == x.b && z.c == x.c
@test y == z

function transform_states!(Xs, sym)
for i = 1:length(Xs)
xi = Xs[i]
Xs[i] = DecoratedParticles.set_property(xi, sym, rand())
Xs[i] = DecoratedParticles.setproperty(xi, sym, rand())
end
return nothing
end
Expand Down

0 comments on commit 939ebcc

Please sign in to comment.