setnames! not working as intended for renaming a single row or column
Closed this issue · 3 comments
If I understand the readme correctly, it should be possible to rename a single row or column using the syntax setnames!(n::NamedArray, name, dim::Int, index:Integer)
.
But if I try
X = NamedArray(rand(4,3))
setnames!(X, "mycol", 2, 2)
setnames!(X, "myrow", 1, 2)
then X
looks like
4×3 Named Array{Float64,2}
A ╲ B │ 1 3 mycol
──────┼────────────────────────────────
1 │ 0.740752 0.0383647 0.118565
3 │ 0.101809 0.0394364 0.18354
4 │ 0.729506 0.544528 0.335412
myrow │ 0.0255924 0.300386 0.338951
If I continue trying to set names on rows or columns, the names they are supposed to replace are removed, but the new names are always pushed in at the last index, and the previous names shift over.
Bonus comment: it would be great if index
could be a string or a vector of integers or strings!
Could this be an effect of displaying, i.e., have the rown/column data also been moved?
I just tried the above example using non-random data (X = NamedArray(reshape(1:12,(4,3)))
) and verified that the data is staying in place. It's only the names that are misbehaving.
Yes, this was definitely a bug.