From 88f0cd43ed68bb06e54fff1d7875dce5659d1cfc Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Wed, 3 Jan 2024 14:52:07 -0700 Subject: [PATCH] Replace `repr(bond)` with explicit string build This way we always see `Bond(...)` and never `Sunny.Bond(...)` in Sunny reports. --- ext/PlottingExt.jl | 3 ++- src/Symmetry/Printing.jl | 3 +-- test/test_symmetry.jl | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/PlottingExt.jl b/ext/PlottingExt.jl index c79a2726d..693fb6e94 100644 --- a/ext/PlottingExt.jl +++ b/ext/PlottingExt.jl @@ -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 diff --git a/src/Symmetry/Printing.jl b/src/Symmetry/Printing.jl index da9896bd1..9f3a06c5e 100644 --- a/src/Symmetry/Printing.jl +++ b/src/Symmetry/Printing.jl @@ -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) diff --git a/test/test_symmetry.jl b/test/test_symmetry.jl index b036fa1ab..c099e6843 100644 --- a/test/test_symmetry.jl +++ b/test/test_symmetry.jl @@ -239,7 +239,7 @@ 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 @@ -247,7 +247,7 @@ end 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 @@ -255,21 +255,21 @@ end 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