Closed marioangst closed 4 years ago
@tseppelt I think this is probably better dealt with at the Python side as providing character attributes to all other functions seems to work fine. minim reprex:
# set a character vertex attribute based on sesType
ml_net <- network::set.vertex.attribute(ml_net, "lvl", as.character(network::get.vertex.attribute(ml_net,"sesType")))
# check it worked
network::get.vertex.attribute(ml_net,"lvl")
# does not work (setting lvl_attr to "lvl")
motif_summary(ml_net, lvl_attr = "lvl")
#gives:
# Fehler in py_call_impl(callable, dots$args, dots$keywords) :
# TypeError: 'float' object cannot be interpreted as an integer
# does work:
exemplify_motif(ml_net, motif = "1,2[I.C]", directed = FALSE, lvl_attr = "lvl")
show_motif("1,2[I.C]", net = ml_net, directed = FALSE, label = TRUE, lvl_attr = "lvl")
The reason for this was indeed a problem on the Python side. Now resolved in this commit. Wait for the next version of sma or update manually.
Version 2.1.1 of sma which resolves the issue is online on PyPI. As of d359731, there is a test for the workaround.
If motif_summary is given a lvl_attr that is just characters, it will not pass the needed integers to sma.
Solution: enforce conversion to numeric via factors (and throw warning to user)