Skip to content

Commit

Permalink
Replace repr(bond) with explicit string build
Browse files Browse the repository at this point in the history
This way we always see `Bond(...)` and never `Sunny.Bond(...)` in Sunny reports.
  • Loading branch information
kbarros committed Jan 3, 2024
1 parent 4f319a8 commit 88f0cd4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ext/PlottingExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@ function Sunny.view_crystal(cryst::Crystal; refbonds=10, orthographic=false, gho
for o in observables
Makie.connect!(o.visible, toggle.active)
end
toggle_grid[toggle_cnt+=1, 1:2] = [toggle, Makie.Label(fig, repr(b); fontsize, halign=:left)]
bondstr = "Bond($(b.i), $(b.j), $(b.n))"
toggle_grid[toggle_cnt+=1, 1:2] = [toggle, Makie.Label(fig, bondstr; fontsize, halign=:left)]
end

# Label lattice vectors. Putting this last helps with visibility (Makie
Expand Down
3 changes: 1 addition & 2 deletions src/Symmetry/Printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ function print_bond(cryst::Crystal, b::Bond; b_ref=nothing, io=stdout)
ri = cryst.positions[b.i]
rj = cryst.positions[b.j] + b.n

# Bond(...)
printstyled(io, repr(b); bold=true, color=:underline)
printstyled(io, "Bond($(b.i), $(b.j), $(b.n))"; bold=true, color=:underline)
println(io)
(m_i, m_j) = (coordination_number(cryst, b.i, b), coordination_number(cryst, b.j, b))
dist_str = number_to_simple_string(global_distance(cryst, b); digits, atol=1e-12)
Expand Down
10 changes: 5 additions & 5 deletions test/test_symmetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,37 +239,37 @@ end
c₂*(-7𝒪[4,-3]-2𝒪[4,-2]+𝒪[4,-1]+𝒪[4,1]+7𝒪[4,3]) + c₃*(𝒪[4,0]+5𝒪[4,4]) +
c₄*(-11𝒪[6,-6]-8𝒪[6,-3]+𝒪[6,-2]-8𝒪[6,-1]-8𝒪[6,1]+8𝒪[6,3]) + c₅*(𝒪[6,0]-21𝒪[6,4]) + c₆*((9/5)𝒪[6,-6]+(24/5)𝒪[6,-5]+𝒪[6,-2]+(8/5)𝒪[6,-1]+(8/5)𝒪[6,1]+(24/5)𝒪[6,5])
Sunny.Bond(1, 2, [0, 0, 0])
Bond(1, 2, [0, 0, 0])
Distance 0.35355339059327, coordination 6
Connects [0, 0, 0] to [1/4, 1/4, 0]
Allowed exchange matrix: [A C -D
C A -D
D D B]
Allowed DM vector: [-D D 0]
Sunny.Bond(3, 5, [0, 0, 0])
Bond(3, 5, [0, 0, 0])
Distance 0.61237243569579, coordination 12
Connects [1/2, 1/2, 0] to [1/4, 0, 1/4]
Allowed exchange matrix: [ A C-E D-F
C+E B -C+E
D+F -C-E A]
Allowed DM vector: [E F -E]
Sunny.Bond(1, 3, [-1, 0, 0])
Bond(1, 3, [-1, 0, 0])
Distance 0.70710678118655, coordination 6
Connects [0, 0, 0] to [-1/2, 1/2, 0]
Allowed exchange matrix: [A D C
D A C
C C B]
Sunny.Bond(1, 3, [0, 0, 0])
Bond(1, 3, [0, 0, 0])
Distance 0.70710678118655, coordination 6
Connects [0, 0, 0] to [1/2, 1/2, 0]
Allowed exchange matrix: [A D C
D A C
C C B]
Sunny.Bond(1, 2, [-1, 0, 0])
Bond(1, 2, [-1, 0, 0])
Distance 0.79056941504209, coordination 12
Connects [0, 0, 0] to [-3/4, 1/4, 0]
Allowed exchange matrix: [A D -F
Expand Down

0 comments on commit 88f0cd4

Please sign in to comment.