hildebrandtlab / BiochemicalAlgorithms.jl

The Biochemical Algorithms Library in Julia
MIT License
13 stars 11 forks source link

`setindex!` value type for `SystemComponentTableCol` is too specific #126

Closed tkemmer closed 1 month ago

tkemmer commented 1 month ago

setindex! of abstract table columns fails for values of types not exactly matching eltype, e.g.

Matching type:

julia> atoms().name .= ["test"]      # natoms == 1
1-element SystemComponentTableCol{String}:
 "test"

Compatible but non-matching type:

julia> s = strip(" test")
"test"

julia> typeof(s), eltype(atoms().name)
(SubString{String}, String)

julia> atoms().name .= [s]     # natoms == 1
ERROR: CanonicalIndexError: setindex! not defined for SystemComponentTableCol{String}
Stacktrace:
 [1] error_if_canonical_setindex(::IndexCartesian, A::SystemComponentTableCol{String}, ::Int64)
   @ Base ./abstractarray.jl:1406
 [2] setindex!
   @ ./abstractarray.jl:1395 [inlined]
 [3] macro expansion
   @ ./broadcast.jl:1004 [inlined]
 [4] macro expansion
   @ ./simdloop.jl:77 [inlined]
 [5] copyto!
   @ ./broadcast.jl:1003 [inlined]
 [6] copyto!
   @ ./broadcast.jl:956 [inlined]
 [7] materialize!
   @ ./broadcast.jl:914 [inlined]
 [8] materialize!(dest::SystemComponentTableCol{…}, bc::Base.Broadcast.Broadcasted{…})
   @ Base.Broadcast ./broadcast.jl:911
 [9] top-level scope
   @ REPL[38]:1
Some type information was truncated. Use `show(err)` to see complete types.