File "/Users/adam/repos/astrodendro/astrodendro/io/util.py", line 54, in parse_newick
items[branch_id] = eval("{%s}" % string[start + 1:end])
File "<string>", line 1, in <module>
NameError: name 'inf' is not defined
which occurred because my dendrogram was written with boatloads of infs int it. That's a problem with the dendrogram, and maybe it should be handled higher up - there weren't infs in my data originally, but there were nans.
More importantly, though, the use of eval is insecure and unreliable. I replaced it with ast.literal_eval so that only dictionaries containing numbers and None should be returned.
@astrofrog @ChrisBeaumont - Changing inf to None is probably not the right approach, but it's a stopgap. Can you recommend another approach?
I encountered this error:
which occurred because my dendrogram was written with boatloads of infs int it. That's a problem with the dendrogram, and maybe it should be handled higher up - there weren't infs in my data originally, but there were nans.
More importantly, though, the use of
eval
is insecure and unreliable. I replaced it withast.literal_eval
so that only dictionaries containing numbers and None should be returned.@astrofrog @ChrisBeaumont - Changing
inf
toNone
is probably not the right approach, but it's a stopgap. Can you recommend another approach?